03c498bcd2b4c94cfc09822b7cafe0324b4e9bec
[pazpar2-moved-to-github.git] / debian / pazpar2.init
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          pazpar2
4 # Required-Start:    $local_fs $remote_fs $network $named $time
5 # Required-Stop:     $local_fs $remote_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: Pazpar2 server
9 # Description:       Debian init script for the Pazpar2 server
10 ### END INIT INFO
11
12 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
13 DAEMON=/usr/sbin/pazpar2
14 NAME=pazpar2
15 DESC=pazpar2
16
17 test -x $DAEMON || exit 0
18
19 # Include pazpar2 defaults if available
20 if [ -f /etc/default/pazpar2 ] ; then
21         . /etc/default/pazpar2
22 fi
23
24 set -e
25
26 case "$1" in
27   start)
28         echo -n "Starting $DESC: "
29         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
30                 --exec $DAEMON -- $DAEMON_OPTS
31         echo "$NAME."
32         ;;
33   stop)
34         echo -n "Stopping $DESC: "
35         start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/$NAME.pid \
36                 --exec $DAEMON
37         echo "$NAME."
38         ;;
39   #reload)
40         #
41         #       If the daemon can reload its config files on the fly
42         #       for example by sending it SIGHUP, do it here.
43         #
44         #       If the daemon responds to changes in its config file
45         #       directly anyway, make this a do-nothing entry.
46         #
47         # echo "Reloading $DESC configuration files."
48         # start-stop-daemon --stop --signal 1 --quiet --pidfile \
49         #       /var/run/$NAME.pid --exec $DAEMON
50   #;;
51   force-reload)
52         #
53         #       If the "reload" option is implemented, move the "force-reload"
54         #       option to the "reload" entry above. If not, "force-reload" is
55         #       just the same as "restart" except that it does nothing if the
56         #   daemon isn't already running.
57         # check wether $DAEMON is running. If so, restart
58         start-stop-daemon --stop --test --quiet --pidfile \
59                 /var/run/$NAME.pid --exec $DAEMON \
60         && $0 restart \
61         || exit 0
62         ;;
63   restart)
64     echo -n "Restarting $DESC: "
65         start-stop-daemon --stop --quiet --oknodo --pidfile \
66                 /var/run/$NAME.pid --exec $DAEMON
67         sleep 1
68         start-stop-daemon --start --quiet --pidfile \
69                 /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
70         echo "$NAME."
71         ;;
72   *)
73         N=/etc/init.d/$NAME
74         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
75         echo "Usage: $N {start|stop|restart|force-reload}" >&2
76         exit 1
77         ;;
78 esac
79
80 exit 0