fix: self-update + fold PPA into packages step

On Ubuntu 24.04, PHP 8.2 is not in the default apt repos.
The ondrej/php PPA must be added before package installation.

Previously this was a separate step that could be bypassed when
running a locally-cached (pre-fix) copy of install.sh.

Changes:
- Add self-update block: script fetches latest version from GitHub
  and re-execs itself, so stale local copies are never used
- Remove standalone php_ppa step; PPA is now added unconditionally
  inside the packages step (checks if already present to avoid
  duplicate adds on re-runs)
- Idempotent: grep checks sources.list before calling
  add-apt-repository
This commit is contained in:
NixReaper
2026-04-23 17:43:05 -05:00
parent 6f2a2bac6b
commit f54b5cd582
+27 -13
View File
@@ -6,6 +6,20 @@
# ────────────────────────────────────────────────────────────────────────────── # ──────────────────────────────────────────────────────────────────────────────
set -euo pipefail set -euo pipefail
# ── Self-update ───────────────────────────────────────────────────────────────
# Always re-exec from the latest version on GitHub so stale local copies
# never silently run outdated logic.
SELF_URL="https://raw.githubusercontent.com/NixReaper/nixpanel/main/install.sh"
if [[ -z "${NIXPANEL_SELF_UPDATED:-}" ]]; then
echo "Fetching latest installer from GitHub…"
LATEST_SCRIPT=$(curl -fsSL "$SELF_URL") \
|| { echo "[WARN] Could not reach GitHub — running local copy"; LATEST_SCRIPT=""; }
if [[ -n "$LATEST_SCRIPT" ]]; then
export NIXPANEL_SELF_UPDATED=1
exec bash <(printf '%s' "$LATEST_SCRIPT") "$@"
fi
fi
# ── Colours ─────────────────────────────────────────────────────────────────── # ── Colours ───────────────────────────────────────────────────────────────────
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m' RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'
YELLOW='\033[1;33m'; BOLD='\033[1m'; RESET='\033[0m' YELLOW='\033[1;33m'; BOLD='\033[1m'; RESET='\033[0m'
@@ -75,22 +89,22 @@ if ! step_done "resolved_stub"; then
fi fi
success "Port 53 free" success "Port 53 free"
# ── 3. ondrej/php PPA (required for PHP 8.2 on Ubuntu 24.04) ───────────────── # ── 3. System packages (including ondrej/php PPA for PHP 8.2 on Ubuntu 24.04) ─
step "Adding ondrej/php PPA"
if ! step_done "php_ppa"; then
export DEBIAN_FRONTEND=noninteractive
# Install prereqs for add-apt-repository
apt-get install -y -qq ca-certificates gnupg software-properties-common
add-apt-repository -y ppa:ondrej/php
apt-get update -qq
mark_done "php_ppa"
fi
success "ondrej/php PPA added"
# ── 4. System packages ────────────────────────────────────────────────────────
step "Installing system packages" step "Installing system packages"
if ! step_done "packages"; then if ! step_done "packages"; then
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
# Ensure PPA tooling is present, then add ondrej/php for PHP 8.2
apt-get install -y -qq ca-certificates gnupg software-properties-common
if ! grep -rq "ondrej/php" /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null; then
info "Adding ondrej/php PPA (required for PHP 8.2 on Ubuntu 24.04)…"
add-apt-repository -y ppa:ondrej/php
apt-get update -qq
success "ondrej/php PPA added"
else
info "ondrej/php PPA already present"
fi
apt-get install -y -qq \ apt-get install -y -qq \
build-essential pkg-config libssl-dev libmariadb-dev curl wget git unzip \ build-essential pkg-config libssl-dev libmariadb-dev curl wget git unzip \
ca-certificates gnupg software-properties-common \ ca-certificates gnupg software-properties-common \