#!/usr/bin/env bash # PPH Package Repository - One-Shot-Installer # Debian, Ubuntu, RHEL / Rocky / Alma / CentOS (inkl. 7) / vz7 # # curl -fsSL https://technik.prepaid-hoster.de/pph-utils/install.txt | sudo bash # curl -fsSL https://technik.prepaid-hoster.de/pph-utils/install.txt | sudo bash -s -- pph-mon pph-sw # # Optional: PPH_REPO_URL=... ueberschreibt die Basis-URL. set -euo pipefail BASE_URL="${PPH_REPO_URL:-https://technik.prepaid-hoster.de/pph-utils}" info() { printf '[**] %s\n' "$*"; } die() { printf '[XX] %s\n' "$*" >&2; exit 1; } fetch() { if command -v curl >/dev/null 2>&1; then curl -fsSL "$1" -o "$2" elif command -v wget >/dev/null 2>&1; then wget -q -O "$2" "$1" else die "weder curl noch wget gefunden" fi } setup_apt() { local tmp tmp="$(mktemp)" info "Installiere Signing-Key nach /usr/share/keyrings/pph-repo.gpg" fetch "$BASE_URL/pph-repo.gpg" "$tmp" install -m 644 "$tmp" /usr/share/keyrings/pph-repo.gpg rm -f "$tmp" info "Schreibe /etc/apt/sources.list.d/pph.list" echo "deb [signed-by=/usr/share/keyrings/pph-repo.gpg] $BASE_URL/apt pph main" \ > /etc/apt/sources.list.d/pph.list info "apt-get update" if ! apt-get update -qq; then # defekte fremde Quellen (z.B. EOL-Mirror) sollen die Einrichtung nicht blockieren info "apt-get update meldet Fehler in anderen Quellen - aktualisiere nur das PPH-Repo" if grep -qrs 'bullseye/updates' /etc/apt/sources.list /etc/apt/sources.list.d/; then info "Hinweis: Bei Debian 11 heisst die Suite 'bullseye-security', nicht 'bullseye/updates'. Fix:" info " sed -i 's#bullseye/updates#bullseye-security#' /etc/apt/sources.list && apt-get update" info "Ohne Security-Paketlisten koennen Pakete mit Abhaengigkeiten (z.B. pph-hw-server) scheitern." fi apt-get update -qq -o Dir::Etc::sourcelist=sources.list.d/pph.list \ -o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0 fi if [ "$#" -gt 0 ]; then info "Installiere: $*" DEBIAN_FRONTEND=noninteractive apt-get install -y "$@" fi } setup_rpm() { local pm=yum command -v dnf >/dev/null 2>&1 && pm=dnf info "Schreibe /etc/yum.repos.d/pph.repo" cat > /etc/yum.repos.d/pph.repo </dev/null 2>&1; then setup_apt "$@" elif command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then setup_rpm "$@" else die "Kein unterstuetzter Paketmanager gefunden (apt-get, dnf, yum)" fi info "PPH-Repository ist eingerichtet." if [ "$#" -eq 0 ]; then if command -v apt-get >/dev/null 2>&1; then info "Installieren mit: apt-get install pph-mon pph-sw" else info "Installieren mit: yum install pph-mon pph-sw" fi fi } main "$@"