diff options
author | Rosen Penev <rosenp@gmail.com> | 2020-07-10 15:30:03 -0700 |
---|---|---|
committer | Rosen Penev <rosenp@gmail.com> | 2020-07-10 15:30:03 -0700 |
commit | 700b4e5cc1e116a5ba532be68d7b8ccd52c4ade8 (patch) | |
tree | c951a54be6eb01ae328b1b08363fbebb126b07be /utils/ap51-flash/files/ap51-flash.init | |
parent | f94cb351bc24dacbb571ad1e713636b3d0ae1125 (diff) |
ap51-flash: run through shellcheck
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'utils/ap51-flash/files/ap51-flash.init')
-rw-r--r-- | utils/ap51-flash/files/ap51-flash.init | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/utils/ap51-flash/files/ap51-flash.init b/utils/ap51-flash/files/ap51-flash.init index 1633ac403..7969385b8 100644 --- a/utils/ap51-flash/files/ap51-flash.init +++ b/utils/ap51-flash/files/ap51-flash.init @@ -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 '{}' \; } |