Skip to content

Commit

Permalink
package/ssdp-responder: fix warnings from check-package and shellcheck
Browse files Browse the repository at this point in the history
Summary of changes:

 - Fix use of $DAEMON, found by check-package
   - Expects DAEMON to be name of daemon controlled by script, this
     causes ripple efects in rest of script
   - Recommend `chmod a-x`, .mk file installs with `-m 0755`
 - Fix shellcheck warnings:
   - Use "$VAR" in case of spaces in filenames
   - recommend not using $? in if stmt, should use `if start-stop ...`
   - mismatch in indentation in case-esac

Signed-off-by: Joachim Wiberg <[email protected]>
Signed-off-by: Thomas Petazzoni <[email protected]>
  • Loading branch information
troglobit authored and tpetazzoni committed Nov 22, 2022
1 parent ea76443 commit 10dbfde
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions package/ssdp-responder/S50ssdpd
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
#!/bin/sh

NAME=ssdpd
PIDFILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/$NAME
CFGFILE=/etc/default/$NAME
DAEMON=ssdpd
PIDFILE=/var/run/$DAEMON.pid
CFGFILE=/etc/default/$DAEMON

DAEMON_ARGS=""

# Read configuration variable file if it is present
[ -f $CFGFILE ] && . $CFGFILE
# shellcheck source=/dev/null
[ -r "$CFGFILE" ] && . "$CFGFILE"

# shellcheck disable=SC2086
start() {
printf 'Starting %s: ' "$NAME"
start-stop-daemon -S -q -p $PIDFILE -x $DAEMON -- $DAEMON_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
printf 'Starting %s: ' "$DAEMON"
if start-stop-daemon -S -q -p "$PIDFILE" -x "$DAEMON" -- $DAEMON_ARGS; then
echo "OK"
else
echo "FAIL"
fi
}

stop() {
printf 'Stopping %s: ' "$NAME"
start-stop-daemon -K -q -p $PIDFILE -x $DAEMON
[ $? = 0 ] && echo "OK" || echo "FAIL"
printf 'Stopping %s: ' "$DAEMON"
if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON"; then
echo "OK"
else
echo "FAIL"
fi
}

restart() {
Expand All @@ -28,15 +35,15 @@ restart() {
}

case "$1" in
start|stop|restart)
"$1"
;;
reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
start|stop|restart)
"$1"
;;
reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac

exit $?

0 comments on commit 10dbfde

Please sign in to comment.