Last active
November 6, 2021 00:40
-
-
Save rwky/a3f6cdfdb28bb510a93213550aeb8028 to your computer and use it in GitHub Desktop.
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/bash | |
if [ -z "$SKYPASSWORD" ] | |
then | |
echo "Please set the SKYPASSWORD environment variable" | |
exit 1 | |
fi | |
if [ -z "$SKYHUBIP" ] | |
then | |
SKYHUBIP='192.168.1.1' | |
fi | |
# get session key | |
sessionKey=$(curl -s -v -u "admin:$SKYPASSWORD" http://$SKYHUBIP/sky_diagnostics.html 2>&1 | grep 'sessionKey' | grep -E 'value="[0-9]+"' | sed 's/.*value="\([0-9]\+\)".*/\1/') | |
# issue reboot | |
curl -v -u "admin:$SKYPASSWORD" "http://$SKYHUBIP/sky_rebootinfo.cgi" -H 'Content-Type: application/x-www-form-urlencoded' --data "sessionKey=${sessionKey}&todo=refresh&this_file=sky_diagnostics.html&next_file=sky_diagnostics.html" | |
# get second session key | |
sessionKey=$(curl -s -v -u "admin:$SKYPASSWORD" "http://$SKYHUBIP/sky_rebootCPE.html" | grep 'sessionKey' | sed 's/.*sessionKey=\([0-9]\+\)",/\1/') | |
# visit reboot page which triggers reboot | |
curl -v -u "admin:$SKYPASSWORD" "http://$SKYHUBIP/sky_rebootCPE.cgi?todo=reboot&sessionKey=${sessionKey}&_=$(date '+%s')" | |
echo 'Done' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script reboots a Sky UK Internet Hub.
Run using
SKYPASSWORD=password SKYHUBIP='xxx.xxx.xxx.xxx' bash test.sh
replacing password with your hub password and xxx.xxx.xxx.xxx with the hub IP probably 192.168.1.1