Merge pull request 'yamlfix' (#1) from yamlfix into main
Reviewed-on: #1
This commit is contained in:
commit
6f85457ed9
@ -5,9 +5,9 @@
|
||||
# Synapse: https://git.techniverse.net/scriptos/livekit-ip-watch.git
|
||||
# Autor: Patrick Asmus
|
||||
# Web: https://www.cleveradmin.de
|
||||
# Version: 1.0
|
||||
# Version: 1.1
|
||||
# Datum: 27.10.2025
|
||||
# Modifikation: Initial
|
||||
# Modifikation: healthcheck auf HTTP mit Custom URL umgestellt.
|
||||
#####################################################
|
||||
|
||||
set -euo pipefail
|
||||
@ -35,9 +35,8 @@ ENABLE_IPV6=false
|
||||
# Wartezeit nach Neustart (Sekunden), dann Healthcheck
|
||||
WAIT_AFTER_RESTART=20
|
||||
|
||||
# Healthcheck-Konfiguration: nur TCP
|
||||
TCP_HOST="127.0.0.1"
|
||||
TCP_PORT="7881"
|
||||
# Healthcheck-Konfiguration: HTTP
|
||||
HEALTHCHECK_DOMAIN="rtc.matrix.techniverse.net"
|
||||
HEALTHCHECK_TIMEOUT=3
|
||||
|
||||
# ntfy (optional)
|
||||
@ -199,16 +198,9 @@ restart_service() {
|
||||
fi
|
||||
}
|
||||
|
||||
healthcheck_tcp() {
|
||||
if (exec 3<>/dev/tcp/"$TCP_HOST"/"$TCP_PORT") 2>/dev/null; then
|
||||
exec 3<&-
|
||||
exec 3>&-
|
||||
return 0
|
||||
elif command -v nc >/dev/null 2>&1; then
|
||||
nc -z -w "$HEALTHCHECK_TIMEOUT" "$TCP_HOST" "$TCP_PORT"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
healthcheck_http() {
|
||||
local url="https://${HEALTHCHECK_DOMAIN}/livekit/sfu/"
|
||||
curl -fsS --max-time "$HEALTHCHECK_TIMEOUT" "$url" >/dev/null
|
||||
}
|
||||
|
||||
main() {
|
||||
@ -263,7 +255,7 @@ main() {
|
||||
info "Warte $WAIT_AFTER_RESTART Sekunden..."
|
||||
sleep "$WAIT_AFTER_RESTART"
|
||||
|
||||
if healthcheck_tcp; then
|
||||
if healthcheck_http; then
|
||||
info "Healthcheck OK."
|
||||
echo "$current_ip" > "$state_file"
|
||||
notify "info" "IP geändert auf $current_ip, Dienst gesund."
|
||||
@ -280,7 +272,7 @@ main() {
|
||||
info "Warte $WAIT_AFTER_RESTART Sekunden (Rollback)..."
|
||||
sleep "$WAIT_AFTER_RESTART"
|
||||
|
||||
if healthcheck_tcp; then
|
||||
if healthcheck_http; 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user