diff --git a/deploy-server.sh b/deploy-server.sh index 7e1387d..532ebe4 100755 --- a/deploy-server.sh +++ b/deploy-server.sh @@ -109,37 +109,40 @@ mkdir -p "$REMOTE_DIR"/{logs,config} sudo mkdir -p /etc/yourpart sudo mkdir -p /var/log/yourpart -# 5. Kopiere Dateien +# 5. Stoppe Service falls läuft +log_info "Stoppe Service falls läuft..." +if sudo systemctl is-active --quiet "$SERVICE_NAME"; then + log_info "Stoppe laufenden Service..." + sudo systemctl stop "$SERVICE_NAME" + sleep 2 +fi + +# 6. Kopiere Dateien log_info "Kopiere Dateien..." sudo cp "$BUILD_DIR/yourpart-daemon" /usr/local/bin/ sudo cp daemon.conf /etc/yourpart/ sudo cp yourpart-daemon.service /etc/systemd/system/ -# 6. Setze Berechtigungen +# 7. Setze Berechtigungen log_info "Setze Berechtigungen..." sudo chmod +x /usr/local/bin/yourpart-daemon sudo chown -R "$DAEMON_USER:$DAEMON_USER" "$REMOTE_DIR" sudo chown -R "$DAEMON_USER:$DAEMON_USER" /var/log/yourpart sudo chmod 600 /etc/yourpart/daemon.conf -# 7. Lade systemd neu +# 8. Lade systemd neu log_info "Lade systemd Konfiguration neu..." sudo systemctl daemon-reload -# 8. Aktiviere Service +# 9. Aktiviere Service log_info "Aktiviere Service..." sudo systemctl enable "$SERVICE_NAME" -# 9. Starte Service +# 10. Starte Service log_info "Starte Service..." -if sudo systemctl is-active --quiet "$SERVICE_NAME"; then - log_info "Service läuft bereits, starte neu..." - sudo systemctl restart "$SERVICE_NAME" -else - sudo systemctl start "$SERVICE_NAME" -fi +sudo systemctl start "$SERVICE_NAME" -# 10. Prüfe Status +# 11. Prüfe Status log_info "Prüfe Service-Status..." sleep 2 if sudo systemctl is-active --quiet "$SERVICE_NAME"; then