ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(install): apt could stop and wait for an answer nobody can give
Juan Denis8b417d2ae57a
diff --git a/install.sh b/install.shindex 246e83f1..be968e69 100644--- a/install.sh+++ b/install.sh@@ -422,7 +422,18 @@ ensure_bootstrap_tools() {pkg_add() {local out="" rc=0case "$PKG_MGR" in- apt) out=$(apt-get install -y "$@" 2>&1) || rc=$? ;;+ # -y is NOT enough on Debian/Ubuntu. It answers apt's own prompts but+ # not debconf's: tzdata, keyboard-configuration and friends still open+ # an interactive dialog and wait forever. Because this output is+ # captured, the installer then hangs in total silence — observed as a+ # 60-minute stall on ubuntu:22.04 with the prompt invisible. Worse+ # under `curl | bash`, where stdin is the script itself, so debconf can+ # read installer source as its answers. The Dpkg options cover the+ # other prompt class (modified conffiles), which DEBIAN_FRONTEND alone+ # does not suppress. Every other manager here was already guarded.+ apt) out=$(DEBIAN_FRONTEND=noninteractive apt-get install -y \+ -o Dpkg::Options::=--force-confold \+ -o Dpkg::Options::=--force-confdef "$@" 2>&1) || rc=$? ;;dnf) out=$(dnf install -y "$@" 2>&1) || rc=$? ;;yum) out=$(yum install -y "$@" 2>&1) || rc=$? ;;zypper) out=$(zypper --non-interactive install "$@" 2>&1) || rc=$? ;;diff --git a/scripts/lib/pkg.sh b/scripts/lib/pkg.shindex c9a4425b..aed47d02 100644--- a/scripts/lib/pkg.sh+++ b/scripts/lib/pkg.sh@@ -109,7 +109,16 @@ pkg_install() {case "$mgr" in# Deliberate word-splitting of the package list via "$@" — each argument# is already a separate, individually-quoted package name.- apt) _pkg_run apt-get install -y "$@" ;;+ # `env VAR=…` rather than an exported variable: _pkg_sudo runs plain+ # `sudo "$@"`, and sudo's env_reset would drop an exported+ # DEBIAN_FRONTEND before apt ever saw it. Putting it in argv survives.+ # Without it, debconf (tzdata et al) opens a dialog and waits forever —+ # the docstring above promised "non-interactively" and only apt did not+ # deliver it. --force-conf* covers modified-conffile prompts, which+ # DEBIAN_FRONTEND does not suppress.+ apt) _pkg_run env DEBIAN_FRONTEND=noninteractive apt-get install -y \+ -o Dpkg::Options::=--force-confold \+ -o Dpkg::Options::=--force-confdef "$@" ;;dnf) _pkg_run dnf install -y "$@" ;;yum) _pkg_run yum install -y "$@" ;;zypper) _pkg_run zypper --non-interactive install "$@" ;;diff --git a/scripts/test/test_install.sh b/scripts/test/test_install.shindex 587ea1b0..23d64630 100644--- a/scripts/test/test_install.sh+++ b/scripts/test/test_install.sh@@ -712,7 +712,10 @@ exit 1EOFchmod +x "$t/bin/apt-get"( set -Eeuo pipefail; PATH="$t/bin:$PYX:$PATH"; OS_FAMILY=debian PKG_MGR=apt locate_python ) >/dev/null 2>&1-if grep -q 'install -y python3.11-venv' "$APT_LOG"; then+# Match the PACKAGE, not the exact argv: pkg_add also passes+# -o Dpkg::Options::=… now, and an assertion pinned to `install -y <pkg>`+# breaks on any future flag without the behaviour under test changing.+if grep -qE 'install .*python3\.11-venv' "$APT_LOG"; thenok "locate_python (Debian family) tries to install the matching pythonX.Y-venv package"elsebad "locate_python never attempted the python3.11-venv fallback; apt saw: $(tr '\n' ';' < "$APT_LOG")"@@ -735,8 +738,8 @@ EOFchmod +x "$t/bin/apt-get"out="$( set -Eeuo pipefail; PATH="$t/bin:$PATH"; PKG_MGR=apt ensure_compose_plugin 2>&1 )"rc=$?-if [ "$rc" -eq 0 ] && grep -q 'install -y docker-compose-plugin' "$APT_LOG" \- && grep -q 'install -y docker-compose-v2' "$APT_LOG" \+if [ "$rc" -eq 0 ] && grep -qE 'install .*docker-compose-plugin' "$APT_LOG" \+ && grep -qE 'install .*docker-compose-v2' "$APT_LOG" \&& printf '%s' "$out" | grep -q 'docker compose'; thenok "ensure_compose_plugin tries plugin → docker-compose-v2 → warn-and-continue (never aborts)"else@@ -971,7 +974,7 @@ out="$( set -Eeuo pipefail; PATH="$t/bin"OS_FAMILY=debian PKG_MGR=apt provision_docker 2>&1 )"rc=$?if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -q 'get.docker.com' && \- grep -q 'install -y docker.io' "$APT_LOG"; then+ grep -qE 'install .*docker\.io' "$APT_LOG"; thenok "provision_docker warns and falls back to the distro package when the download fails"elsebad "provision_docker rc=$rc on a failed download (I13); apt saw: $(tr '\n' ';' < "$APT_LOG"): [$out]"@@ -2176,6 +2179,21 @@ elsebad "the rendered unit does not bind loopback: [$(grep ExecStart "$unit" 2>/dev/null)]"fi+# -- apt must never be able to open an interactive prompt.+#+# `apt-get install -y` answers apt's questions but NOT debconf's: tzdata and+# friends still open a dialog and block. pkg_add captures output, so the+# installer then hangs in complete silence — a real 60-minute stall on+# ubuntu:22.04, found only once provisioning was exercised for real. Under+# `curl | bash` it is worse: stdin is the script, so debconf can consume+# installer source as its answers.+apt_line="$(awk '/^pkg_add\(\)/,/^}/' "$INSTALL_SH" | grep -A3 'apt)')"+if printf '%s' "$apt_line" | grep -q 'DEBIAN_FRONTEND=noninteractive'; then+ ok "pkg_add runs apt with DEBIAN_FRONTEND=noninteractive"+else+ bad "pkg_add's apt branch can block on a debconf prompt: [$apt_line]"+fi+# -- static guard: the documented insecure site must keep shipping, since both# the docs and SERVERKIT_EXTERNAL_PROXY point operators straight at it.if [ -f "$REPO_DIR/nginx/sites-available/serverkit-insecure.conf" ] \diff --git a/scripts/test/test_lib.sh b/scripts/test/test_lib.shindex 4f26086f..ca8921e2 100644--- a/scripts/test/test_lib.sh+++ b/scripts/test/test_lib.sh@@ -60,7 +60,9 @@ ok "pkg_detect honors PKG_MGR_OVERRIDE for all six managers"# Each manager's install command, captured in dry-run.declare -A expect_install=(- [apt]="apt-get install -y git"+ # apt must carry the non-interactive guard in ARGV (sudo strips exported+ # env), or debconf stalls the install forever with no visible prompt.+ [apt]="env DEBIAN_FRONTEND=noninteractive apt-get install -y"[dnf]="dnf install -y git"[yum]="yum install -y git"[zypper]="zypper --non-interactive install git"@@ -76,6 +78,27 @@ for mgr in "${!expect_install[@]}"; dodone[ "$allok" = "1" ] && ok "pkg_install emits the right command per manager (dry-run)"+# Every manager must be non-interactive. An install that stops to ask a question+# nobody can answer hangs forever, and under `curl | bash` stdin is the script+# itself — so the prompt may consume installer source as its answer.+declare -A expect_noninteractive=(+ [apt]="DEBIAN_FRONTEND=noninteractive"+ [dnf]="-y"+ [yum]="-y"+ [zypper]="--non-interactive"+ [pacman]="--noconfirm"+)+allok=1+for mgr in "${!expect_noninteractive[@]}"; do+ # `--` before the pattern: these expectations are flags (-y, --noconfirm),+ # and grep would otherwise parse them as its own options.+ if ! out="$( set -Eeuo pipefail; PKG_DRY_RUN=1 PKG_MGR_OVERRIDE="$mgr" pkg_install git 2>&1 )" \+ || ! printf '%s' "$out" | grep -qF -- "${expect_noninteractive[$mgr]}"; then+ bad "pkg_install $mgr can prompt: [$out]"; allok=0+ fi+done+[ "$allok" = "1" ] && ok "pkg_install is non-interactive for every manager"+# Empty PATH genuinely hides every package manager (CI distro containers DO ship# one, so PKG_MGR_OVERRIDE="" alone would run a real install here).if ( set -Eeuo pipefail; PATH="" PKG_MGR_OVERRIDE="" PKG_DRY_RUN=0 pkg_install git ) 2>/dev/null; then