From 9ec246cb657fbc950c6e4da93e4e09060e0b376a Mon Sep 17 00:00:00 2001 From: constantprojects Date: Tue, 24 Feb 2026 08:45:18 -0700 Subject: [PATCH] Add rolling 4-line progress preview to install.sh Long-running apt commands now show a live 4-line preview window that overwrites in place using terminal escape codes. Users see what's happening without the screen flooding with package manager output. Preview auto-clears when each step completes. Also fixes: duplicate else branch in Docker if/else block, adds DEBIAN_FRONTEND=noninteractive and --force-confold to prevent interactive dpkg prompts (sshd_config, etc). Co-Authored-By: Claude Opus 4.6 --- install.sh | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 820d051..82f2209 100755 --- a/install.sh +++ b/install.sh @@ -5,6 +5,32 @@ set -eo pipefail # Bootstrap script: installs Docker, clones repo, runs setup wizard # Usage: curl -fsSL /install.sh | bash +# --- Rolling preview helper --- +# Shows last 4 lines of output in-place, then clears when done. +# Keeps the terminal clean while still showing live progress. +show_progress() { + local n=4 buffer=() count=0 + while IFS= read -r line; do + buffer+=("$line") + (( count++ )) || true + if [ ${#buffer[@]} -gt $n ]; then + buffer=("${buffer[@]:1}") + fi + if [ $count -gt 1 ]; then + printf '\033[%dA' "${#buffer[@]}" 2>/dev/null || true + fi + for l in "${buffer[@]}"; do + printf '\033[2K %.60s\n' "$l" + done + done + # clear preview lines when done + if [ ${#buffer[@]} -gt 0 ]; then + printf '\033[%dA' "${#buffer[@]}" 2>/dev/null || true + for _ in "${buffer[@]}"; do printf '\033[2K\n'; done + printf '\033[%dA' "${#buffer[@]}" 2>/dev/null || true + fi +} + echo "" echo "═══════════════════════════════════════════════════════════" echo " WebsiteBox Installer" @@ -75,13 +101,13 @@ echo "Updating system packages..." echo " Downloading the latest security patches for your operating system." echo " On a fresh server this can take 2-10 minutes. Sit tight." $SUDO apt-get update -qq -$SUDO apt-get upgrade -y -qq -o Dpkg::Options::="--force-confold" +DEBIAN_FRONTEND=noninteractive $SUDO apt-get upgrade -y -o Dpkg::Options::="--force-confold" 2>&1 | show_progress echo "System packages updated." # Install firewall, fail2ban, and automatic updates echo "Installing security tools (firewall, fail2ban, auto-updates)..." echo " These protect your server from common attacks. Usually under a minute." -$SUDO apt-get install -y -qq ufw fail2ban unattended-upgrades +DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y ufw fail2ban unattended-upgrades 2>&1 | show_progress # Configure firewall — allow SSH first to avoid lockout if ! $SUDO ufw status | grep -q "Status: active"; then @@ -148,6 +174,10 @@ DOCKER_JUST_INSTALLED=false if command -v docker &>/dev/null; then echo "Docker is already installed." + # Restart to pick up daemon.json if it was just created + if [ -f /etc/docker/daemon.json ]; then + $SUDO systemctl restart docker 2>/dev/null || true + fi else echo "Installing Docker..." echo " Docker packages and runs your website in isolated containers." @@ -155,7 +185,7 @@ else # Install prerequisites $SUDO apt-get update -qq - $SUDO apt-get install -y -qq ca-certificates curl gnupg lsb-release + DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y ca-certificates curl gnupg lsb-release 2>&1 | show_progress # Add Docker's GPG key $SUDO install -m 0755 -d /etc/apt/keyrings @@ -170,7 +200,7 @@ else # Install Docker $SUDO apt-get update -qq - $SUDO apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin + DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin 2>&1 | show_progress # Add user to docker group if [ "$ACTUAL_USER" != "root" ]; then @@ -184,11 +214,6 @@ else $SUDO systemctl enable docker echo "Docker installation complete." -else - # Docker exists — restart to pick up daemon.json if it was just created - if [ -f /etc/docker/daemon.json ]; then - $SUDO systemctl restart docker 2>/dev/null || true - fi fi # --- Clone Repository ---