root hace 5 años
commit
9e3ca87b57
Se han modificado 2 ficheros con 69 adiciones y 0 borrados
  1. 14 0
      README.md
  2. 55 0
      liveboxGetInfo

+ 14 - 0
README.md

@@ -0,0 +1,14 @@
+# Livebox tools 
+
+## `liveboxGetInfo` 
+
+Get some infos from livebox and populate `/var/lib/livebox` with json status files. Put livebox password in `/etc/.livebox`
+
+Based on stolen work from :  
+
+ * https://github.com/NextDom/plugin-livebox/
+ * https://www.alex-braga.fr/ressources_externe/xdslbox_3.4.10.sh
+ * https://easydomoticz.com/forum/viewtopic.php?t=7247
+
+
+

+ 55 - 0
liveboxGetInfo

@@ -0,0 +1,55 @@
+#!/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