URL: https://linuxfr.org/forums/programmation-shell/posts/controle-de-la-freebox-v6-par-le-shell-wifi-reboot Title: Contrôle de la Freebox V6 par le shell : wifi, reboot ... Authors: skimpax Date: 2012年10月24日T11:36:49+02:00 Tags: freebox Score: 13 Bonjour, Ce sujet fait suite au premier sujet que j'avais initialement créé pour contrôler le **wifi** de la freebox v6. Vous en retrouverez le fil ici : http://linuxfr.org/forums/programmationshell/posts/activerd%C3%A9sactiver-le-wifi-dune-freebox-v6-depuis-le-r%C3%A9seau-local J'y ajoute maintenant la possibilité de faire **rebooter** la freebox à distance. Pour l'occasion, le script change de nom (fbxCtrl.sh) et la syntaxe des paramètres change légèrement. Une petite entrée dans la crontab, dans la nuit des mardi/mercredi par exemple, puisque Free délivre ses firmwares le mardi souvent, et hop le tour est joué. **Exemple de crontab :** _Reboot tous les mercredi à 2h05 du matin._ ```bash 05 2 * * Wed /chemin/script/fbxCtrl.sh fbxReboot ``` **Le script fbxCtrl.sh :** ```bash #!/bin/bash fbxLogin='freebox' fbxPasswd='monMotDePasse' fbxCookieFile="/tmp/fbxCookie.txt" fbxLogin() { curl --cookie-jar $fbxCookieFile -s -o /dev/null -L "http://mafreebox.freebox.fr/login.php?login=$fbxLogin&passwd=$fbxPasswd" if [ $? -ne 0 ]; then echo "Login to Freebox failed!" exit 0 fi } fbxLogout() { curl -b $fbxCookieFile -s -o /dev/null -L 'http://mafreebox.freebox.fr/login.php?logout=1' rm -f $fbxCookieFile if [ $? -ne 0 ]; then echo "Logout of Freebox failed!" fi } wifiOn() { fbxLogin curl -b $fbxCookieFile -s -o /dev/null -d 'enabled=on&channel=9&ht_mode=20&method=wifi.ap_params_set&config=Valider' -H "X-Requested-With: XMLHttpRequest" -L 'http://mafreebox.freebox.fr/wifi.cgi' if [ $? -ne 0 ]; then echo "Setting Freebox wifi ON failed!" fi fbxLogout } wifiOff() { fbxLogin curl -b $fbxCookieFile -s -o /dev/null -d 'channel=9&ht_mode=20&method=wifi.ap_params_set&config=Valider' -H "X-Requested-With: XMLHttpRequest" -L 'http://mafreebox.freebox.fr/wifi.cgi' if [ $? -ne 0 ]; then echo "Setting Freebox wifi OFF failed!" fi fbxLogout } wifiStatus() { fbxLogin checked=$(curl -b $fbxCookieFile -s -L 'http://mafreebox.freebox.fr/settings.php?page=wifi_conf' | grep '') rc=0 if [ "$checked" != "" ]; then echo "Freebox Wifi is ON" rc=1 else echo "Freebox Wifi is OFF" fi fbxLogout exit $rc } fbxReboot() { fbxLogin curl -b $fbxCookieFile -s -o /dev/null -d 'method=system.reboot&timeout=1&reboot=Red%C3%A9marrer+la+freebox' -H "X-Requested-With: XMLHttpRequest" -L 'http://mafreebox.freebox.fr/system.cgi' 2>/dev/null if [ $? -ne 0 ]; then echo "Request to reboot the Freebox has failed!" fi } case "1ドル" in wifiOn) wifiOn exit 1 ;; wifiOff) wifiOff exit 0 ;; wifiStatus) wifiStatus exit $? ;; fbxReboot) fbxReboot exit $? ;; *) echo "Usage: 0ドル {wifiOn|wifiOff|wifiStatus|fbxReboot}" exit 0 esac exit 0 ```

AltStyle によって変換されたページ (->オリジナル) /