mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 21:43:30 +08:00
fc7488e99f
The init script provided by thttpd is for FreeBSD. Add a custom one, made specifically for Buildroot. Signed-off-by: Carlos Santos <unixmania@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
55 lines
932 B
Bash
55 lines
932 B
Bash
#!/bin/sh
|
|
|
|
DAEMON="thttpd"
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
THTTPD_ARGS="-C /etc/thttpd.conf"
|
|
|
|
# shellcheck source=/dev/null
|
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
|
|
|
start() {
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
# shellcheck disable=SC2086 # we need the word splitting
|
|
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
|
-- $THTTPD_ARGS
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf 'Stopping %s: ' "$DAEMON"
|
|
start-stop-daemon -K -q -p "$PIDFILE"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
# thttpd does not remove the pid file on exit
|
|
rm -f "$PIDFILE"
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
sleep 1
|
|
start
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart)
|
|
"$1";;
|
|
reload)
|
|
# Restart, since there is no true "reload" feature.
|
|
restart;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|