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>
This commit is contained in:
+35
-13
@@ -1,25 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Einmalige Einrichtung auf einem Linux-Mint-Rechner:
|
||||
# - benötigte System-Pakete
|
||||
# - virtuelle Python-Umgebung + Abhängigkeiten
|
||||
# - Eintrag im Startmenü
|
||||
# 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
|
||||
# Aufruf: ./install.sh (kann gefahrlos wiederholt werden)
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$(readlink -f "$0")")"
|
||||
APPDIR="$(pwd)"
|
||||
|
||||
echo "==> System-Pakete (fragt nach dem Passwort)…"
|
||||
sudo apt update
|
||||
sudo apt install -y python3-tk python3-venv python3-pip git
|
||||
# ── 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")
|
||||
|
||||
echo
|
||||
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/pip install --upgrade pip
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
.venv/bin/python -m pip install --upgrade pip
|
||||
.venv/bin/python -m pip install -r requirements.txt
|
||||
|
||||
echo
|
||||
# ── 3. Startmenü-Eintrag (ohne sudo, nur für dieses Konto) ──────────────────
|
||||
echo "==> Startmenü-Eintrag …"
|
||||
DESKTOP_DIR="$HOME/.local/share/applications"
|
||||
mkdir -p "$DESKTOP_DIR"
|
||||
@@ -40,5 +62,5 @@ 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, damit sie auftaucht)."
|
||||
echo "(ggf. einmal ab- und wieder anmelden)."
|
||||
echo "Direkt testen: ./run.sh"
|
||||
|
||||
Reference in New Issue
Block a user