#!/usr/bin/env bash # ImnovaPanel bootstrap installer, published as https://imnovapanel.net/downloads/install.sh # # curl -fsSL https://imnovapanel.net/downloads/install.sh | bash # # Reads and verifies the signed release manifest, downloads the bundle it points to, verifies its # SHA-256 and runs the AlmaLinux 9 installer included in the bundle. Installer options (ISERVERPANEL_*) are passed # through, for example: ISERVERPANEL_INSTALL_CLAMAV=0. set -Eeuo pipefail umask 022 # Everything runs inside main() so a partially downloaded script never executes. main() { DOWNLOAD_BASE="${ISERVERPANEL_DOWNLOAD_BASE:-https://imnovapanel.net/downloads}" MANIFEST_URL="${ISERVERPANEL_UPDATE_MANIFEST:-$DOWNLOAD_BASE/version.json}" MANIFEST_SIGNATURE_URL="${ISERVERPANEL_UPDATE_MANIFEST_SIGNATURE:-$MANIFEST_URL.sig}" log(){ printf '\033[1;36m[imnovapanel]\033[0m %s\n' "$*"; } fail(){ printf '\033[1;31m[imnovapanel:error]\033[0m %s\n' "$*" >&2; exit 1; } [ "${EUID}" -eq 0 ] || fail "Run this installer as root." command -v curl >/dev/null 2>&1 || fail "curl is required." command -v sha256sum >/dev/null 2>&1 || fail "sha256sum is required." command -v openssl >/dev/null 2>&1 || { command -v dnf >/dev/null 2>&1 || fail "openssl is required, and dnf is not available to install it." dnf -y install openssl >/dev/null || fail "Could not install openssl." } if ! command -v tar >/dev/null 2>&1 || ! command -v gzip >/dev/null 2>&1; then command -v dnf >/dev/null 2>&1 || fail "tar and gzip are required, and dnf is not available to install them." log "Installing required extraction tools (tar and gzip)." dnf -y install tar gzip >/dev/null || fail "Could not install tar and gzip." fi workdir=$(mktemp -d /root/imnovapanel-install.XXXXXX) trap 'rm -rf "$workdir"' EXIT log "Reading release manifest: $MANIFEST_URL" curl -fsSL --retry 3 --connect-timeout 20 "$MANIFEST_URL" -o "$workdir/version.json" || fail "Could not download the release manifest." curl -fsSL --retry 3 --connect-timeout 20 "$MANIFEST_SIGNATURE_URL" -o "$workdir/version.json.sig" || fail "Could not download the release manifest signature." cat >"$workdir/release-public.pem" <<'PUBKEY' -----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAQPmHZ0S+bRje4IssLiaTV4+QDQcHpEzOkee+RpJwMIU= -----END PUBLIC KEY----- PUBKEY openssl pkeyutl -verify -pubin -inkey "$workdir/release-public.pem" -rawin -in "$workdir/version.json" -sigfile "$workdir/version.json.sig" >/dev/null 2>&1 \ || fail "The release manifest signature is invalid. Installation aborted." log "Release manifest signature verified (Ed25519)." json_value(){ grep -o "\"$1\"[[:space:]]*:[[:space:]]*\"[^\"]*\"" "$workdir/version.json" | head -1 | sed 's/.*:[[:space:]]*"\(.*\)"/\1/'; } version=$(json_value version) bundle_url=$(json_value bundleUrl) expected_sha=$(json_value sha256) [ -n "$version" ] && [ -n "$bundle_url" ] || fail "The release manifest is incomplete." case "$bundle_url" in https://*) ;; *) fail "The bundle URL must use HTTPS." ;; esac [[ "$expected_sha" =~ ^[0-9a-f]{64}$ ]] || fail "The release manifest has no valid SHA-256." log "Downloading ImnovaPanel $version" curl -fL --retry 3 --connect-timeout 20 --max-time 900 -sS "$bundle_url" -o "$workdir/imnovapanel.tar.gz" || fail "Could not download the bundle." actual_sha=$(sha256sum "$workdir/imnovapanel.tar.gz" | awk '{print $1}') [ "$actual_sha" = "$expected_sha" ] || fail "SHA-256 mismatch: expected $expected_sha, got $actual_sha. The download is incomplete or was altered." log "Package integrity verified (SHA-256)." mkdir -p "$workdir/src" tar -xzf "$workdir/imnovapanel.tar.gz" -C "$workdir/src" [ -f "$workdir/src/install/install-almalinux9.sh" ] || fail "The bundle does not contain the installer." export ISERVERPANEL_DOWNLOAD_BASE="$DOWNLOAD_BASE" bash "$workdir/src/install/install-almalinux9.sh"