From c9ef303908fdf2bfb9a40869ec5e664b61094476 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Tue, 16 Oct 2018 23:08:14 +0300 Subject: [PATCH] init: use [[ cond ]] bash ifs --- board/common/overlay/etc/init.d/S01mountall | 2 +- board/common/overlay/etc/init.d/S02modules | 4 +- board/common/overlay/etc/init.d/S03hostname | 8 ++-- .../common/overlay/etc/init.d/S14postupgrade | 4 +- board/common/overlay/etc/init.d/S33hostapd | 10 ++-- board/common/overlay/etc/init.d/S35wifi | 20 ++++---- board/common/overlay/etc/init.d/S36ppp | 18 +++---- board/common/overlay/etc/init.d/S37bluetooth | 8 ++-- board/common/overlay/etc/init.d/S40network | 48 +++++++++---------- board/common/overlay/etc/init.d/S41netwatch | 4 +- board/common/overlay/etc/init.d/S43firewall | 6 +-- board/common/overlay/etc/init.d/S45dnsmasq | 6 +-- board/common/overlay/etc/init.d/S50date | 18 +++---- board/common/overlay/etc/init.d/S51crond | 2 +- board/common/overlay/etc/init.d/conf | 14 +++--- board/common/overlay/etc/init.d/panic | 4 +- board/common/overlay/etc/init.d/rcK | 4 +- board/common/overlay/etc/init.d/rcS | 4 +- .../raspberrypi/overlay/etc/init.d/S05cpufreq | 2 +- .../overlay/etc/init.d/S11throttlewatch | 4 +- .../raspberrypi/overlay/etc/init.d/S13btuart | 4 +- .../overlay/etc/init.d/S05cpufreq | 2 +- .../overlay/etc/init.d/S11throttlewatch | 4 +- .../overlay/etc/init.d/S05cpufreq | 2 +- .../overlay/etc/init.d/S11throttlewatch | 4 +- .../raspberrypi3/overlay/etc/init.d/S13btuart | 4 +- 26 files changed, 105 insertions(+), 105 deletions(-) diff --git a/board/common/overlay/etc/init.d/S01mountall b/board/common/overlay/etc/init.d/S01mountall index 829b974c64..71065f714d 100755 --- a/board/common/overlay/etc/init.d/S01mountall +++ b/board/common/overlay/etc/init.d/S01mountall @@ -6,7 +6,7 @@ mount_fs() { msg_begin "Mounting filesystems" /bin/mount -T /etc/fstab.disk -a && /bin/mount -T /etc/fstab.extra -a && - if [ -r /data/etc/fstab.user ]; then /bin/mount -T /data/etc/fstab.user -a; fi + if [[ -r /data/etc/fstab.user ]]; then /bin/mount -T /data/etc/fstab.user -a; fi test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S02modules b/board/common/overlay/etc/init.d/S02modules index 8e1b5a9fd8..685f63a5fb 100755 --- a/board/common/overlay/etc/init.d/S02modules +++ b/board/common/overlay/etc/init.d/S02modules @@ -9,11 +9,11 @@ case "$1" in start) msg_begin "Loading kernel modules" - if [ -r $sys_modules_file ]; then + if [[ -r $sys_modules_file ]]; then cat $sys_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done fi - if [ -r $modules_file ]; then + if [[ -r $modules_file ]]; then cat $modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done fi diff --git a/board/common/overlay/etc/init.d/S03hostname b/board/common/overlay/etc/init.d/S03hostname index dc1a56e345..8b886e838d 100755 --- a/board/common/overlay/etc/init.d/S03hostname +++ b/board/common/overlay/etc/init.d/S03hostname @@ -10,15 +10,15 @@ case "$1" in start) msg_begin "Setting hostname" - if ! [ -f $hostname_file ]; then - if [ -f $boot_hostname_file ]; then + if ! [[ -f $hostname_file ]]; then + if [[ -f $boot_hostname_file ]]; then cp $boot_hostname_file $hostname_file - elif [ -f $sys_hostname_file ]; then + elif [[ -f $sys_hostname_file ]]; then cp $sys_hostname_file $hostname_file fi fi - if [ -f $hostname_file ]; then + if [[ -f $hostname_file ]]; then hostname=$(cat $hostname_file) else hostname="$os_prefix-$board_sn" diff --git a/board/common/overlay/etc/init.d/S14postupgrade b/board/common/overlay/etc/init.d/S14postupgrade index 0765d72b76..65c0adf96b 100755 --- a/board/common/overlay/etc/init.d/S14postupgrade +++ b/board/common/overlay/etc/init.d/S14postupgrade @@ -16,7 +16,7 @@ test "$hash" == "$sys_hash" && exit 0 test -d $post_upgrade_dir || exit 0 function version_gt() { - if [ "$1" != "$2" ] && [ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]; then + if [[ "$1" != "$2" ]] && [[ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]]; then return 0 else return 1 @@ -29,7 +29,7 @@ function run_post_upgrade() { versions=$(ls -1 $post_upgrade_dir | cut -d '.' -f 1) for v in $versions; do - if [ -z "$version" ] || version_gt $v $version; then + if [[ -z "$version" ]] || version_gt $v $version; then msg_begin "Post-upgrading to version $v" out=$($post_upgrade_dir/$v.sh 2>&1) test $? == 0 && msg_done || msg_fail diff --git a/board/common/overlay/etc/init.d/S33hostapd b/board/common/overlay/etc/init.d/S33hostapd index bbdb797ff0..b8d6759589 100755 --- a/board/common/overlay/etc/init.d/S33hostapd +++ b/board/common/overlay/etc/init.d/S33hostapd @@ -14,10 +14,10 @@ link_watch_timeout=20 test -f $watch_conf && source $watch_conf -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi @@ -49,7 +49,7 @@ start() { while ! ifconfig $iface >/dev/null 2>&1; do sleep 1 count=$(($count + 1)) - if [ $count -ge 5 ]; then + if [[ $count -ge 5 ]]; then msg_fail "no device" return 1 fi @@ -61,7 +61,7 @@ start() { iwconfig $iface power off &> /dev/null $prog $conf &> $log & - if [ "$link_watch" == "yes" ]; then + if [[ "$link_watch" == "yes" ]]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S35wifi b/board/common/overlay/etc/init.d/S35wifi index 67d07047b6..7ab6635531 100755 --- a/board/common/overlay/etc/init.d/S35wifi +++ b/board/common/overlay/etc/init.d/S35wifi @@ -12,20 +12,20 @@ sys_watch_conf="/etc/watch.conf" boot_watch_conf="/boot/watch.conf" watch_conf="/data/etc/watch.conf" -if ! [ -f $watch_conf ]; then - if [ -f $boot_watch_conf ]; then +if ! [[ -f $watch_conf ]]; then + if [[ -f $boot_watch_conf ]]; then cp $boot_watch_conf $watch_conf - elif [ -f $sys_watch_conf ]; then + elif [[ -f $sys_watch_conf ]]; then cp $sys_watch_conf $watch_conf fi fi source $watch_conf -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi @@ -53,7 +53,7 @@ watch() { if connected; then count=0 else - if [ $count -lt $link_watch_timeout ]; then + if [[ $count -lt $link_watch_timeout ]]; then count=$(($count + 5)) logger -t wifi -s "disconnected" else @@ -74,7 +74,7 @@ start() { while ! ifconfig $os_wlan >/dev/null 2>&1; do sleep 1 count=$(($count + 1)) - if [ $count -ge 5 ]; then + if [[ $count -ge 5 ]]; then msg_fail "no device" return 1 fi @@ -93,7 +93,7 @@ start() { break fi - if [ $count -gt $link_watch_timeout ] || ! pidof wpa_supplicant > /dev/null; then + if [[ $count -gt $link_watch_timeout ]] || ! pidof wpa_supplicant > /dev/null; then test -n "$module" && msg_fail "failed ($module)"|| msg_fail return 1 fi @@ -101,7 +101,7 @@ start() { count=$(($count + 1)) done - if [ "$link_watch" == "true" ]; then + if [[ "$link_watch" == "true" ]]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S36ppp b/board/common/overlay/etc/init.d/S36ppp index b3dc0be5c6..c67f7253e6 100755 --- a/board/common/overlay/etc/init.d/S36ppp +++ b/board/common/overlay/etc/init.d/S36ppp @@ -11,10 +11,10 @@ watch_conf="/data/etc/watch.conf" source $watch_conf -if ! [ -d $conf ]; then - if [ -d $boot_conf ]; then +if ! [[ -d $conf ]]; then + if [[ -d $boot_conf ]]; then cp -r $boot_conf $conf - elif [ -d $sys_conf ]; then + elif [[ -d $sys_conf ]]; then cp -r $sys_conf $conf fi fi @@ -37,7 +37,7 @@ watch() { if connected; then count=0 else - if [ $count -lt $link_watch_timeout ]; then + if [[ $count -lt $link_watch_timeout ]]; then count=$(($count + 5)) logger -t ppp -s "disconnected" else @@ -64,13 +64,13 @@ start() { # wait for modem modem=$(head -n 1 $conf/modem) - if ! [ -e /dev/$modem ]; then + if ! [[ -e /dev/$modem ]]; then udev_trigger_add 4 & fi count=0 while true; do - if [ -e /dev/$modem ] || [ $count -gt $link_watch_timeout ]; then + if [[ -e /dev/$modem ]] || [[ $count -gt $link_watch_timeout ]]; then break fi @@ -78,7 +78,7 @@ start() { sleep 1 done - if ! [ -e /dev/$modem ]; then + if ! [[ -e /dev/$modem ]]; then msg_fail "modem /dev/$modem not present" return fi @@ -92,7 +92,7 @@ start() { break fi - if [ $count -gt $link_watch_timeout ] || ! pidof pppd > /dev/null; then + if [[ $count -gt $link_watch_timeout ]] || ! pidof pppd > /dev/null; then msg_fail return fi @@ -100,7 +100,7 @@ start() { count=$(($count + 1)) done - if [ "$link_watch" == "true" ]; then + if [[ "$link_watch" == "true" ]]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S37bluetooth b/board/common/overlay/etc/init.d/S37bluetooth index 1e61009058..76e570ab00 100755 --- a/board/common/overlay/etc/init.d/S37bluetooth +++ b/board/common/overlay/etc/init.d/S37bluetooth @@ -4,10 +4,10 @@ sys_conf="/etc/bluetooth.conf" boot_conf="/boot/bluetooth.conf" conf="/data/etc/bluetooth.conf" -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi @@ -46,7 +46,7 @@ start() { while ! hciconfig $hci &>/dev/null; do sleep 1 count=$(($count + 1)) - if [ $count -ge 10 ]; then + if [[ $count -ge 10 ]]; then msg_fail "no device" logger -t bluetooth -s "bluetooth device not available, calling panic action" panic_action bluetooth diff --git a/board/common/overlay/etc/init.d/S40network b/board/common/overlay/etc/init.d/S40network index 010329219a..93b03c81af 100755 --- a/board/common/overlay/etc/init.d/S40network +++ b/board/common/overlay/etc/init.d/S40network @@ -11,10 +11,10 @@ link_nego_timeout=10 source $watch_conf -if ! [ -f $static_conf ]; then - if [ -f $boot_static_conf ]; then +if ! [[ -f $static_conf ]]; then + if [[ -f $boot_static_conf ]]; then cp $boot_static_conf $static_conf - elif [ -f $sys_static_conf ]; then + elif [[ -f $sys_static_conf ]]; then cp $sys_static_conf $static_conf fi fi @@ -27,10 +27,10 @@ watch_eth() { count=0 while true; do sleep 5 - if [ "$(cat /sys/class/net/$os_eth/operstate 2>/dev/null)" == "up" ]; then + if [[ "$(cat /sys/class/net/$os_eth/operstate 2>/dev/null)" == "up" ]]; then count=0 else - if [ $count -lt $link_watch_timeout ]; then + if [[ $count -lt $link_watch_timeout ]]; then count=$(($count + 5)) logger -t ethernet -s "disconnected" else @@ -49,7 +49,7 @@ watch_ip() { if ip addr show dev $iface | grep inet &>/dev/null; then count=0 else - if [ $count -lt $ip_watch_timeout ]; then + if [[ $count -lt $ip_watch_timeout ]]; then count=$(($count + 5)) logger -t network -s "$iface has no IP address" else @@ -71,16 +71,16 @@ start_wlan() { return 1 fi - if [ "$(cat /sys/class/net/$os_wlan/carrier 2>/dev/null)" != "1" ]; then + if [[ "$(cat /sys/class/net/$os_wlan/carrier 2>/dev/null)" != "1" ]]; then msg_fail "no link" return 1 fi - if [ -n "$mtu" ]; then + if [[ -n "$mtu" ]]; then ip link set mtu $mtu dev $os_wlan fi - if [ -n "$static_ip" ]; then + if [[ -n "$static_ip" ]]; then msg_done $static_ip ifconfig $os_wlan $static_ip up static_ip="" # won't be used again @@ -89,7 +89,7 @@ start_wlan() { dhclient -cf "$dh_conf" $os_wlan fi - if [ "$ip_watch" == "true" ] && ip addr show dev $os_wlan | grep inet &>/dev/null; then + if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_wlan | grep inet &>/dev/null; then watch_ip $os_wlan & fi } @@ -103,7 +103,7 @@ start_eth() { while ! ifconfig $os_eth >/dev/null 2>&1; do sleep 1 count=$(($count + 1)) - if [ $count -ge $w ]; then + if [[ $count -ge $w ]]; then msg_done "no device" return 1 fi @@ -115,10 +115,10 @@ start_eth() { # wait for operstate w=3 count=0 - while [ "$(cat /sys/class/net/$os_eth/operstate 2>&1)" == "unknown" ]; do + while [[ "$(cat /sys/class/net/$os_eth/operstate 2>&1)" == "unknown" ]]; do sleep 1 count=$(($count + 1)) - if [ $count -ge $w ]; then + if [[ $count -ge $w ]]; then msg_done "no link" return 1 fi @@ -127,20 +127,20 @@ start_eth() { # wait for link test "$link_watch" == "true" || link_nego_timeout=5 count=0 - while [ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]; do + while [[ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]]; do sleep 1 count=$(($count + 1)) - if [ $count -ge $link_nego_timeout ]; then + if [[ $count -ge $link_nego_timeout ]]; then msg_done "no link" return 1 fi done - if [ -n "$mtu" ]; then + if [[ -n "$mtu" ]]; then ip link set mtu $mtu dev $os_eth fi - if [ -n "$static_ip" ]; then + if [[ -n "$static_ip" ]]; then msg_done $static_ip ifconfig $os_eth $static_ip up static_ip="" # won't be used again @@ -149,11 +149,11 @@ start_eth() { dhclient -cf "$dh_conf" $os_eth fi - if [ "$link_watch" == "true" ]; then + if [[ "$link_watch" == "true" ]]; then watch_eth & fi - if [ "$ip_watch" == "true" ] && ip addr show dev $os_eth | grep inet &>/dev/null; then + if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_eth | grep inet &>/dev/null; then watch_ip $os_eth & fi } @@ -172,14 +172,14 @@ start() { test -r /data/etc/ppp/modem && ifconfig | grep $os_ppp &>/dev/null && ppp_ok="ok" # if wifi or ppp link ok, start eth in background - if [ "$wlan_ok" == "ok" ] || [ "$ppp_ok" == "ok" ]; then + if [[ "$wlan_ok" == "ok" ]] || [[ "$ppp_ok" == "ok" ]]; then start_eth &>/dev/null & else start_eth && eth_ok="ok" fi - if [ "$eth_ok" != "ok" ] && [ "$wlan_ok" != "ok" ] && [ "$ppp_ok" != "ok" ]; then - if [ "$link_watch" == "true" ]; then + if [[ "$eth_ok" != "ok" ]] && [[ "$wlan_ok" != "ok" ]] && [[ "$ppp_ok" != "ok" ]]; then + if [[ "$link_watch" == "true" ]]; then logger -t network -s "no network connection available, calling panic action" panic_action network return 1 @@ -189,13 +189,13 @@ start() { fi fi - if [ -n "$static_gw" ]; then + if [[ -n "$static_gw" ]]; then msg_begin "Setting static gateway to $static_gw" ip route add default via $static_gw test $? == 0 && msg_done || msg_fail fi - if [ -n "$static_dns" ]; then + if [[ -n "$static_dns" ]]; then msg_begin "Setting static DNS server to $static_dns" echo "nameserver $static_dns" > /etc/resolv.conf test $? == 0 && msg_done || msg_fail diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index 2abd6433c6..a7bd496f32 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -7,7 +7,7 @@ netwatch_interval=20 test -f $watch_conf && source $watch_conf || exit 0 -if [ -z "$netwatch_host" ] || [ -z "$netwatch_port" ]; then +if [[ -z "$netwatch_host" ]] || [[ -z "$netwatch_port" ]]; then exit 0 fi @@ -23,7 +23,7 @@ watch() { if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port /dev/null 2>&1; then count=0 else - if [ $count -lt $netwatch_retries ]; then + if [[ $count -lt $netwatch_retries ]]; then logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port" count=$(($count + 1)) continue diff --git a/board/common/overlay/etc/init.d/S43firewall b/board/common/overlay/etc/init.d/S43firewall index a6313d2559..3e049c18d8 100755 --- a/board/common/overlay/etc/init.d/S43firewall +++ b/board/common/overlay/etc/init.d/S43firewall @@ -4,10 +4,10 @@ sys_conf="/etc/firewall.sh" boot_conf="/boot/firewall.sh" conf="/data/etc/firewall.sh" -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi diff --git a/board/common/overlay/etc/init.d/S45dnsmasq b/board/common/overlay/etc/init.d/S45dnsmasq index c571488db4..e6c7c3ffed 100755 --- a/board/common/overlay/etc/init.d/S45dnsmasq +++ b/board/common/overlay/etc/init.d/S45dnsmasq @@ -7,10 +7,10 @@ conf="/data/etc/dnsmasq.conf" log="/var/log/dnsmasq.log" prog="/usr/sbin/dnsmasq" -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi diff --git a/board/common/overlay/etc/init.d/S50date b/board/common/overlay/etc/init.d/S50date index 87464d368c..0390037222 100755 --- a/board/common/overlay/etc/init.d/S50date +++ b/board/common/overlay/etc/init.d/S50date @@ -11,18 +11,18 @@ sys_ntp_conf="/etc/ntp.conf" boot_ntp_conf="/boot/ntp.conf" ntp_conf="/data/etc/ntp.conf" -if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then +if ! [[ -f $conf ]]; then + if [[ -f $boot_conf ]]; then cp $boot_conf $conf - elif [ -f $sys_conf ]; then + elif [[ -f $sys_conf ]]; then cp $sys_conf $conf fi fi -if ! [ -f $ntp_conf ]; then - if [ -f $boot_ntp_conf ]; then +if ! [[ -f $ntp_conf ]]; then + if [[ -f $boot_ntp_conf ]]; then cp $boot_ntp_conf $ntp_conf - elif [ -f $sys_ntp_conf ]; then + elif [[ -f $sys_ntp_conf ]]; then cp $sys_ntp_conf $ntp_conf fi fi @@ -69,7 +69,7 @@ start_ntp() { cat $ntp_conf | grep -v iburst > ${ntp_conf}.tmp - if [ -n "$date_ntp_server" ]; then + if [[ -n "$date_ntp_server" ]]; then echo "server $date_ntp_server iburst" > $ntp_conf else cat $sys_ntp_conf | grep iburst > $ntp_conf @@ -100,7 +100,7 @@ stop_ntp() { } start() { - if [ "$date_method" == "http" ]; then + if [[ "$date_method" == "http" ]]; then start_http else start_ntp @@ -110,7 +110,7 @@ start() { } stop() { - if [ "$date_method" == "http" ]; then + if [[ "$date_method" == "http" ]]; then stop_http else stop_ntp diff --git a/board/common/overlay/etc/init.d/S51crond b/board/common/overlay/etc/init.d/S51crond index 1a839f71df..618b482e12 100755 --- a/board/common/overlay/etc/init.d/S51crond +++ b/board/common/overlay/etc/init.d/S51crond @@ -8,7 +8,7 @@ test -n "$os_version" || source /etc/init.d/base start() { msg_begin "Starting crond" - if [ -d $sys_conf ]; then + if [[ -d $sys_conf ]]; then /usr/sbin/crond -c $sys_conf fi diff --git a/board/common/overlay/etc/init.d/conf b/board/common/overlay/etc/init.d/conf index dc71091fb9..46ab1a6378 100644 --- a/board/common/overlay/etc/init.d/conf +++ b/board/common/overlay/etc/init.d/conf @@ -4,26 +4,26 @@ _sys_conf="/etc/os.conf" _boot_conf="/boot/os.conf" _conf="/data/etc/os.conf" -if ! [ -d /data/etc ]; then +if ! [[ -d /data/etc ]]; then # use boot/system variants if we don't have the data partition mounted - if [ -f $_boot_conf ]; then + if [[ -f $_boot_conf ]]; then source $_boot_conf - elif [ -f $_sys_conf ]; then + elif [[ -f $_sys_conf ]]; then source $_sys_conf fi return fi -if ! [ -f $_conf ]; then - if [ -f $_boot_conf ]; then +if ! [[ -f $_conf ]]; then + if [[ -f $_boot_conf ]]; then cp $_boot_conf $_conf - elif [ -f $_sys_conf ]; then + elif [[ -f $_sys_conf ]]; then cp $_sys_conf $_conf fi fi -if [ -f $_conf ]; then +if [[ -f $_conf ]]; then source $_conf fi diff --git a/board/common/overlay/etc/init.d/panic b/board/common/overlay/etc/init.d/panic index e0d288d0d6..fcf6724e54 100755 --- a/board/common/overlay/etc/init.d/panic +++ b/board/common/overlay/etc/init.d/panic @@ -13,11 +13,11 @@ panic_action() { echo $((panic_counter + 1)) > ${_PANIC_COUNTER_FILE} delay=$((_PANIC_REBOOT_DELAY_FACTOR * panic_counter)) - if [ "${delay}" -gt "${_PANIC_REBOOT_DELAY_MAX}" ]; then + if [[ "${delay}" -gt "${_PANIC_REBOOT_DELAY_MAX}" ]]; then delay=${_PANIC_REBOOT_DELAY_MAX} fi - if [ "${delay}" -gt 0 ]; then + if [[ "${delay}" -gt 0 ]]; then logger -t panic -s "rebooting in ${delay} seconds (caused by $1)" sleep ${delay} fi diff --git a/board/common/overlay/etc/init.d/rcK b/board/common/overlay/etc/init.d/rcK index 90d77ec140..7d08910c5b 100755 --- a/board/common/overlay/etc/init.d/rcK +++ b/board/common/overlay/etc/init.d/rcK @@ -10,8 +10,8 @@ echo "---- shutting down $os_name $os_version ----" >> $boot_log # stop all init scripts in /etc/init.d, # executing them in reverse numerical order. (for i in $(ls -r /etc/init.d/S??*); do - [ ! -x "$i" ] && continue - [ -f /data/etc/no_$(basename $i) ] && continue + if ! [[ -x "$i" ]]; then continue; fi + if [[ -f /data/etc/no_$(basename $i) ]]; then continue; fi $i stop done& echo $! > $pid_file) | tee -a $boot_log & diff --git a/board/common/overlay/etc/init.d/rcS b/board/common/overlay/etc/init.d/rcS index 22fa4ac98f..d15157610f 100755 --- a/board/common/overlay/etc/init.d/rcS +++ b/board/common/overlay/etc/init.d/rcS @@ -11,8 +11,8 @@ echo "---- booting $os_name $os_version ----" >> $tmp_boot_log # start all init scripts in /etc/init.d, # executing them in numerical order. (for i in /etc/init.d/S??* /etc/init.d/bootdone; do - [ ! -x "$i" ] && continue - [ -f /data/etc/no_$(basename $i) ] && continue + if ! [[ -x "$i" ]]; then continue; fi + if [[ -f /data/etc/no_$(basename $i) ]]; then continue; fi $i start || break done& echo $! > $pid_file) | tee -a $tmp_boot_log & diff --git a/board/raspberrypi/overlay/etc/init.d/S05cpufreq b/board/raspberrypi/overlay/etc/init.d/S05cpufreq index 5c97047d42..82ae420f49 100755 --- a/board/raspberrypi/overlay/etc/init.d/S05cpufreq +++ b/board/raspberrypi/overlay/etc/init.d/S05cpufreq @@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov" configure() { echo $gov > $cpufreqdir/scaling_governor - if [ $gov == "ondemand" ]; then + if [[ $gov == "ondemand" ]]; then echo 50 > $govdir/up_threshold echo 100000 > $govdir/sampling_rate echo 50 > $govdir/sampling_down_factor diff --git a/board/raspberrypi/overlay/etc/init.d/S11throttlewatch b/board/raspberrypi/overlay/etc/init.d/S11throttlewatch index 05e1ada454..a06374158c 100755 --- a/board/raspberrypi/overlay/etc/init.d/S11throttlewatch +++ b/board/raspberrypi/overlay/etc/init.d/S11throttlewatch @@ -21,7 +21,7 @@ get_throttled_since_boot() { watch_now() { while true; do t=$(get_throttled_now) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "currently: $t" fi @@ -32,7 +32,7 @@ watch_now() { watch_since_boot() { while true; do t=$(get_throttled_since_boot) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "since boot: $t" break fi diff --git a/board/raspberrypi/overlay/etc/init.d/S13btuart b/board/raspberrypi/overlay/etc/init.d/S13btuart index 48464b8263..f5d51a4148 100755 --- a/board/raspberrypi/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi/overlay/etc/init.d/S13btuart @@ -11,8 +11,8 @@ test -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi blu test -n "$os_version" || source /etc/init.d/base function start() { - if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then - if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ] ; then + if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then + if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null else /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null diff --git a/board/raspberrypi2/overlay/etc/init.d/S05cpufreq b/board/raspberrypi2/overlay/etc/init.d/S05cpufreq index 5c97047d42..82ae420f49 100755 --- a/board/raspberrypi2/overlay/etc/init.d/S05cpufreq +++ b/board/raspberrypi2/overlay/etc/init.d/S05cpufreq @@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov" configure() { echo $gov > $cpufreqdir/scaling_governor - if [ $gov == "ondemand" ]; then + if [[ $gov == "ondemand" ]]; then echo 50 > $govdir/up_threshold echo 100000 > $govdir/sampling_rate echo 50 > $govdir/sampling_down_factor diff --git a/board/raspberrypi2/overlay/etc/init.d/S11throttlewatch b/board/raspberrypi2/overlay/etc/init.d/S11throttlewatch index 05e1ada454..a06374158c 100755 --- a/board/raspberrypi2/overlay/etc/init.d/S11throttlewatch +++ b/board/raspberrypi2/overlay/etc/init.d/S11throttlewatch @@ -21,7 +21,7 @@ get_throttled_since_boot() { watch_now() { while true; do t=$(get_throttled_now) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "currently: $t" fi @@ -32,7 +32,7 @@ watch_now() { watch_since_boot() { while true; do t=$(get_throttled_since_boot) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "since boot: $t" break fi diff --git a/board/raspberrypi3/overlay/etc/init.d/S05cpufreq b/board/raspberrypi3/overlay/etc/init.d/S05cpufreq index 5c97047d42..82ae420f49 100755 --- a/board/raspberrypi3/overlay/etc/init.d/S05cpufreq +++ b/board/raspberrypi3/overlay/etc/init.d/S05cpufreq @@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov" configure() { echo $gov > $cpufreqdir/scaling_governor - if [ $gov == "ondemand" ]; then + if [[ $gov == "ondemand" ]]; then echo 50 > $govdir/up_threshold echo 100000 > $govdir/sampling_rate echo 50 > $govdir/sampling_down_factor diff --git a/board/raspberrypi3/overlay/etc/init.d/S11throttlewatch b/board/raspberrypi3/overlay/etc/init.d/S11throttlewatch index 05e1ada454..a06374158c 100755 --- a/board/raspberrypi3/overlay/etc/init.d/S11throttlewatch +++ b/board/raspberrypi3/overlay/etc/init.d/S11throttlewatch @@ -21,7 +21,7 @@ get_throttled_since_boot() { watch_now() { while true; do t=$(get_throttled_now) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "currently: $t" fi @@ -32,7 +32,7 @@ watch_now() { watch_since_boot() { while true; do t=$(get_throttled_since_boot) - if [ -n "$t" ]; then + if [[ -n "$t" ]]; then logger -t throttlewatch -s "since boot: $t" break fi diff --git a/board/raspberrypi3/overlay/etc/init.d/S13btuart b/board/raspberrypi3/overlay/etc/init.d/S13btuart index 6899065c82..513842ba6a 100755 --- a/board/raspberrypi3/overlay/etc/init.d/S13btuart +++ b/board/raspberrypi3/overlay/etc/init.d/S13btuart @@ -9,8 +9,8 @@ test -f $conf || test -f $boot_conf || test -f $sys_conf || exit 0 test -n "$os_version" || source /etc/init.d/base function start() { - if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then - if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ] ; then + if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then + if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null else /usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null