S90httpd 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. DAEMON="httpd"
  3. PIDFILE="/var/run/$DAEMON.pid"
  4. HTTPD_ARGS="-h /var/www/data"
  5. # shellcheck source=/dev/null
  6. [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
  7. # BusyBox' httpd does not create a pidfile, so pass "-f" in the command line
  8. # and use "--make-pidfile" to instruct start-stop-daemon to create one.
  9. start() {
  10. printf 'Starting %s: ' "$DAEMON"
  11. # shellcheck disable=SC2086 # we need the word splitting
  12. start-stop-daemon --start --background --quiet --make-pidfile \
  13. --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
  14. -- -f $HTTPD_ARGS
  15. status=$?
  16. if [ "$status" -eq 0 ]; then
  17. echo "OK"
  18. else
  19. echo "FAIL"
  20. fi
  21. return "$status"
  22. }
  23. stop() {
  24. printf 'Stopping %s: ' "$DAEMON"
  25. start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
  26. status=$?
  27. if [ "$status" -eq 0 ]; then
  28. echo "OK"
  29. else
  30. echo "FAIL"
  31. fi
  32. while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
  33. --exec "/usr/sbin/$DAEMON"; do
  34. sleep 0.1
  35. done
  36. rm -f "$PIDFILE"
  37. return "$status"
  38. }
  39. restart() {
  40. stop
  41. start
  42. }
  43. case "$1" in
  44. start|stop|restart)
  45. "$1";;
  46. reload)
  47. # Restart, since there is no true "reload" feature.
  48. restart;;
  49. *)
  50. echo "Usage: $0 {start|stop|restart|reload}"
  51. exit 1
  52. esac