Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ########################################################
- # Reconnect Script Telekom Speedport W723V Typ B
- # schapplm, 26.01.2013
- # Vorlage: Philipp Immel 2012 April 13 für W723V Typ A
- ########################################################
- # Description: Reconnects Speedport W 723V router Typ B
- # Syntax: recon
- # Extern: read printf echo curl grep awk sleep rm
- ########################################################
- #----------------------
- # Read router password
- #----------------------
- password="YOURPASSWORD"
- #---------------------------
- # Check external IP address
- #---------------------------
- echo "Fetching external IP address …"
- OLDIP=$( curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' )
- echo "Your IP before reconnect:" $OLDIP
- #----------------------------------------------
- # Log on to router and get a session ID cookie
- #----------------------------------------------
- echo "Logging in …"
- curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --data "pws=$password" --data "login_pwd=2" --referer "https://speedport.ip/hcti_start_passwort.stm" --insecure "https://speedport.ip/cgi-bin/login.cgi" &> /dev/null
- sleep 1
- #----------------------------------------------
- # Execute Disconnect and Connect Script
- #----------------------------------------------
- echo "Reconnect …"
- curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --insecure "https://speedport.ip/cgi-bin/disconnect.exe" &> /dev/null
- sleep 3
- curl --user-agent "Mozilla/4.0" --location --cookie-jar "/volume1/pyload/SessionID.txt" --insecure "https://speedport.ip/cgi-bin/connect.exe" &> /dev/null
- #-------------------------
- # Log out from the router
- #-------------------------
- echo "Logging off …"
- curl --location --insecure --cookie "/volume1/pyload/SessionID.txt" "https://speedport.ip/cgi-bin/logout.cgi" &> /dev/null
- sleep 10
- #---------------------------
- # Check external IP address
- #---------------------------
- echo "Fetching external IP address …"
- NEWIP=$( curl -s --data "dummy=42" --connect-timeout 120 "http://checkip.dyndns.org/dummy/" | sed 's/[a-zA-Z/<> :]//g' )
- #-------------------
- # Check for success
- #-------------------
- if [ "$OLDIP" != "$NEWIP" ] && [ "$NEWIP" != "" ]
- then
- echo "Reconnect has been successful. Your new IP address is:" $NEWIP
- else
- echo "Reconnect has not been successful. Please try again. Your IP address is still:" $OLDIP
- fi
- #--------------------
- # Remove cookie file
- #--------------------
- rm /volume1/pyload/SessionID.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement