xref: /OK3568_Linux_fs/buildroot/package/thttpd/S90thttpd (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3DAEMON="thttpd"
4PIDFILE="/var/run/$DAEMON.pid"
5
6THTTPD_ARGS="-C /etc/thttpd.conf"
7
8# shellcheck source=/dev/null
9[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
10
11start() {
12	printf 'Starting %s: ' "$DAEMON"
13	# shellcheck disable=SC2086 # we need the word splitting
14	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
15		-- $THTTPD_ARGS
16	status=$?
17	if [ "$status" -eq 0 ]; then
18		echo "OK"
19	else
20		echo "FAIL"
21	fi
22	return "$status"
23}
24
25stop() {
26	printf 'Stopping %s: ' "$DAEMON"
27	start-stop-daemon -K -q -p "$PIDFILE"
28	status=$?
29	if [ "$status" -eq 0 ]; then
30		# thttpd does not remove the pid file on exit
31		rm -f "$PIDFILE"
32		echo "OK"
33	else
34		echo "FAIL"
35	fi
36	return "$status"
37}
38
39restart() {
40	stop
41	sleep 1
42	start
43}
44
45case "$1" in
46	start|stop|restart)
47		"$1";;
48	reload)
49		# Restart, since there is no true "reload" feature.
50		restart;;
51	*)
52		echo "Usage: $0 {start|stop|restart|reload}"
53		exit 1
54esac
55