· 7 years ago · Sep 22, 2018, 08:28 PM
1#!/bin/bash
2
3echo "==================================================================="
4echo "This bash script will upload tomato.trx in the current directory to"
5echo "192.168.11.1 during the router's bootup."
6echo
7echo "* Set your ethernet card's settings to:"
8echo " IP: 192.168.11.2"
9echo " Mask: 255.255.255.0"
10echo " Gateway: 192.168.11.1."
11echo
12echo "* Unplug the router's power cable."
13echo " Press Ctrl+C to abort or any other key to continue..."
14
15read
16
17echo "* Re-plug the router's power cable."
18echo "==================================================================="
19echo
20echo "Waiting for the router... Press Ctrl+C to abort."
21
22ROUTER_IP='192.168.11.1'
23ret=""
24
25while [ -z "$ret" ]; do
26 ret=$( ping -c 1 -W 50 $ROUTER_IP | grep ttl )
27 echo -n '.'
28done
29echo
30
31if [ -n "$ret" ]; then
32 echo 'Uploading firmware via tftp...'
33 echo 'put tomato.trx' | tftp $ROUTER_IP
34 echo
35 echo "==================================================================="
36 echo "* WAIT for about 2 minutes while the firmware is being flashed."
37 echo
38 echo "* Reset your ethernet card's settings back to DHCP."
39 echo
40 echo "* The default router address will be at 192.168.1.1."
41else
42 echo 'Upload failed!'
43fi