package/ssdp-responder: fix warnings from check-package and shellcheck

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 <troglobit@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Joachim Wiberg
2022-11-06 19:19:46 +01:00
committed by Thomas Petazzoni
parent ea76443a4b
commit 10dbfdec2d

47
package/ssdp-responder/S50ssdpd Executable file → Normal file
View File

@@ -1,25 +1,32 @@
#!/bin/sh #!/bin/sh
NAME=ssdpd DAEMON=ssdpd
PIDFILE=/var/run/$NAME.pid PIDFILE=/var/run/$DAEMON.pid
DAEMON=/usr/sbin/$NAME CFGFILE=/etc/default/$DAEMON
CFGFILE=/etc/default/$NAME
DAEMON_ARGS="" DAEMON_ARGS=""
# Read configuration variable file if it is present # Read configuration variable file if it is present
[ -f $CFGFILE ] && . $CFGFILE # shellcheck source=/dev/null
[ -r "$CFGFILE" ] && . "$CFGFILE"
# shellcheck disable=SC2086
start() { start() {
printf 'Starting %s: ' "$NAME" printf 'Starting %s: ' "$DAEMON"
start-stop-daemon -S -q -p $PIDFILE -x $DAEMON -- $DAEMON_ARGS if start-stop-daemon -S -q -p "$PIDFILE" -x "$DAEMON" -- $DAEMON_ARGS; then
[ $? = 0 ] && echo "OK" || echo "FAIL" echo "OK"
else
echo "FAIL"
fi
} }
stop() { stop() {
printf 'Stopping %s: ' "$NAME" printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p $PIDFILE -x $DAEMON if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON"; then
[ $? = 0 ] && echo "OK" || echo "FAIL" echo "OK"
else
echo "FAIL"
fi
} }
restart() { restart() {
@@ -28,15 +35,15 @@ restart() {
} }
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1" "$1"
;; ;;
reload) reload)
restart restart
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
esac esac
exit $? exit $?