2013-11-14 23:11:16 -07:00
|
|
|
#!/bin/sh
|
2015-01-18 12:36:49 -07:00
|
|
|
<<'LICENSE'
|
2015-03-09 17:39:04 -06:00
|
|
|
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
2015-01-18 12:36:49 -07:00
|
|
|
Copyright (C) 2015 Conrad Lara
|
|
|
|
See Contributors file for additional contributors
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation version 3 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
LICENSE
|
2013-11-14 23:11:16 -07:00
|
|
|
|
2016-01-17 21:09:11 -07:00
|
|
|
BOARD_TYPE=$(/usr/local/bin/get_hardwaretype)
|
|
|
|
|
|
|
|
case "$BOARD_TYPE" in
|
|
|
|
airrouter)
|
2016-06-16 18:32:29 -06:00
|
|
|
LINK1LED=$(readlink -f '/sys/class/leds/ubnt:green:globe')
|
2016-01-17 21:09:11 -07:00
|
|
|
;;
|
2018-05-19 23:39:51 -06:00
|
|
|
rb-912uag-5hpnd)
|
|
|
|
LINK1LED=$(readlink -f '/sys/class/leds/rb:green:led1')
|
|
|
|
;;
|
2016-01-17 21:09:11 -07:00
|
|
|
*)
|
|
|
|
LINK1LED=$(readlink -f /sys/class/leds/*link1)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-04-06 12:57:37 -06:00
|
|
|
|
2017-01-12 12:47:03 -07:00
|
|
|
firmware_upgrade_mode() {
|
|
|
|
# Put the LED in "upgrade" mode
|
|
|
|
echo timer > "$LINK1LED/trigger"
|
|
|
|
echo 100 > "$LINK1LED/delay_on"
|
|
|
|
echo 100 > "$LINK1LED/delay_off"
|
|
|
|
echo 1 > "$LINK1LED/brightness"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reset_led() {
|
|
|
|
# Reset the LED to a blank state
|
|
|
|
echo none > "$LINK1LED/trigger"
|
|
|
|
echo 0 > "$LINK1LED/brightness"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
link_state() {
|
|
|
|
{
|
|
|
|
reset_led
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
sleep 5;
|
2018-03-29 22:03:16 -06:00
|
|
|
if echo /nei | nc 127.0.0.1 2006 2>/dev/null | grep -q YES; then
|
2017-01-12 12:47:03 -07:00
|
|
|
echo 1 > "$LINK1LED/brightness"
|
|
|
|
else
|
|
|
|
echo 0 > "$LINK1LED/brightness"
|
|
|
|
fi
|
|
|
|
done;
|
|
|
|
} & # Push into the background
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"upgrade" )
|
|
|
|
firmware_upgrade_mode
|
|
|
|
;;
|
|
|
|
"restore" )
|
|
|
|
reset_led
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
link_state
|
|
|
|
;;
|
|
|
|
esac
|