initscript: lift out DESCRIPTION
[hippotat] / debian / hippotat.init
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides: hippotatd
5 # Required-Start: $syslog $network userv
6 # Required-Stop: $syslog $network
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 # Short-Description: hippotatd
10 # Description: Asinine IP over HTTP server
11 ### END INIT INFO
12
13 DAEMON=/usr/sbin/hippotat
14 MASTER_CONFIG=/etc/hippotat/master.cfg
15 USER=Debian-hippotat
16 PIDFILE=/var/run/hippotat/hippotatd.pid
17 LOGFACILITY=daemon
18 # HIPPOTATD_ARGS
19 DESCRIPTION='Asinine IP over HTTP server'
20
21 . /etc/default/hippotatd
22
23 test -f $DAEMON || exit 0
24 egrep '^[^ #]' $MASTER_CONFIG >/dev/null 2>&1 || exit 0
25
26 . /lib/lsb/init-functions
27
28 ssd () {
29 set +e
30 start-stop-daemon --start --quiet --user $USER --pidfile=$PIDFILE "$@"
31 rc=$?
32 set -e
33 }
34 ensure_dirs () {
35 pidfiledir=${PIDFILE%/*}
36 if test -d ${pidfiledir}; then return; fi
37 mkdir -m 755 $pidfiledir
38 chown $USER $pidfiledir
39 }
40
41 do_start () {
42 ensure_dirs
43 ssd --chuid $USER --startas \
44 $DAEMON --daemon --pidfile=$PIDFILE \
45 --syslog-facility=$LOGFACILITY $HIPPOTATD_ARGS
46 }
47 do_stop () {
48 ssd --stop --retry 5
49 }
50
51 case "$1" in
52 start)
53 log_daemon_msg "Starting $DESCRIPTION" hippotatd
54 do_start
55 log_end_msg $rc
56 ;;
57
58 stop)
59 log_daemon_msg "Stopping $DESCRIPTION" hippotatd
60 do_stop
61 log_end_msg $rc
62 ;;
63
64 restart|force-reload)
65 log_daemon_msg "Restarting $DESCRIPTION" hippotatd
66 do_stop
67 sleep 1
68 do_start
69 log_end_msg $rc
70 ;;
71
72 reload)
73 log_failure_msg "Cannot reload hippotat - need restart"
74 exit 1
75 ;;
76
77 *)
78 echo >&2 "$0: unknown action $1"
79 exit 1
80 ;;
81
82 esac
83
84 exit 0