Skip to content

Instantly share code, notes, and snippets.

@rwky
Last active November 6, 2021 00:40
Show Gist options
  • Save rwky/a3f6cdfdb28bb510a93213550aeb8028 to your computer and use it in GitHub Desktop.
Save rwky/a3f6cdfdb28bb510a93213550aeb8028 to your computer and use it in GitHub Desktop.
#!/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'
@rwky
Copy link
Author

rwky commented Dec 25, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment