Skip to content

Instantly share code, notes, and snippets.

@vicwomg
Last active September 6, 2024 11:25
Show Gist options
  • Save vicwomg/9b0bc6f1ea22e08379651a36877e0420 to your computer and use it in GitHub Desktop.
Save vicwomg/9b0bc6f1ea22e08379651a36877e0420 to your computer and use it in GitHub Desktop.
@bit7777
Copy link

bit7777 commented Sep 25, 2022

Here comes a modified version of the script from @jrwren for use on a TP-Link Archer C7 V1 with the latest Firmware 3.15.3 Build 150511 Rel.5581:

#!/bin/bash
IP=192.168.0.1
USER=admin
PASSWD=YOURPASSWORDHERE

LOGIN_URL=http://$IP/userRpm/LoginRpm.htm?Save=Save
REBOOT_PATH=/userRpm/SysRebootRpm.htm

#PASSMD5=$(echo -n $PASSWD | md5sum | cut -f 1 -d ' ')
#COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSMD5" | base64|sed s/=/%3D/)"

COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSWD" | base64|sed s/=/%3D/g)"

SESSION=$(curl -s -b "$COOKIE" "$LOGIN_URL" | grep -o 'http://[^"]*')
REBOOT_URL="$(dirname $(dirname $SESSION))$REBOOT_PATH"
curl -sif -o /dev/null -b "$COOKIE" -e "$REBOOT_URL" "$REBOOT_URL?Reboot=Reboot"

I was also able to write this script in a version running with cmd.exe on Windows XP SP3 (no cygwin etc. required). If someone is interested I can post it here.

@ausfas
Copy link

ausfas commented Sep 6, 2024

Here comes a modified version of the script from @jrwren for use on a TP-Link Archer C7 V1 with the latest Firmware 3.15.3 Build 150511 Rel.5581:

#!/bin/bash
IP=192.168.0.1
USER=admin
PASSWD=YOURPASSWORDHERE

LOGIN_URL=http://$IP/userRpm/LoginRpm.htm?Save=Save
REBOOT_PATH=/userRpm/SysRebootRpm.htm

#PASSMD5=$(echo -n $PASSWD | md5sum | cut -f 1 -d ' ')
#COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSMD5" | base64|sed s/=/%3D/)"

COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSWD" | base64|sed s/=/%3D/g)"

SESSION=$(curl -s -b "$COOKIE" "$LOGIN_URL" | grep -o 'http://[^"]*')
REBOOT_URL="$(dirname $(dirname $SESSION))$REBOOT_PATH"
curl -sif -o /dev/null -b "$COOKIE" -e "$REBOOT_URL" "$REBOOT_URL?Reboot=Reboot"

I was also able to write this script in a version running with cmd.exe on Windows XP SP3 (no cygwin etc. required). If someone is interested I can post it here.

I'm not an expert in Linux, can you please post the script that I run and test in Windows before testing if it can work in Homeassistant ?

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