diff --git a/install_newt.sh b/install_newt.sh index 1f1f489..ae62737 100644 --- a/install_newt.sh +++ b/install_newt.sh @@ -68,13 +68,21 @@ cleanup_old_versions() { setup_systemd_service() { svc="/etc/systemd/system/${SERVICE_NAME}.service" - if [ -f "$svc" ]; then + + if [ -f "$svc" ] && [ $FORCE -eq 0 ]; then info "systemd-Dienst ${SERVICE_NAME} existiert bereits. Überspringe Neuanlage." sudo systemctl restart "$SERVICE_NAME" info "Dienst ${SERVICE_NAME} neu gestartet." return fi + if [ -f "$svc" ] && [ $FORCE -eq 1 ]; then + info "systemd-Dienst ${SERVICE_NAME} wird wegen --force neu erstellt." + # Dienst noch NICHT stoppen hier! + sudo rm -f "$svc" + fi + + # Eingabe erst hier, bevor Dienst gestoppt wird read -rp "🆔 Bitte gib die Pangolin-ID ein: " PANGOLIN_ID read -rp "🔑 Bitte gib das Secret ein: " PANGOLIN_SECRET read -rp "🌐 Bitte gib den Endpoint (z. B. https://pangolin.domain.de) ein: " PANGOLIN_ENDPOINT @@ -93,6 +101,11 @@ RestartSec=5 WantedBy=multi-user.target EOF + # Dienst jetzt stoppen und neu starten (nur wenn force) + if [ $FORCE -eq 1 ]; then + sudo systemctl stop "$SERVICE_NAME" || true + fi + sudo systemctl daemon-reexec sudo systemctl daemon-reload sudo systemctl enable "$SERVICE_NAME" @@ -111,10 +124,6 @@ main() { if [ -f "${INSTALL_DIR}/newt_${version}" ] && [ $FORCE -eq 0 ]; then info "✅ Version ${version} ist bereits installiert. Kein Update nötig." else - if [ $FORCE -eq 1 ]; then - info "--force erkannt: Erzwinge Neuinstallation." - sudo systemctl stop "$SERVICE_NAME" || true - fi download_newt "$version" fi