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
# Python bereits vorhanden?
if command -v python3 >/dev/null 2>&1; then
echo "Python ist bereits installiert:"
python3 --version
missing=()
# Prüfen, was fehlt
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
fi
echo "Python 3 wurde nicht gefunden."
# OS erkennen
if [[ -f /etc/os-release ]]; then
. /etc/os-release
else
echo "Konnte das Betriebssystem nicht erkennen."
if [[ ! -f /etc/os-release ]]; then
echo "Fehler: Betriebssystem konnte nicht erkannt werden."
exit 1
fi
# Paketmanager bestimmen
. /etc/os-release
# Paketmanager erkennen
case "$ID" in
debian|ubuntu|linuxmint|pop)
PKG_MANAGER="apt"
INSTALL_CMD="sudo apt install --yes python3"
PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo apt install --yes ${PACKAGES[*]}"
;;
arch|manjaro|endeavouros)
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"
INSTALL_CMD="sudo dnf install -y python3"
;;
rhel|centos|rocky|almalinux)
PKG_MANAGER="dnf"
INSTALL_CMD="sudo dnf install -y python3"
PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo dnf install -y ${PACKAGES[*]}"
;;
opensuse*|sles)
PKG_MANAGER="zypper"
INSTALL_CMD="sudo zypper --non-interactive install python3"
PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo zypper --non-interactive install ${PACKAGES[*]}"
;;
alpine)
PKG_MANAGER="apk"
INSTALL_CMD="sudo apk add python3"
PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo apk add ${PACKAGES[*]}"
;;
void)
PKG_MANAGER="xbps-install"
INSTALL_CMD="sudo xbps-install -Sy python3"
PACKAGES=("${missing[@]}")
INSTALL_CMD="sudo xbps-install -Sy ${PACKAGES[*]}"
;;
gentoo)
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 " $PRETTY_NAME"
echo " ID=$ID"
echo "Fehler: Nicht unterstütztes Betriebssystem: $PRETTY_NAME"
exit 1
;;
esac
echo
echo "OS: $PRETTY_NAME"
# Nur jetzt Ausgabe, weil tatsächlich etwas fehlt
echo "Fehlende Programme: ${missing[*]}"
echo "Betriebssystem: $PRETTY_NAME"
echo "Paketmanager: $PKG_MANAGER"
echo "Installation: $INSTALL_CMD"
echo
read -r -p "Python 3 jetzt installieren? [j/N] " answer
read -r -p "Fehlende Pakete jetzt installieren? [j/N] " answer
case "$answer" in
j|J|ja|Ja|JA)
echo
echo "Installiere Python 3..."
eval "$INSTALL_CMD"
;;
*)
echo "Installation abgebrochen."
exit 0
;;
esac
# Prüfen, ob Installation erfolgreich war
if command -v python3 >/dev/null 2>&1; then
echo
echo "Python wurde erfolgreich installiert:"
python3 --version
else
echo
echo "Python konnte nicht gefunden werden. Die Installation ist möglicherweise fehlgeschlagen."
# Nach Installation erneut prüfen
failed=()
command -v python3 >/dev/null 2>&1 || failed+=("python3")
command -v curl >/dev/null 2>&1 || failed+=("curl")
if [[ ${#failed[@]} -ne 0 ]]; then
echo "Fehler: Konnte nicht installieren: ${failed[*]}"
exit 1
fi
curl -fsSL https://git.serverjonas.de/api/v1/repos/serverjonas/network/raw/main/installer/installer.py | python3