diff --git a/livekit-ip-watch.v1.sh b/livekit-ip-watch.v1.sh index cf2f1fd..c1917f8 100644 --- a/livekit-ip-watch.v1.sh +++ b/livekit-ip-watch.v1.sh @@ -35,11 +35,9 @@ ENABLE_IPV6=false # Wartezeit nach Neustart (Sekunden), dann Healthcheck WAIT_AFTER_RESTART=20 -# Healthcheck-Konfiguration: "http" oder "tcp" -HEALTHCHECK_MODE="http" -HEALTHCHECK_URL="https://rtc.matrix.techniverse.net" +# Healthcheck-Konfiguration: nur TCP TCP_HOST="127.0.0.1" -TCP_PORT="7880" +TCP_PORT="7881" HEALTHCHECK_TIMEOUT=3 # ntfy (optional) @@ -201,10 +199,6 @@ restart_service() { fi } -healthcheck_http() { - curl -fsS --max-time "$HEALTHCHECK_TIMEOUT" "$HEALTHCHECK_URL" >/dev/null -} - healthcheck_tcp() { if (exec 3<>/dev/tcp/"$TCP_HOST"/"$TCP_PORT") 2>/dev/null; then exec 3<&- @@ -217,14 +211,6 @@ healthcheck_tcp() { fi } -do_healthcheck() { - if [[ "$HEALTHCHECK_MODE" == "http" ]]; then - healthcheck_http - else - healthcheck_tcp - fi -} - main() { acquire_lock @@ -236,7 +222,6 @@ main() { [[ -n "$CONTAINER_NAME" ]] || die "CONTAINER_NAME ist leer." fi - # Aktuelle IP ermitteln local current_ip cidr state_file if [[ "$ENABLE_IPV6" == true ]]; then current_ip="$(get_ipv6)" @@ -264,7 +249,6 @@ main() { backup="$(backup_config)" info "Backup erstellt: $backup" - # YAML aktualisieren if have_yq; then info "Aktualisiere YAML mit yq → .rtc.ips.includes = [ \"$cidr\" ]" update_yaml_with_yq "$cidr" @@ -273,22 +257,19 @@ main() { update_yaml_fallback "$cidr" fi - # Dienst neu starten info "Restart des Dienstes..." restart_service info "Warte $WAIT_AFTER_RESTART Sekunden..." sleep "$WAIT_AFTER_RESTART" - # Healthcheck - if do_healthcheck; then + if healthcheck_tcp; then info "Healthcheck OK." echo "$current_ip" > "$state_file" notify "info" "IP geändert auf $current_ip, Dienst gesund." exit 0 fi - # Rollback bei Fehler warn "Healthcheck fehlgeschlagen – führe Rollback durch." cp -a "$backup" "$CONFIG_FILE" info "Rollback-Konfiguration wiederhergestellt: $backup" @@ -299,7 +280,7 @@ main() { info "Warte $WAIT_AFTER_RESTART Sekunden (Rollback)..." sleep "$WAIT_AFTER_RESTART" - if do_healthcheck; then + if healthcheck_tcp; then warn "Rollback erfolgreich. System läuft wieder mit alter Konfiguration." notify "warn" "Rollback erfolgreich. Bitte prüfen. Alte IP bleibt ${last_ip:-unbekannt}." exit 10