ap51-flash: run through shellcheck
authorRosen Penev <redacted>
Fri, 10 Jul 2020 22:30:03 +0000 (15:30 -0700)
committerRosen Penev <redacted>
Fri, 10 Jul 2020 22:30:03 +0000 (15:30 -0700)
Signed-off-by: Rosen Penev <redacted>
utils/ap51-flash/Makefile
utils/ap51-flash/files/ap51-flash.init
utils/ap51-flash/files/ap51-flash.sh

index 860a8d24db2c4ae7757b711965864140d1c1f86b..565444710e63618aac084a426cd452cc56bee473 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ap51-flash
 PKG_VERSION:=2019.0.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/ap51-flash/ap51-flash/releases/download/v$(PKG_VERSION)
index 1633ac4034e822dfaa514e9c4fa0def19c43536b..7969385b857588913ffbaee0c29319bad7e68fcf 100644 (file)
@@ -16,14 +16,15 @@ start_daemon() {
        [ "$loop" != "1" ] && loop=0
        if [ -n "$ifname" -a -n "$rootfs" -a -n "$kernel" ] || \
           [ -n "$ifname" -a -n "$ubnt" ]; then
-               PID="`cat /var/run/$NAME.sh-$ifname.pid 2> /dev/null`"
-               [ -z "`ps | grep "^.[ ]*$PID "`" ] && \
-                       rm /var/run/$NAME.sh-$ifname.pid
-               [ -n "`ls /var/run/$NAME.sh-$ifname.pid 2> /dev/null`" ] && {
+               PID="$(cat /var/run/$NAME.sh-$ifname.pid 2> /dev/null)"
+               if ! pgrep "^.[ ]*$PID "; then
+                       rm "/var/run/$NAME.sh-$ifname.pid"
+               fi
+               if find /var/run/ -name "$NAME.sh-$ifname.pid"; then
                        echo "Can't start more than one ap51-flash for interface $ifname!"
                        return 0
-               }
-               start-stop-daemon -S -b -m -p /var/run/$NAME.sh-$ifname.pid -n $NAME.sh \
+               fi
+               start-stop-daemon -S -b -m -p "/var/run/$NAME.sh-$ifname.pid" -n $NAME.sh \
                        -x /usr/lib/ap51-flash/$NAME.sh -- "$loop" "$ifname" "$rootfs" "$kernel" "$ubnt"
        fi
 }
@@ -38,13 +39,6 @@ stop() {
        echo "WARNING: Going to teminate all ap51-flash processes! (hope you made sure that they're not flashing right now)"
        echo "OR you can stop this with Ctrl+c within 10 seconds"
        sleep 10
-       local pidfile
-       for pidfile in `ls /var/run/${NAME}.sh-*.pid 2> /dev/null`; do
-               start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}.sh" >/dev/null
-               rm -f "${pidfile}"
-       done
-       for pidfile in `ls /var/run/${NAME}-*.pid 2> /dev/null`; do
-               start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}" >/dev/null
-               rm -f "${pidfile}"
-       done
+       find /var/run/ -name "$NAME.sh-*.pid" -exec start-stop-daemon -K -s TERM -p '{}' -n "$NAME.sh" \; -exec rm -f '{}' \;
+       find /var/run/ -name "$NAME.sh-*.pid" -exec start-stop-daemon -K -s TERM -p '{}' -n "$NAME" \; -exec rm -f '{}' \;
 }
index 9ac33ee0005c1abc212d4bf849261abd0b19d861..4eb5ea5ca65097902bbc28f3a024ed91c063115e 100755 (executable)
@@ -5,17 +5,17 @@ rootfs=""
 kernel=""
 ubnt=""
 
-[ $1 -eq "1" ] && loop="1"
+[ "$1" -eq "1" ] && loop="1"
 ifname="$2"
 [ -n "$3" ] && rootfs="--rootfs $3"
 [ -n "$4" ] && kernel="--kernel $4"
 [ -n "$5" ] && ubnt="--ubnt $5"
 
-while [ 1 ]; do
-       start-stop-daemon -S -m -p /var/run/$NAME-$ifname.pid -n $NAME \
-               -x /usr/sbin/$NAME -- --flash-from-file $rootfs $kernel $ubnt $ifname
-       
-       rm /var/run/$NAME-$ifname.pid
+while true; do
+       start-stop-daemon -S -m -p "/var/run/$NAME-$ifname.pid" -n $NAME \
+               -x /usr/sbin/$NAME -- --flash-from-file "$rootfs" "$kernel" "$ubnt" "$ifname"
+
+       rm "/var/run/$NAME-$ifname.pid"
        [ "$loop" != "1" ] && break
        sleep 15
 done
git clone https://git.99rst.org/PROJECT