12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #!/bin/bash
- ###########################################
- # Firmware Livebox 4 = 3.4.10 g0-f-sip-fr #
- # Script mis a jour le 06/04/2018 #
- ###########################################
- export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin"
- #############################
- # Declaration des variables #
- #############################
- myLivebox=192.168.1.1
- myPassword=$(cat /etc/.livebox)
- myBashDir=/var/lib/livebox
- mkdir -p $myBashDir
- myOutput=$myBashDir/myOutput.txt
- myCookies=$myBashDir/myCookies.txt
- ########################################
- # Connexion et recuperation du cookies #
- ########################################
- curl -s -o "$myOutput" -X POST -c "$myCookies" -H 'Content-Type: application/x-sah-ws-4-call+json' -H 'Authorization: X-Sah-Login' -d "{\"service\":\"sah.Device.Information\",\"method\":\"createContext\",\"parameters\":{\"applicationName\":\"so_sdkut\",\"username\":\"admin\",\"password\":\"$myPassword\"}}" http://$myLivebox/ws > /dev/null
- ##################################################
- # Lecture du cookies pour utilisation ulterieure #
- ##################################################
- myContextID=$(tail -n1 "$myOutput" | sed 's/{"status":0,"data":{"contextID":"//1'| sed 's/",//1' | sed 's/"groups":"http,admin//1' | sed 's/"}}//1')
- ###############################################################################################
- # Envoi des commandes pour recuperer les informtations et ecriture dans un fichier TXT separe #
- ###############################################################################################
- getDSLStats=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NeMo.Intf.dsl0\",\"method\":\"getDSLStats\",\"parameters\":{}}" http://$myLivebox/ws`
- getMIBs=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NeMo.Intf.data\",\"method\":\"getMIBs\",\"parameters\":{}}" http://$myLivebox/ws`
- getLan=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NeMo.Intf.lan\",\"method\":\"getMIBs\",\"parameters\":{}}" http://$myLivebox/ws`
- getWan=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NMC\",\"method\":\"getWANStatus\",\"parameters\":{}}" http://$myLivebox/ws`
- getPhone=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"VoiceService.VoiceApplication\",\"method\":\"listTrunks\",\"parameters\":{}}" http://$myLivebox/ws`
- getTV=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NMC.OrangeTV\",\"method\":\"getIPTVStatus\",\"parameters\":{}}" http://$myLivebox/ws`
- echo $getDSLStats > $myBashDir/DSLStats.json
- echo $getMIBs > $myBashDir/MIBs.json
- echo $getLan > $myBashDir/LAN.json
- echo $getWan > $myBashDir/WAN.json
- echo $getPhone > $myBashDir/Phone.json
- echo $getTV > $myBashDir/TV.json
- #######################################################
- # Deconnexion et suppression des fichiers temporaires #
- #######################################################
- curl -s -b "$myCookies" -X POST http://$myLivebox/logout &> /dev/null
- rm "$myCookies" "$myOutput"
- exit 0
|