source: trunk/third/moira/debian/debathena-moira-update-server.init @ 23178

Revision 23178, 3.3 KB checked in by broder, 16 years ago (diff)
Take a new snapshot from CVS for Moira, and add a debathena-moira-update-server package
  • Property svn:executable set to *
Line 
1#! /bin/sh
2### BEGIN INIT INFO
3# Provides:          debathena-moira-update-server
4# Required-Start:    $local_fs $remote_fs
5# Required-Stop:     $local_fs $remote_fs
6# Default-Start:     2 3 4 5
7# Default-Stop:      0 1 6
8# Short-Description: Moira update_server
9# Description:       The moira update_server program for taking updates from
10#                    moira
11### END INIT INFO
12
13# Author: Evan Broder <broder@mit.edu>
14
15# Do NOT "set -e"
16
17# PATH should only include /usr/* if it runs after the mountnfs.sh script
18PATH=/usr/sbin:/usr/bin:/sbin:/bin
19DESC="Moira update_server"
20NAME=debathena-moira-update-server
21DAEMON=/usr/sbin/update_server
22DAEMON_ARGS=""
23SCRIPTNAME=/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[ -f /etc/default/rcS ] && . /etc/default/rcS
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#
41do_start()
42{
43        # Return
44        #   0 if daemon has been started
45        #   1 if daemon was already running
46        #   2 if daemon could not be started
47        start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
48                || return 1
49        start-stop-daemon --start --quiet --exec $DAEMON -- \
50                $DAEMON_ARGS \
51                || return 2
52        # Add code here, if necessary, that waits for the process to be ready
53        # to handle requests from services started subsequently which depend
54        # on this one.  As a last resort, sleep for some time.
55}
56
57#
58# Function that stops the daemon/service
59#
60do_stop()
61{
62        # Return
63        #   0 if daemon has been stopped
64        #   1 if daemon was already stopped
65        #   2 if daemon could not be stopped
66        #   other if a failure occurred
67        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
68        RETVAL="$?"
69        [ "$RETVAL" = 2 ] && return 2
70        # Wait for children to finish too if this is a daemon that forks
71        # and if the daemon is only ever run from this initscript.
72        # If the above conditions are not satisfied then add some other code
73        # that waits for the process to drop all resources that could be
74        # needed by services started subsequently.  A last resort is to
75        # sleep for some time.
76        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
77        [ "$?" = 2 ] && return 2
78        return "$RETVAL"
79}
80
81case "$1" in
82  start)
83        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
84        do_start
85        case "$?" in
86                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
87                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
88        esac
89        ;;
90  stop)
91        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
92        do_stop
93        case "$?" in
94                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
95                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
96        esac
97        ;;
98  restart|force-reload)
99        #
100        # If the "reload" option is implemented then remove the
101        # 'force-reload' alias
102        #
103        log_daemon_msg "Restarting $DESC" "$NAME"
104        do_stop
105        case "$?" in
106          0|1)
107                do_start
108                case "$?" in
109                        0) log_end_msg 0 ;;
110                        1) log_end_msg 1 ;; # Old process is still running
111                        *) log_end_msg 1 ;; # Failed to start
112                esac
113                ;;
114          *)
115                # Failed to stop
116                log_end_msg 1
117                ;;
118        esac
119        ;;
120  *)
121        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
122        exit 3
123        ;;
124esac
125
126:
Note: See TracBrowser for help on using the repository browser.