| 1 | #!/bin/sh |
| 2 | ### BEGIN INIT INFO |
| 3 | # Provides: ashd |
| 4 | # Required-Start: $local_fs $remote_fs $network $syslog |
| 5 | # Required-Stop: $local_fs $remote_fs $network $syslog |
| 6 | # Default-Start: 2 3 4 5 |
| 7 | # Default-Stop: 0 1 6 |
| 8 | # Short-Description: The ashd HTTP server |
| 9 | ### END INIT INFO |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | . /lib/lsb/init-functions |
| 14 | |
| 15 | PATH=/usr/local/bin:/usr/local/sbin:$PATH |
| 16 | HTPARSER="$(which htparser || true)" |
| 17 | PIDFILE=/var/run/ashd.pid |
| 18 | PORTSPEC="plain" |
| 19 | ROOTSPEC="dirplex /srv/www" |
| 20 | [ -r /etc/default/locale ] && . /etc/default/locale |
| 21 | [ -r /etc/default/ashd ] && . /etc/default/ashd |
| 22 | [ -x "$HTPARSER" ] || exit 0 |
| 23 | |
| 24 | start() { |
| 25 | export LANG |
| 26 | log_daemon_msg "Starting HTTP server" "ashd" |
| 27 | ulimit -c unlimited |
| 28 | start-stop-daemon -S -p "$PIDFILE" -qx "$HTPARSER" -- -Sf -p "$PIDFILE" -u nobody -r /var/tmp $PORTSPEC -- $ROOTSPEC |
| 29 | log_end_msg $? |
| 30 | } |
| 31 | |
| 32 | stop() { |
| 33 | log_daemon_msg "Stopping HTTP server" "ashd" |
| 34 | start-stop-daemon -K -p "$PIDFILE" -qx "$HTPARSER" |
| 35 | log_end_msg $? |
| 36 | } |
| 37 | |
| 38 | case "$1" in |
| 39 | start) |
| 40 | start |
| 41 | ;; |
| 42 | stop) |
| 43 | stop |
| 44 | ;; |
| 45 | restart) |
| 46 | stop |
| 47 | start |
| 48 | ;; |
| 49 | esac |
| 50 | |
| 51 | exit 0 |