Skip to content

Instantly share code, notes, and snippets.

@cyanide-burnout
Last active October 28, 2024 09:13
Show Gist options
  • Save cyanide-burnout/b879e9cbccb4a0184dc5613d03bb0c65 to your computer and use it in GitHub Desktop.
Save cyanide-burnout/b879e9cbccb4a0184dc5613d03bb0c65 to your computer and use it in GitHub Desktop.
Automate switching Sagem F@ST DOCSIS modem to bridge mode on power cycling
#!/bin/bash
if ping -c 1 -t 5 192.168.0.1 2>&1 >/dev/null; then
KEY=$(curl -s http://192.168.0.1/login.html | grep 'var sessionkey' | grep -o -E '[0-9]+')
COOKIE=$(curl -s -d 'loginUsername=admin&loginPassword=PASSWORD' -X POST http://192.168.0.1/postlogin.cgi?sessionKey=$KEY -c - -O /dev/null | grep -m 1 web_cookie | awk '{print $7}')
CONTENT=$(mktemp)
curl -s -b "web_cookie=$COOKIE" http://192.168.0.1/reseau.html > $CONTENT
KEY=$(grep 'var sessionkey' $CONTENT | grep -o -E '[0-9]+')
grep -q "enblBridging = '0'" $CONTENT && curl -s -b "web_cookie=$COOKIE" -d 'PrimSecurity2GRadio=1' -X POST http://192.168.0.1/reseau-pa1-eRouterMode.cgi?sessionKey=$KEY -m 5
rm $CONTENT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment