10dbfdec2d
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>
50 lines
719 B
Bash
50 lines
719 B
Bash
#!/bin/sh
|
|
|
|
DAEMON=ssdpd
|
|
PIDFILE=/var/run/$DAEMON.pid
|
|
CFGFILE=/etc/default/$DAEMON
|
|
|
|
DAEMON_ARGS=""
|
|
|
|
# Read configuration variable file if it is present
|
|
# shellcheck source=/dev/null
|
|
[ -r "$CFGFILE" ] && . "$CFGFILE"
|
|
|
|
# shellcheck disable=SC2086
|
|
start() {
|
|
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: ' "$DAEMON"
|
|
if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON"; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart)
|
|
"$1"
|
|
;;
|
|
reload)
|
|
restart
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $?
|