Triggertftp

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 00:51, 23 January 2009 (edit)
Jecurrey (Talk | contribs)
(Script to help with tftp boot timing)
← Previous diff
Current revision (16:53, 30 April 2010) (edit) (undo)
Glenn (Talk | contribs)
(catspec)
 
(3 intermediate revisions not shown.)
Line 46: Line 46:
nmap $NEW nmap $NEW
fi fi
 +
 +[[Category:Flashing networking hardware]]

Current revision

# small script to help with tftp boot, change out the values of the variable at the top to your values
# the use of an intermediate switch is highly recommended
#IMAGE=f5d7230-4_4.03.03.bin
#IMAGE=dd-wrt.v24-9517_VINT_mini_usb.bin
IMAGE=dd-wrt.v24_generic-8184.bin
#f5d7230-4_4.03.03.bin
# current IP of the router
OLD=192.168.2.1
# address of the router if it flashes successfully
NEW=192.168.1.1
# interface on the machine providing the tftp boot and where this script is being run.
INTERFACE=eth0
set -e
if test -f "$IMAGE"
then
       echo $IMAGE exists starting ping loop
else
       echo file: $IMAGE doesnot exist >&2
       exit 2
fi
CURRENT_IP=`ip addr show "$INTERFACE"| awk '$1 == "inet" { print $2}'`
if test -z "$CURRENT_IP"
then
       echo "Interface address for $INTERFACE not found." >&2
       exit 2
fi
count=0
until ping -c 2 -i .2 -n -w 60 $OLD || test $count -gt 5
do
       count=$(( $count + 1))
done
atftp --option "mode octet" --option "timeout  60" --verbose --trace -p -l "$IMAGE" "$OLD"
# waiting longer than needed x2
sleep 120
ping -c 1 $OLD
if test $? -eq 0
then
       echo old address is still responding, probably tftp boot failed >&2
       exit 3
else
       # hardcoded
       # using class c addressing
       ip addr del $CURRENT_IP  dev  $INTERFACE
       ip addr add ${NEW}/24 dev $INTERFACE
       ping -c 4 $NEW
       nmap $NEW
fi