mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
feat(install): Add install-only mode to the install script (#194)
This commit is contained in:
+27
-7
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# If set to 'true', only install the packages and dependencies, without running, reloading, or
|
||||||
|
# restarting services or systemd.
|
||||||
|
INSTALL_ONLY=${INSTALL_ONLY:-false}
|
||||||
|
|
||||||
INSTALL_BIN_DIR=${INSTALL_BIN_DIR:-/usr/local/bin}
|
INSTALL_BIN_DIR=${INSTALL_BIN_DIR:-/usr/local/bin}
|
||||||
INSTALL_SYSTEMD_DIR=${INSTALL_SYSTEMD_DIR:-/etc/systemd/system}
|
INSTALL_SYSTEMD_DIR=${INSTALL_SYSTEMD_DIR:-/etc/systemd/system}
|
||||||
|
|
||||||
@@ -57,7 +61,7 @@ verify_system() {
|
|||||||
Your system architecture ($arch) is not supported."
|
Your system architecture ($arch) is not supported."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d /run/systemd/system ]]; then
|
if [[ ! -d /run/systemd/system && "${INSTALL_ONLY}" != "true" ]]; then
|
||||||
error "Cannot find systemd to use as a service manager for the Uncloud machine daemon. \
|
error "Cannot find systemd to use as a service manager for the Uncloud machine daemon. \
|
||||||
Uncloud supports only systemd-based Linux systems for now."
|
Uncloud supports only systemd-based Linux systems for now."
|
||||||
fi
|
fi
|
||||||
@@ -66,9 +70,14 @@ Uncloud supports only systemd-based Linux systems for now."
|
|||||||
install_docker() {
|
install_docker() {
|
||||||
if command_exists dockerd; then
|
if command_exists dockerd; then
|
||||||
log "✓ Docker is already installed."
|
log "✓ Docker is already installed."
|
||||||
|
DOCKER_ALREADY_INSTALLED=true
|
||||||
|
|
||||||
|
if [[ "${INSTALL_ONLY}" == "true" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
docker version
|
docker version
|
||||||
|
|
||||||
DOCKER_ALREADY_INSTALLED=true
|
|
||||||
# Check if the installed Docker configured to use the containerd image store.
|
# Check if the installed Docker configured to use the containerd image store.
|
||||||
local driver_status
|
local driver_status
|
||||||
driver_status=$(docker info -f '{{ .DriverStatus }}' 2>/dev/null)
|
driver_status=$(docker info -f '{{ .DriverStatus }}' 2>/dev/null)
|
||||||
@@ -93,7 +102,9 @@ install_docker() {
|
|||||||
log "⏳ Configuring Docker daemon (${DOCKER_DAEMON_CONFIG_FILE}) to optimise it for Uncloud..."
|
log "⏳ Configuring Docker daemon (${DOCKER_DAEMON_CONFIG_FILE}) to optimise it for Uncloud..."
|
||||||
echo "${DOCKER_DAEMON_CONFIG}" > "${DOCKER_DAEMON_CONFIG_FILE}"
|
echo "${DOCKER_DAEMON_CONFIG}" > "${DOCKER_DAEMON_CONFIG_FILE}"
|
||||||
|
|
||||||
systemctl restart docker
|
if [[ "${INSTALL_ONLY}" != "true" ]]; then
|
||||||
|
systemctl restart docker
|
||||||
|
fi
|
||||||
|
|
||||||
log "✓ Docker installed and configured successfully."
|
log "✓ Docker installed and configured successfully."
|
||||||
}
|
}
|
||||||
@@ -215,8 +226,11 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
log "✓ Systemd unit file created: ${uncloud_service_path}"
|
log "✓ Systemd unit file created: ${uncloud_service_path}"
|
||||||
|
|
||||||
# Reload systemd to recognize the new or updated unit file.
|
|
||||||
systemctl daemon-reload
|
if [[ "${INSTALL_ONLY}" != "true" ]]; then
|
||||||
|
# Reload systemd to recognize the new or updated unit file.
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
systemctl enable uncloud.service
|
systemctl enable uncloud.service
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,11 +298,17 @@ RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
|
|||||||
EOF
|
EOF
|
||||||
log "✓ Systemd unit file created: ${corrosion_service_path}"
|
log "✓ Systemd unit file created: ${corrosion_service_path}"
|
||||||
|
|
||||||
# Reload systemd to recognize the new unit file
|
if [[ "${INSTALL_ONLY}" != "true" ]]; then
|
||||||
systemctl daemon-reload
|
# Reload systemd to recognize the new unit file
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_uncloud() {
|
start_uncloud() {
|
||||||
|
if [[ "${INSTALL_ONLY}" == "true" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
log "⏳ Starting Uncloud machine daemon (uncloud.service)..."
|
log "⏳ Starting Uncloud machine daemon (uncloud.service)..."
|
||||||
systemctl restart uncloud.service
|
systemctl restart uncloud.service
|
||||||
log "✓ Uncloud machine daemon started."
|
log "✓ Uncloud machine daemon started."
|
||||||
|
|||||||
Reference in New Issue
Block a user