S90thttpd 932 B

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