#! /bin/bash

ROUTER=10.0.0.2
NEWIP=10.0.0.254

if [ "$1" ] ; then ROUTER=$1; fi

cat <<EOF
epicrouter:

This here script sets your Planet ADSL router at $IP to work in PPPOE mode.
For some reason, this is not the default.  You will need to run this as often
as you press the firmware reset button.  It also sets the IP address to
$NEWIP, so it will not interrupt running connections.

EOF

ping -c 1 -w 1 $ROUTER >& /dev/null || {
	echo "Oops: ping $ROUTER failed.  Is it plugged in?  Turned on?"
	arp -an | grep '($ROUTER)' >& /dev/null || {
		echo "$ROUTER is not local.  This script ASSUMES that $ROUTER is reachable via standard routing."
		echo "Try this:"
		echo "    ifconfig eth0:1 $ROUTER"
		echo "    $0"
	}
}


echo "Sending 4 8 2 ... M S Y to $ROUTER"

echo -ne "epicrouter
4
8
2
4
1
2
$NEWIP
3
255.255.255.0
1
B
M
S
Y
" | netcat -i 1 -w 1 $ROUTER 23 | strings

cat <<EOF
Completed - you should have seen the responses from the router. If you did not,
then the configuration has not changed.
EOF

