Last change
on this file since 13480 was 12360, checked in by rick, 12 years ago |
Make it no newlines, for readability.
|
-
Property svn:executable
set to
*
|
File size:
1.6 KB
|
Rev | Line | |
---|
[12356] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Flash stock nanostation for use in WL network
|
---|
| 4 | #
|
---|
| 5 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
| 6 | #
|
---|
| 7 | DIRNAME=`dirname $0`
|
---|
[12358] | 8 | TOTAL_TRIES=60
|
---|
[12356] | 9 |
|
---|
| 10 | # Argument helpers
|
---|
| 11 | if [ -z "$2" ]; then
|
---|
| 12 | echo "Usage: $0 <node> <iface>"
|
---|
| 13 | exit 128
|
---|
| 14 | fi
|
---|
| 15 |
|
---|
| 16 | if [ ! -r "fwupdate.bin" ]; then
|
---|
| 17 | echo "Unable to read fwupdate.bin (download latest firmware file)"
|
---|
| 18 | exit 1
|
---|
| 19 | fi
|
---|
| 20 |
|
---|
| 21 | HOSTNAME=$1
|
---|
| 22 | NS_IFACE=$2
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | # Create configuration
|
---|
| 26 | $DIRNAME/gformat.py test $HOSTNAME $NS_IFACE-ns5m.conf > system.cfg.new
|
---|
| 27 | if [ $? -ne 0 ]; then
|
---|
| 28 | echo "Unable to generate configuration file"
|
---|
| 29 | exit 1
|
---|
| 30 | fi
|
---|
| 31 |
|
---|
| 32 | # Verify connectivity
|
---|
[12358] | 33 | TRY=0
|
---|
| 34 | while true; do
|
---|
| 35 | sshpass -p ubnt ssh -oUserKnownHostsFile=/dev/null ubnt@192.168.1.20 'uname -a'
|
---|
| 36 | if [ $? -eq 0 ]; then
|
---|
| 37 | break
|
---|
| 38 | fi
|
---|
[12356] | 39 |
|
---|
[12358] | 40 | TRY=`expr $TRY + 1`
|
---|
| 41 | echo "Unable to connect to NanoStation (attempt $TRY of $TOTAL_TRIES)"
|
---|
| 42 | if [ $TRY -ge $TOTAL_TRIES ]; then
|
---|
| 43 | exit 1
|
---|
| 44 | fi
|
---|
| 45 | sleep 1
|
---|
| 46 | done
|
---|
| 47 |
|
---|
[12356] | 48 | # Variables needed from Nanostaion, as to be filled into configuration
|
---|
| 49 | MAC=`arp -na | awk '/192.168.1.20/ {print $4}'`
|
---|
| 50 | IFACE=`arp -na | awk '/192.168.1.20/ {print $7}'`
|
---|
| 51 |
|
---|
| 52 | # XXX: Automatically put MAC into configuration
|
---|
| 53 | echo "# MAC of NanoStation is $MAC"
|
---|
| 54 |
|
---|
| 55 | # Flash node
|
---|
[12358] | 56 | sshpass -p ubnt scp -oUserKnownHostsFile=/dev/null system.cfg.new fwupdate.bin ubnt@192.168.1.20:/tmp || exit 1
|
---|
| 57 | sshpass -p ubnt ssh -oUserKnownHostsFile=/dev/null ubnt@192.168.1.20 'cfgmtd -w -f /tmp/system.cfg.new && fwupdate -m' || exit 1
|
---|
[12356] | 58 |
|
---|
| 59 | echo "Ones the leds are off configuration is done"
|
---|
| 60 |
|
---|
| 61 | # TODO: Login on auto-alias IP address to verify
|
---|
| 62 | sudo tcpdump -nn -v -i $IFACE -s 1500 -c 1 'ether[18:4] == 0x000c2000'
|
---|
| 63 |
|
---|
[12357] | 64 | echo "All done, press CTRL-C to quit"
|
---|
| 65 | while true; do
|
---|
[12360] | 66 | echo -ne "\a"
|
---|
[12359] | 67 | sleep 5
|
---|
[12357] | 68 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.