package/thttpd: fix init script
authorCarlos Santos <unixmania@gmail.com>
Sun, 15 Sep 2019 00:06:57 +0000 (21:06 -0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sun, 15 Sep 2019 12:37:54 +0000 (14:37 +0200)
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>
package/thttpd/S90thttpd [new file with mode: 0644]
package/thttpd/thttpd.mk

diff --git a/package/thttpd/S90thttpd b/package/thttpd/S90thttpd
new file mode 100644 (file)
index 0000000..94b079b
--- /dev/null
@@ -0,0 +1,54 @@
+#!/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
index 29611fff2cd6bc79455ac5e73d62715e84f81484..a028e48cb4eee02dc4ebfd3166bcbff95a007a79 100644 (file)
@@ -28,8 +28,8 @@ define THTTPD_INSTALL_TARGET_CMDS
 endef
 
 define THTTPD_INSTALL_INIT_SYSV
-       $(INSTALL) -D -m 0755 $(@D)/scripts/thttpd.sh $(TARGET_DIR)/etc/init.d/S90thttpd
-       $(SED) 's:/usr/local/sbin:/usr/sbin:g' $(TARGET_DIR)/etc/init.d/S90thttpd
+       $(INSTALL) -D -m 0755 package/thttpd/S90thttpd \
+               $(TARGET_DIR)/etc/init.d/S90thttpd
 endef
 
 define THTTPD_INSTALL_INIT_SYSTEMD