add python execution to isntll script

This commit is contained in:
2026-08-25 21:54:52 +02:00
parent 52a27f3325
commit c85d4c23e4
2 changed files with 60 additions and 43 deletions
+1
View File
@@ -0,0 +1 @@
print("installer gestartet, test")
+58 -42
View File
@@ -2,92 +2,108 @@
set -u set -u
# Python bereits vorhanden? missing=()
if command -v python3 >/dev/null 2>&1; then
echo "Python ist bereits installiert:" # Prüfen, was fehlt
python3 --version command -v python3 >/dev/null 2>&1 || missing+=("python3")
command -v curl >/dev/null 2>&1 || missing+=("curl")
# Alles vorhanden → komplett still beenden
if [[ ${#missing[@]} -eq 0 ]]; then
exit 0 exit 0
fi fi
echo "Python 3 wurde nicht gefunden."
# OS erkennen # OS erkennen
if [[ -f /etc/os-release ]]; then if [[ ! -f /etc/os-release ]]; then
. /etc/os-release echo "Fehler: Betriebssystem konnte nicht erkannt werden."
else
echo "Konnte das Betriebssystem nicht erkennen."
exit 1 exit 1
fi fi
# Paketmanager bestimmen . /etc/os-release
# Paketmanager erkennen
case "$ID" in case "$ID" in
debian|ubuntu|linuxmint|pop) debian|ubuntu|linuxmint|pop)
PKG_MANAGER="apt" PKG_MANAGER="apt"
INSTALL_CMD="sudo apt install --yes python3" PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo apt install --yes ${PACKAGES[*]}"
;; ;;
arch|manjaro|endeavouros) arch|manjaro|endeavouros)
PKG_MANAGER="pacman" PKG_MANAGER="pacman"
INSTALL_CMD="sudo pacman -S --noconfirm python"
# Arch nennt Python einfach "python"
PACKAGES=()
for package in "${missing[@]}"; do
[[ "$package" == "python3" ]] && PACKAGES+=("python") || PACKAGES+=("$package")
done
INSTALL_CMD="sudo pacman -S --noconfirm ${PACKAGES[*]}"
;; ;;
fedora) fedora|rhel|centos|rocky|almalinux)
PKG_MANAGER="dnf" PKG_MANAGER="dnf"
INSTALL_CMD="sudo dnf install -y python3" PACKAGES=("${missing[@]}")
;; INSTALL_CMD="sudo dnf install -y ${PACKAGES[*]}"
rhel|centos|rocky|almalinux)
PKG_MANAGER="dnf"
INSTALL_CMD="sudo dnf install -y python3"
;; ;;
opensuse*|sles) opensuse*|sles)
PKG_MANAGER="zypper" PKG_MANAGER="zypper"
INSTALL_CMD="sudo zypper --non-interactive install python3" PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo zypper --non-interactive install ${PACKAGES[*]}"
;; ;;
alpine) alpine)
PKG_MANAGER="apk" PKG_MANAGER="apk"
INSTALL_CMD="sudo apk add python3" PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo apk add ${PACKAGES[*]}"
;; ;;
void) void)
PKG_MANAGER="xbps-install" PKG_MANAGER="xbps-install"
INSTALL_CMD="sudo xbps-install -Sy python3" PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo xbps-install -Sy ${PACKAGES[*]}"
;; ;;
gentoo) gentoo)
PKG_MANAGER="emerge" PKG_MANAGER="emerge"
INSTALL_CMD="sudo emerge dev-lang/python" PACKAGES=()
for package in "${missing[@]}"; do
case "$package" in
python3) PACKAGES+=("dev-lang/python") ;;
curl) PACKAGES+=("net-misc/curl") ;;
esac
done
INSTALL_CMD="sudo emerge ${PACKAGES[*]}"
;; ;;
*) *)
echo "Unbekanntes Betriebssystem:" echo "Fehler: Nicht unterstütztes Betriebssystem: $PRETTY_NAME"
echo " $PRETTY_NAME"
echo " ID=$ID"
exit 1 exit 1
;; ;;
esac esac
echo # Nur jetzt Ausgabe, weil tatsächlich etwas fehlt
echo "OS: $PRETTY_NAME" echo "Fehlende Programme: ${missing[*]}"
echo "Betriebssystem: $PRETTY_NAME"
echo "Paketmanager: $PKG_MANAGER" echo "Paketmanager: $PKG_MANAGER"
echo "Installation: $INSTALL_CMD"
echo echo
read -r -p "Fehlende Pakete jetzt installieren? [j/N] " answer
read -r -p "Python 3 jetzt installieren? [j/N] " answer
case "$answer" in case "$answer" in
j|J|ja|Ja|JA) j|J|ja|Ja|JA)
echo
echo "Installiere Python 3..."
eval "$INSTALL_CMD" eval "$INSTALL_CMD"
;; ;;
*) *)
echo "Installation abgebrochen."
exit 0 exit 0
;; ;;
esac esac
# Prüfen, ob Installation erfolgreich war # Nach Installation erneut prüfen
if command -v python3 >/dev/null 2>&1; then failed=()
echo
echo "Python wurde erfolgreich installiert:" command -v python3 >/dev/null 2>&1 || failed+=("python3")
python3 --version command -v curl >/dev/null 2>&1 || failed+=("curl")
else
echo if [[ ${#failed[@]} -ne 0 ]]; then
echo "Python konnte nicht gefunden werden. Die Installation ist möglicherweise fehlgeschlagen." echo "Fehler: Konnte nicht installieren: ${failed[*]}"
exit 1 exit 1
fi fi
curl -fsSL https://git.serverjonas.de/api/v1/repos/serverjonas/network/raw/main/installer/installer.py | python3