mirror of https://github.com/aredn/aredn.git
Cleanup /usr/local/bin scripts to pass shellcheck
Correct all shellcheck "errors" and "warnings" for /usr/local/bin/* shell scripts. This is necesary to have Jenkins start publishing test results. All code worked on nodes but pushed to strict posix compliance as part of the cleanup. SC1001,SC2002,SC2004,SC2006,SC2034,SC2039,SC2086,SC2155 https://github.com/koalaman/shellcheck/wiki for more info Change-Id: If1f27381eedae79087e490ea12f5939f8cc525a0
This commit is contained in:
parent
39efd11beb
commit
8abe628915
|
@ -18,7 +18,7 @@
|
|||
|
||||
LICENSE
|
||||
|
||||
DHCPLANSECTION=`uci show dhcp|grep interface=lan|sed "s/dhcp.\@dhcp\[\(.*\)\].interface=lan/\1/"`
|
||||
DHCPLANSECTION=$(uci show dhcp|grep interface=lan|sed "s/dhcp.\@dhcp\[\(.*\)\].interface=lan/\1/")
|
||||
|
||||
logger "AREDN(TM) Recovery: Reseting root password to: hsmm"
|
||||
/usr/local/bin/setpasswd hsmm
|
||||
|
@ -29,7 +29,7 @@ logger "AREDN(TM) Recovery: Restarting uhttpd"
|
|||
if [ "$DHCPLANSECTION" != "" ]
|
||||
then
|
||||
logger "AREDN(TM) Recovery: Enable DHCP on lan interface"
|
||||
uci set dhcp.@dhcp\[$DHCPLANSECTION\].ignore=0
|
||||
uci set "dhcp.@dhcp\[$DHCPLANSECTION\].ignore=0"
|
||||
uci -q commit
|
||||
|
||||
logger "AREDN(TM) Recovery: Restart dnsmasq"
|
||||
|
|
|
@ -38,7 +38,7 @@ LICENSE
|
|||
[ -f /etc/config/run-fccid ] || exit
|
||||
|
||||
# stagger the beacons between nodes
|
||||
N=`ifconfig wlan0 | grep "inet addr" | cut -f4 -d. | cut -c1-3`
|
||||
sleep $N
|
||||
N=$(ifconfig wlan0 | grep "inet addr" | cut -f4 -d. | cut -c1-3)
|
||||
sleep "$N"
|
||||
|
||||
echo "ID: `uname -n`" | socat - udp4:10.255.255.255:4919,broadcast,so-bindtodevice=wlan0
|
||||
echo "ID: $(uname -n)" | socat - udp4:10.255.255.255:4919,broadcast,so-bindtodevice=wlan0
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
. /lib/ar71xx.sh
|
||||
|
||||
local boardtype=$(ar71xx_board_name)
|
||||
local boardtype
|
||||
boardtype=$(ar71xx_board_name)
|
||||
|
||||
echo $boardtype
|
||||
echo "$boardtype"
|
||||
|
|
|
@ -22,7 +22,7 @@ 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/ubnt:green:globe')
|
||||
;;
|
||||
*)
|
||||
LINK1LED=$(readlink -f /sys/class/leds/*link1)
|
||||
|
@ -34,9 +34,9 @@ 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
|
||||
echo 1 > "$LINK1LED/brightness"
|
||||
else
|
||||
echo 0 > $LINK1LED//brightness
|
||||
echo 0 > "$LINK1LED/brightness"
|
||||
fi
|
||||
done;
|
||||
} &
|
||||
|
|
|
@ -5,7 +5,7 @@ while true; do
|
|||
N=0
|
||||
while [ ! -f /tmp/namechange -a $N -lt 60 ]; do
|
||||
sleep 5
|
||||
N=$(($N + 5))
|
||||
N=$((N + 5))
|
||||
done
|
||||
|
||||
rm -f /tmp/namechange
|
||||
|
|
|
@ -33,8 +33,8 @@ do
|
|||
then
|
||||
rm -f "/tmp/olsrd.watchdog"
|
||||
else
|
||||
uptime=`cat /proc/uptime | cut -d' ' -f1`
|
||||
date=`date`
|
||||
uptime=$(cut -d' ' -f1 < /proc/uptime)
|
||||
date=$(date)
|
||||
echo "$uptime $date" >> /tmp/olsrd.log
|
||||
/etc/init.d/olsrd restart
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
/sbin/sysupgrade -d 7 -f /tmp/arednsysupgradebackup.tgz -q $1 2>&1
|
||||
/sbin/sysupgrade -d 7 -f /tmp/arednsysupgradebackup.tgz -q "$1" 2>&1
|
||||
|
||||
rc=$?; if [[ $rc != 0 ]]; then /sbin/reboot; fi
|
||||
rc=$?; if [ $rc != 0 ]; then /sbin/reboot; fi
|
||||
|
|
|
@ -5,34 +5,35 @@
|
|||
|
||||
kill_remaining() { # [ <signal> ]
|
||||
local sig="${1:-TERM}"
|
||||
echo -n "Sending $sig to remaining processes ... "
|
||||
printf "Sending %s to remaining processes ... " "$sig"
|
||||
|
||||
local my_pid=$$
|
||||
local my_ppid=$(cut -d' ' -f4 /proc/$my_pid/stat)
|
||||
local my_ppid
|
||||
my_ppid=$(cut -d' ' -f4 /proc/$my_pid/stat)
|
||||
local my_ppisupgraded=
|
||||
grep -q upgraded /proc/$my_ppid/cmdline >/dev/null && {
|
||||
grep -q upgraded "/proc/$my_ppid/cmdline" >/dev/null && {
|
||||
local my_ppisupgraded=1
|
||||
}
|
||||
|
||||
|
||||
local stat
|
||||
for stat in /proc/[0-9]*/stat; do
|
||||
[ -f "$stat" ] || continue
|
||||
|
||||
local pid name state ppid rest
|
||||
read pid name state ppid rest < $stat
|
||||
local pid name _ ppid rest
|
||||
read pid name _ ppid rest < "$stat"
|
||||
name="${name#(}"; name="${name%)}"
|
||||
|
||||
local cmdline
|
||||
read cmdline < /proc/$pid/cmdline
|
||||
read cmdline < "/proc/$pid/cmdline"
|
||||
|
||||
# Skip kernel threads
|
||||
[ -n "$cmdline" ] || continue
|
||||
|
||||
if [ $$ -eq 1 ] || [ $my_ppid -eq 1 ] && [ -n "$my_ppisupgraded" ]; then
|
||||
if [ $$ -eq 1 ] || [ "$my_ppid" -eq 1 ] && [ -n "$my_ppisupgraded" ]; then
|
||||
# Running as init process, kill everything except me
|
||||
if [ $pid -ne $$ ] && [ $pid -ne $my_ppid ]; then
|
||||
echo -n "$name "
|
||||
kill -$sig $pid 2>/dev/null
|
||||
if [ "$pid" -ne $$ ] && [ "$pid" -ne "$my_ppid" ]; then
|
||||
printf "%s " "$name"
|
||||
kill "-$sig" "$pid" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
case "$name" in
|
||||
|
@ -41,9 +42,9 @@ kill_remaining() { # [ <signal> ]
|
|||
|
||||
# Killable process
|
||||
*)
|
||||
if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
|
||||
echo -n "$name "
|
||||
kill -$sig $pid 2>/dev/null
|
||||
if [ "$pid" -ne $$ ] && [ "$ppid" -ne $$ ]; then
|
||||
printf "%s " "$name"
|
||||
kill "-$sig" "$pid" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue