feat(install): Add install-only mode to the install script (#194)

This commit is contained in:
Anton Ovchinnikov
2025-11-30 20:00:33 +01:00
committed by GitHub
parent d89bfb8e03
commit 234985b57d
+22 -2
View File
@@ -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}"
if [[ "${INSTALL_ONLY}" != "true" ]]; then
systemctl restart docker 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}"
if [[ "${INSTALL_ONLY}" != "true" ]]; then
# Reload systemd to recognize the new or updated unit file. # Reload systemd to recognize the new or updated unit file.
systemctl daemon-reload 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}"
if [[ "${INSTALL_ONLY}" != "true" ]]; then
# Reload systemd to recognize the new unit file # Reload systemd to recognize the new unit file
systemctl daemon-reload 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."