Initial commit

pull/3/head
Nico Hartung 2017-12-28 13:48:06 +01:00
commit 175d0ad522
5 changed files with 81 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store

38
README.md Executable file
View File

@ -0,0 +1,38 @@
# FRITZ!Box Neustart Skript - jede Nacht, einmal die Woche, wie ihr wollt
#### Quick 'n Dirty Scripting | nicht schön, aber selten
![avm-fritzbox_pressekit.png](avm-fritzbox_pressekit.png?raw=true "avm-fritzbox_pressekit.png")
Bei diesem Skript handelt es sich um ein klassisches Linux Bash-Skript, welches ich verwende um jeden Freitag, um 4:50, meine 3 AVM FRITZ! Geräte neuzustarten - eine FRITZ!Box und zwei FRITZ!Repeater.
Folgende Variablen müssen angepasst werden:
* `IPS` - IP-Adressen der AVM FRITZ! Geräte, können mehrere sein
* `FRITZUSER` - Username der FRITZ! Weboberfläche, kann leer gelassen werden, wenn man nur ein Passwort eingeben muss
* `FRITZPW` - Passwort der FRITZ! Weboberfläche, muss bei allen FRITZ! Geräten gleich sein
Viel Spaß!
#### Beispiel
##### Crontab
[Wiki-Artikel](https://wiki.ubuntuusers.de/Cron/) zur Crontab auf ubuntuusers.de
`vi /etc/crontab`
```
# FRITZ! Geräte neustarten
50 4 * * 5 root /root/Scripts/cron_fritzbox-reboot.sh
```
##### Terminal / Bash
Natürlich kann man das Skript auch einfach manuell über die Bash / den Terminal jederzeit auführen.
Beispiel: `./cron_fritzbox-reboot.sh`
#### Inspiration & Dank
* [Dragonfly](https://homematic-forum.de/forum/viewtopic.php?t=27994)

BIN
avm-fritzbox_pressekit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

39
cron_fritzbox-reboot.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
#######################################################
### Autor: Nico Hartung <nicohartung1@googlemail.com> #
#######################################################
# Skript sollte ab FritzOS 6.0 (2013) funktioneren - also auch für die 6.8x und 6.9x
# Dieses Bash-Skript nutzt das Protokoll TR-064 nicht die WEBCM-Schnittstelle
# http://fritz.box:49000/tr64desc.xml
# https://wiki.fhem.de/wiki/FRITZBOX#TR-064
# https://avm.de/service/schnittstellen/
# Thanks to Dragonfly (https://homematic-forum.de/forum/viewtopic.php?t=27994)
###=======###
# Variablen #
###=======###
IPS="192.168.137.1
192.168.137.2
192.168.137.3"
FRITZUSER=""
FRITZPW="passwort-weboberflaeche"
###====###
# Skript #
###====###
location="/upnp/control/deviceconfig"
uri="urn:dslforum-org:service:DeviceConfig:1"
action='Reboot'
for IP in ${IPS}; do
curl -k -m 5 --anyauth -u "$FRITZUSER:$FRITZPW" 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
done