Logging hinzugefuegt
This commit is contained in:
parent
a56e16b45f
commit
4ab87dadc8
@ -7,22 +7,35 @@
|
|||||||
# Aufruf 2 bash ./fritzbox-reboot.v1.sh
|
# Aufruf 2 bash ./fritzbox-reboot.v1.sh
|
||||||
# Autor: Patrick Asmus
|
# Autor: Patrick Asmus
|
||||||
# Web: https://www.media-techport.de
|
# Web: https://www.media-techport.de
|
||||||
# Git-Reposit.: -
|
# Git-Reposit.: https://git.media-techport.de/scriptos/fritzbox-restart-script
|
||||||
# Version: 1.0.1
|
# Version: 1.0.2
|
||||||
# Datum: 16.07.2023
|
# Datum: 16.07.2023
|
||||||
# Modifikation: Header angepasst
|
# Modifikation: Logging hinzugefuegt
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
# Variablen
|
# Variablen
|
||||||
IPS="192.168.178.1"
|
IPS="192.168.178.1"
|
||||||
FRITZ_USER="FritzBenutzer"
|
FRITZ_USER="FritzBenutzer"
|
||||||
FRITZ_PW="FritzPasswort"
|
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
|
# Ausführung
|
||||||
location="/upnp/control/deviceconfig"
|
location="/upnp/control/deviceconfig"
|
||||||
uri="urn:dslforum-org:service:DeviceConfig:1"
|
uri="urn:dslforum-org:service:DeviceConfig:1"
|
||||||
action='Reboot'
|
action='Reboot'
|
||||||
|
|
||||||
|
log "Script gestartet."
|
||||||
|
|
||||||
for IP in ${IPS}; do
|
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 "<?xml version='1.0' encoding='utf-8'?><s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><u:$action xmlns:u='$uri'></u:$action></s:Body></s:Envelope>" -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 "<?xml version='1.0' encoding='utf-8'?><s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><u:$action xmlns:u='$uri'></u:$action></s:Body></s:Envelope>" -s > /dev/null
|
||||||
|
log "Neustart für Fritzbox mit IP: $IP abgeschlossen."
|
||||||
done
|
done
|
||||||
|
|
||||||
|
log "Script beendet."
|
||||||
|
Loading…
Reference in New Issue
Block a user