Last active
October 10, 2022 14:00
-
-
Save dbro/648ab064a8608438c967e5479f1f6498 to your computer and use it in GitHub Desktop.
Restart the DSL connection on a Telekom Speedport Hybrid router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
# tested on firmware version 050124.04.00.007 | |
# thanks and credit to https://blog.mellenthin.de/archives/2015/04/29/telekom-speedport-hybrid-logging-mit-rrdtool/comment-page-1/ | |
# note that this script depends on sha256sum which may not be installed in some systems (eg Tomato router). It can be installed using entware/opkg. | |
address="speedport.ip" | |
password="12345678" | |
echo "contacting speedport router at ${address} ..." | |
challengev=$(curl -s -m 5 http://${address}/html/login/index.html?lang=en | grep challenge | cut -d'"' -f2) | |
#echo "challenge : ${challengev}" | |
encryptpwd=$(echo -n "${challengev}:${password}" | sha256sum | cut -d' ' -f1) | |
#echo "encryptpwd : ${encryptpwd}" | |
sessionid=$(curl -s -i -m 5 -d csrf_token=nulltoken -d showpw=0 -d challengev=${challengev} -d password=${encryptpwd} http://${address}/data/Login.json?lang=en | grep SessionID | cut -d'=' -f2 | cut -d';' -f1) | |
#echo "sessionid : ${sessionid}" | |
if [ -z $sessionid ]; then | |
echo "error: unable to log in to Telekom router and get a session id."; | |
exit 1; | |
fi | |
echo "tunnel_addr before: $(curl -s -m 5 --cookie "SessionID_R3=${sessionid}" http://${address}/data/bonding_client.json | grep tunnel_addr | cut -d'"' -f2)" | |
#echo "IPv4: $(curl -s --cookie "SessionID_R3=${sessionid}" http://${address}/data/interfaces.json | grep -B 1 255.255.255.255 | head -1 | awk -F"'" '{print $4}')" | |
echo "disconnecting DSL" | |
curl -s -m 10 --cookie "SessionID_R3=${sessionid}" -d req_connect=disabled http://${address}/data/Connect.json > /dev/null | |
sleep 10 | |
# TODO: wait for status to show dsl offline instead of this simple sleep command | |
echo "connecting DSL" | |
curl -s -m 10 --cookie "SessionID_R3=${sessionid}" -d req_connect=online http://${address}/data/Connect.json > /dev/null | |
# TODO: check for status indicating dsl online, and set exit status accordingly | |
echo "tunnel_addr after: $(curl -s -m 5 --cookie "SessionID_R3=${sessionid}" http://${address}/data/bonding_client.json | grep tunnel_addr | cut -d'"' -f2)" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment