mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
With the action function as the last command in the script its return code automatically becomes that of the script, and without explicit exit shellcheck does not complain about unused functions. Also wait for the process to stop in "stop", and simplify restart. Signed-off-by: Fiona Klute <fiona.klute@gmx.de> Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
74 lines
1.2 KiB
Bash
74 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
DAEMON=mdnsd
|
|
MDNSD=/usr/sbin/$DAEMON
|
|
PIDFILE=/var/run/$DAEMON.pid
|
|
CFGFILE=/etc/default/$DAEMON
|
|
|
|
MDNSD_ARGS=""
|
|
|
|
# Read configuration variable file if it is present
|
|
# shellcheck source=/dev/null
|
|
[ -r "$CFGFILE" ] && . "$CFGFILE"
|
|
|
|
start() {
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
# shellcheck disable=SC2086 # we need word splitting
|
|
start-stop-daemon --start --pidfile "$PIDFILE" \
|
|
--exec "$MDNSD" -- $MDNSD_ARGS
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf "Stopping %s: " "$DAEMON"
|
|
start-stop-daemon --stop --pidfile "$PIDFILE" \
|
|
--exec "$MDNSD"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
return "$status"
|
|
fi
|
|
# mdnsd deletes its PID file on exit, wait for it to be gone
|
|
while [ -f "$PIDFILE" ]; do
|
|
sleep 0.1
|
|
done
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
# SIGHUP reloads /etc/mdns.d/*.service
|
|
reload() {
|
|
printf 'Reloading %s: ' "$DAEMON"
|
|
start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \
|
|
--exec "$MDNSD"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart|reload)
|
|
"$1"
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
;;
|
|
esac
|