aredn/files/usr/local/bin/linkled

43 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
<<'LICENSE'
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
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
BOARD_TYPE=$(/usr/local/bin/get_hardwaretype)
case "$BOARD_TYPE" in
airrouter)
LINK1LED=$(readlink -f '/sys/class/leds/ubnt:green:globe')
;;
*)
LINK1LED=$(readlink -f /sys/class/leds/*link1)
;;
esac
{
while true; do
sleep 5;
if echo /neighbors | nc 127.0.0.1 2006 2>/dev/null | grep -q YES; then
echo 1 > "$LINK1LED/brightness"
else
echo 0 > "$LINK1LED/brightness"
fi
done;
} &