Files
drk-blutspende-orte/install.sh
T
Paddy 5b85596a46 Split install for non-admin users
The target laptop account has no sudo. install.sh now runs without root once the
system packages exist; if they're missing and the account can't sudo it prints
the exact command and stops. New install-system.sh holds the one-time
"sudo apt install python3-tk python3-venv git" for an admin account.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 22:30:03 +02:00

67 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Einrichtung der App läuft OHNE Administrator-Rechte, solange die
# System-Pakete (python3-tk, python3-venv, git) schon installiert sind.
# Falls nicht: einmalig ./install-system.sh von einem Admin-Konto ausführen.
#
# Aufruf: ./install.sh (kann gefahrlos wiederholt werden)
set -euo pipefail
cd "$(dirname "$(readlink -f "$0")")"
APPDIR="$(pwd)"
# ── 1. System-Voraussetzungen prüfen ────────────────────────────────────────
missing=()
python3 -c 'import tkinter' 2>/dev/null || missing+=("python3-tk")
python3 -c 'import ensurepip' 2>/dev/null || missing+=("python3-venv")
command -v git >/dev/null 2>/dev/null || missing+=("git")
if [ "${#missing[@]}" -gt 0 ]; then
if id -nG | tr ' ' '\n' | grep -qxE 'sudo|wheel|admin'; then
echo "==> Fehlende System-Pakete werden installiert: ${missing[*]}"
sudo apt update
sudo apt install -y "${missing[@]}"
else
cat >&2 <<EOF
Es fehlen System-Pakete, und dieses Konto hat keine Administrator-Rechte:
${missing[*]}
Bitte einmal von einem Admin-Konto (Patrick) ausführen:
cd "$APPDIR" && ./install-system.sh
Danach dieses Skript hier erneut starten: ./install.sh
EOF
exit 1
fi
fi
# ── 2. Virtuelle Umgebung + Abhängigkeiten (ohne sudo) ──────────────────────
echo "==> Virtuelle Umgebung unter .venv …"
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install -r requirements.txt
# ── 3. Startmenü-Eintrag (ohne sudo, nur für dieses Konto) ──────────────────
echo "==> Startmenü-Eintrag …"
DESKTOP_DIR="$HOME/.local/share/applications"
mkdir -p "$DESKTOP_DIR"
cat > "$DESKTOP_DIR/drk-blutspende-orte.desktop" <<EOF
[Desktop Entry]
Type=Application
Name=DRK Blutspende Arbeitsorte
Comment=Einsatzorte protokollieren und auf der Karte anzeigen
Exec=$APPDIR/run.sh
Icon=$APPDIR/icon.png
Terminal=false
Categories=Utility;
StartupWMClass=DRK Blutspende Arbeitsorte
EOF
chmod +x "$APPDIR/run.sh"
update-desktop-database "$DESKTOP_DIR" 2>/dev/null || true
echo
echo "Fertig."
echo "Die App ist jetzt im Menü als \"DRK Blutspende Arbeitsorte\" zu finden"
echo "(ggf. einmal ab- und wieder anmelden)."
echo "Direkt testen: ./run.sh"