fix(install): install curl on machine init/add if missing (fixes #402)

This commit is contained in:
Pasha Sviderski
2026-06-25 10:52:22 +10:00
parent e9762dda21
commit e5b205391e
+34
View File
@@ -2,6 +2,10 @@
set -euo pipefail set -euo pipefail
# Avoid locale warnings (e.g. on apt install) from SSH-forwarded LANG/LC_* on minimal hosts. C.UTF-8 is built into
# glibc and present on all supported distros, unlike locale-specific values like en_US.UTF-8 that may not be generated.
export LC_ALL="${LC_ALL:-C.UTF-8}"
# If set to 'true', only install the packages and dependencies, without running, reloading, or # If set to 'true', only install the packages and dependencies, without running, reloading, or
# restarting services or systemd. # restarting services or systemd.
INSTALL_ONLY=${INSTALL_ONLY:-false} INSTALL_ONLY=${INSTALL_ONLY:-false}
@@ -64,6 +68,35 @@ Uncloud supports only systemd-based Linux systems for now."
fi fi
} }
# install_prerequisites ensures curl is available, installing it with the system package manager if needed.
install_prerequisites() {
if command_exists curl; then
return
fi
log "⏳ curl is required but not installed, installing it using the system package manager..."
if command_exists apt-get; then
apt-get update -qq >/dev/null
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq curl ca-certificates
elif command_exists dnf; then
dnf install -y curl ca-certificates
elif command_exists yum; then
yum install -y curl ca-certificates
elif command_exists pacman; then
pacman -Sy --noconfirm curl ca-certificates
elif command_exists zypper; then
zypper --non-interactive refresh >/dev/null
zypper --non-interactive install curl ca-certificates
else
error "curl is required but not installed, and no supported package manager \
(apt, dnf, yum, pacman, zypper) was found to install it automatically. \
Please install curl manually and re-run the command."
fi
log "✓ curl installed."
}
install_docker() { install_docker() {
if command_exists dockerd; then if command_exists dockerd; then
log "✓ Docker is already installed." log "✓ Docker is already installed."
@@ -298,6 +331,7 @@ if [ "$EUID" -ne 0 ]; then
fi fi
verify_system verify_system
install_prerequisites
install_docker install_docker
create_uncloud_user_and_group create_uncloud_user_and_group
install_uncloud_binaries install_uncloud_binaries