source: genesis/tools/flash-ns5m@ 13691

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