Private
Public Access
1
0

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 <noreply@anthropic.com>
This commit is contained in:
constantprojects
2026-02-24 08:45:18 -07:00
parent 06ecfe1034
commit 9ec246cb65

View File

@@ -5,6 +5,32 @@ set -eo pipefail
# Bootstrap script: installs Docker, clones repo, runs setup wizard # Bootstrap script: installs Docker, clones repo, runs setup wizard
# Usage: curl -fsSL <url>/install.sh | bash # Usage: curl -fsSL <url>/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 "═══════════════════════════════════════════════════════════" echo "═══════════════════════════════════════════════════════════"
echo " WebsiteBox Installer" echo " WebsiteBox Installer"
@@ -75,13 +101,13 @@ echo "Updating system packages..."
echo " Downloading the latest security patches for your operating system." echo " Downloading the latest security patches for your operating system."
echo " On a fresh server this can take 2-10 minutes. Sit tight." echo " On a fresh server this can take 2-10 minutes. Sit tight."
$SUDO apt-get update -qq $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." echo "System packages updated."
# Install firewall, fail2ban, and automatic updates # Install firewall, fail2ban, and automatic updates
echo "Installing security tools (firewall, fail2ban, auto-updates)..." echo "Installing security tools (firewall, fail2ban, auto-updates)..."
echo " These protect your server from common attacks. Usually under a minute." 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 # Configure firewall — allow SSH first to avoid lockout
if ! $SUDO ufw status | grep -q "Status: active"; then if ! $SUDO ufw status | grep -q "Status: active"; then
@@ -148,6 +174,10 @@ DOCKER_JUST_INSTALLED=false
if command -v docker &>/dev/null; then if command -v docker &>/dev/null; then
echo "Docker is already installed." 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 else
echo "Installing Docker..." echo "Installing Docker..."
echo " Docker packages and runs your website in isolated containers." echo " Docker packages and runs your website in isolated containers."
@@ -155,7 +185,7 @@ else
# Install prerequisites # Install prerequisites
$SUDO apt-get update -qq $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 # Add Docker's GPG key
$SUDO install -m 0755 -d /etc/apt/keyrings $SUDO install -m 0755 -d /etc/apt/keyrings
@@ -170,7 +200,7 @@ else
# Install Docker # Install Docker
$SUDO apt-get update -qq $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 # Add user to docker group
if [ "$ACTUAL_USER" != "root" ]; then if [ "$ACTUAL_USER" != "root" ]; then
@@ -184,11 +214,6 @@ else
$SUDO systemctl enable docker $SUDO systemctl enable docker
echo "Docker installation complete." 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 fi
# --- Clone Repository --- # --- Clone Repository ---