From 4ab87dadc8c4142e12a332cd7efe1bdac2a00872 Mon Sep 17 00:00:00 2001 From: Patrick Asmus Date: Sun, 16 Jul 2023 12:20:52 +0000 Subject: [PATCH] Logging hinzugefuegt --- fritzbox-restart.v1.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fritzbox-restart.v1.sh b/fritzbox-restart.v1.sh index 2887412..06dd2dd 100644 --- a/fritzbox-restart.v1.sh +++ b/fritzbox-restart.v1.sh @@ -7,22 +7,35 @@ # Aufruf 2 bash ./fritzbox-reboot.v1.sh # Autor: Patrick Asmus # Web: https://www.media-techport.de -# Git-Reposit.: - -# Version: 1.0.1 +# Git-Reposit.: https://git.media-techport.de/scriptos/fritzbox-restart-script +# Version: 1.0.2 # Datum: 16.07.2023 -# Modifikation: Header angepasst +# Modifikation: Logging hinzugefuegt ##################################################### # Variablen IPS="192.168.178.1" FRITZ_USER="FritzBenutzer" FRITZ_PW="FritzPasswort" +LOG_FILE="/var/log/script-logs/fritzbox-restart.log" + +# Funktion zum Schreiben von Logs +log() { + timestamp=$(date +"%Y-%m-%d %T") + echo "[${timestamp}] $1" >> "$LOG_FILE" +} # Ausführung location="/upnp/control/deviceconfig" uri="urn:dslforum-org:service:DeviceConfig:1" action='Reboot' +log "Script gestartet." + for IP in ${IPS}; do - curl -k -m 5 --anyauth -u "$FRITZ_USER:$FRITZ_PW" http://$IP:49000$location -H 'Content-Type: text/xml; charset="utf-8"' -H "SoapAction:$uri#$action" -d "" -s > /dev/null + log "Starte Neustart für Fritzbox mit IP: $IP" + curl -k -m 5 --anyauth -u "$FRITZ_USER:$FRITZ_PW" "http://$IP:49000$location" -H 'Content-Type: text/xml; charset="utf-8"' -H "SoapAction:$uri#$action" -d "" -s > /dev/null + log "Neustart für Fritzbox mit IP: $IP abgeschlossen." done + +log "Script beendet."