5f76ea2e3d4610a0b1b57dafed0599d9d9cb87bf
[archipelago] / debian / archipelago.init.d
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          archipelago
4 # Required-Start:    $network $local_fs $remote_fs
5 # Required-Stop:     $remote_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: <Enter a short description of the sortware>
9 # Description:       <Enter a long description of the software>
10 #                    <...>
11 #                    <...>
12 ### END INIT INFO
13
14 # Author: philipgian<philipgian@grnet.gr>
15
16 # PATH should only include /usr/* if it runs after the mountnfs.sh script */
17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
18 DESC=archipelago            # Introduce a short description here
19 NAME=archipelago            # Introduce the short server's name here
20 DAEMON=/usr/bin/archipelago # Introduce the server's location here
21 DAEMON_ARGS=""              # Arguments to run the daemon with
22 #PIDFILE=/var/run/$NAME.pid
23 SCRIPTNAME=/etc/init.d/$NAME
24
25 # Exit if the package is not installed
26 [ -x $DAEMON ] || exit 0
27
28 # Read configuration variable file if it is present
29 #[ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
31 # Load the VERBOSE setting and other rcS variables
32 . /lib/init/vars.sh
33
34 # Define LSB log_* functions.
35 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
36 . /lib/lsb/init-functions
37
38 #
39 # Function that starts the daemon/service
40 #
41 do_start()
42 {
43         $DAEMON start && return 0
44 }
45
46 #
47 # Function that stops the daemon/service
48 #
49 do_stop()
50 {
51         $DAEMON stop && return 0
52 }
53
54
55 case "$1" in
56   start)
57         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
58         do_start
59         case "$?" in
60                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
61                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
62         esac
63         ;;
64   stop)
65         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
66         do_stop
67         case "$?" in
68                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
69                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
70         esac
71         ;;
72   status)
73        $DAEMON status
74        ;;
75   restart|force-reload)
76         #
77         # If the "reload" option is implemented then remove the
78         # 'force-reload' alias
79         #
80         log_daemon_msg "Restarting $DESC" "$NAME"
81         do_stop
82         case "$?" in
83           0|1)
84                 do_start
85                 case "$?" in
86                         0) log_end_msg 0 ;;
87                         1) log_end_msg 1 ;; # Old process is still running
88                         *) log_end_msg 1 ;; # Failed to start
89                 esac
90                 ;;
91           *)
92                 # Failed to stop
93                 log_end_msg 1
94                 ;;
95         esac
96         ;;
97   *)
98         echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
99         exit 3
100         ;;
101 esac
102