chore(2.0): Deploy als sudo-freier systemd-USER-Dienst (Home, :9001)
mission-control-2.service auf %h/mission-control-v2 umgestellt (kein /opt/ sudo); deploy.sh = Erstinstall+Update als User-Dienst (clone/pull, venv, systemctl --user, linger). Nordstern: kein Passwort/SSH-Gefummel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+20
-25
@@ -1,38 +1,33 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Deploy AUF DER BOX: git pull (Source) → venv-Sync → rsync nach /opt → Restart.
|
# Deploy AUF DER BOX als systemd-USER-Dienst — KEIN sudo, KEIN /opt, KEIN Passwort.
|
||||||
# Läuft als User hitonabi. KEIN eingebettetes Passwort — der Restart nutzt die
|
# Erstinstallation + Updates in einem. Läuft als User hitonabi.
|
||||||
# NOPASSWD-sudoers-Whitelist (nur `systemctl restart mission-control-2`).
|
|
||||||
#
|
#
|
||||||
# Voraussetzungen (einmalig):
|
# Erstinstallation (einmalig):
|
||||||
# - Gitea-Repo angelegt + hier geklont nach ~/mission-control-2
|
# git clone https://git.tobisniceshomelab.ddnsfree.com/Hitonabi/mission-control-v2 ~/mission-control-v2
|
||||||
# - sudoers: hitonabi ALL=(root) NOPASSWD: /usr/bin/systemctl restart mission-control-2
|
# bash ~/mission-control-v2/deploy/deploy.sh
|
||||||
# - systemd-Unit installiert (siehe mission-control-2.service)
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SRC="${MC2_SRC:-$HOME/mission-control-2}"
|
SRC="${MC2_SRC:-$HOME/mission-control-v2}"
|
||||||
PROD="${MC2_PROD:-/opt/mission-control-2}"
|
|
||||||
|
|
||||||
cd "$SRC"
|
cd "$SRC"
|
||||||
git fetch -q origin
|
git fetch -q origin && git reset -q --hard origin/main
|
||||||
git reset -q --hard origin/main
|
|
||||||
|
|
||||||
# Backend-venv auf der Box sicherstellen + Abhängigkeiten aktuell halten.
|
# venv + Abhängigkeiten
|
||||||
if [ ! -d "$SRC/backend/.venv" ]; then
|
if [ ! -d "$SRC/backend/.venv" ]; then
|
||||||
python3 -m venv "$SRC/backend/.venv"
|
python3 -m venv "$SRC/backend/.venv"
|
||||||
fi
|
fi
|
||||||
|
"$SRC/backend/.venv/bin/python" -m pip install -q --upgrade pip
|
||||||
"$SRC/backend/.venv/bin/python" -m pip install -q -r "$SRC/backend/requirements.txt"
|
"$SRC/backend/.venv/bin/python" -m pip install -q -r "$SRC/backend/requirements.txt"
|
||||||
|
|
||||||
# Nach /opt spiegeln (Frontend-dist kommt aus dem Repo mit).
|
# systemd-USER-Unit installieren/aktualisieren
|
||||||
sudo rsync -a --delete \
|
mkdir -p "$HOME/.config/systemd/user"
|
||||||
--exclude '.git' --exclude 'node_modules' \
|
cp "$SRC/deploy/mission-control-2.service" "$HOME/.config/systemd/user/mission-control-2.service"
|
||||||
"$SRC/" "$PROD/"
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable mission-control-2 >/dev/null 2>&1 || true
|
||||||
|
loginctl enable-linger "$USER" >/dev/null 2>&1 || true
|
||||||
|
systemctl --user restart mission-control-2
|
||||||
|
|
||||||
# venv separat syncen (rsync oben schließt sie nicht aus, aber Pfade im venv sind
|
sleep 2
|
||||||
# absolut — daher venv direkt im PROD neu aufbauen, robust):
|
echo "--- Health ---"
|
||||||
if [ ! -d "$PROD/backend/.venv" ]; then
|
curl -sf http://127.0.0.1:9001/api/health && echo
|
||||||
sudo python3 -m venv "$PROD/backend/.venv"
|
echo "OK — Mission Control 2.0 läuft auf :9001 (User-Dienst, sudo-frei)."
|
||||||
fi
|
|
||||||
sudo "$PROD/backend/.venv/bin/python" -m pip install -q -r "$PROD/backend/requirements.txt"
|
|
||||||
|
|
||||||
sudo systemctl restart mission-control-2
|
|
||||||
echo "OK — Mission Control 2.0 neu gestartet (:9001)."
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# systemd-Unit für Mission Control 2.0 (läuft PARALLEL zu v1 auf eigenem Port 9001).
|
# systemd-USER-Unit für Mission Control 2.0 (PARALLEL zu v1, Port 9001).
|
||||||
# Ablage: ~/.config/systemd/user/ (user-Dienst) ODER /etc/systemd/system/ (system, User=hitonabi).
|
# Läuft sudo-frei aus dem Home-Verzeichnis (Nordstern: kein Passwort/sudo).
|
||||||
# Aktivieren: systemctl --user enable --now mission-control-2 (bzw. system-weit)
|
# Ablage: ~/.config/systemd/user/mission-control-2.service ; dann:
|
||||||
|
# systemctl --user daemon-reload
|
||||||
|
# systemctl --user enable --now mission-control-2
|
||||||
|
# loginctl enable-linger hitonabi # läuft auch ohne aktive Session
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Mission Control 2.0 (Cockpit)
|
Description=Mission Control 2.0 (Cockpit)
|
||||||
@@ -9,8 +12,8 @@ Wants=network-online.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/mission-control-2/backend
|
WorkingDirectory=%h/mission-control-v2/backend
|
||||||
ExecStart=/opt/mission-control-2/backend/.venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port 9001
|
ExecStart=%h/mission-control-v2/backend/.venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port 9001
|
||||||
Environment=MC_PORT=9001
|
Environment=MC_PORT=9001
|
||||||
Environment=MC_LLAMA_SWAP_URL=http://127.0.0.1:8080
|
Environment=MC_LLAMA_SWAP_URL=http://127.0.0.1:8080
|
||||||
Environment=MC_CONFIG_PATH=/etc/llama-swap/config.yaml
|
Environment=MC_CONFIG_PATH=/etc/llama-swap/config.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user