source: trunk/packages/invirt-dns/debian/invirt-dns.init @ 1274

Last change on this file since 1274 was 1223, checked in by broder, 16 years ago

Standardize on "Invirt project" in invirt-dns

File size: 2.8 KB
RevLine 
[268]1#! /bin/sh
2### BEGIN INIT INFO
[1184]3# Provides:          invirt-dns
[268]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
[1184]8# Short-Description: Invirt DNS server
[268]9# Description:       
10### END INIT INFO
11
[1223]12# Author: Invirt project <invirt@mit.edu>
[268]13
14# Do NOT "set -e"
15
16# PATH should only include /usr/* if it runs after the mountnfs.sh script
17PATH=/sbin:/usr/sbin:/bin:/usr/bin
[1184]18DESC="the Invirt DNS server"
19NAME=invirt-dns
20DAEMON=/usr/sbin/invirt-dns
[269]21DAEMON_ARGS=""
[268]22PIDFILE=/var/run/$NAME.pid
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. /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#
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
[269]47        daemon --running -n $NAME && return 1
[319]48        daemon -r -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2
[268]49}
50
51#
52# Function that stops the daemon/service
53#
54do_stop()
55{
56        # Return
57        #   0 if daemon has been stopped
58        #   1 if daemon was already stopped
59        #   2 if daemon could not be stopped
60        #   other if a failure occurred
[269]61        daemon --stop -n $NAME
[268]62        RETVAL="$?"
63        [ "$RETVAL" = 2 ] && return 2
64        # Many daemons don't delete their pidfiles when they exit.
65        rm -f $PIDFILE
66        return "$RETVAL"
67}
68
69case "$1" in
70  start)
71        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
72        do_start
73        case "$?" in
74                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
75                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
76        esac
77        ;;
78  stop)
79        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
80        do_stop
81        case "$?" in
82                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
83                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
84        esac
85        ;;
86  #reload|force-reload)
87        #
88        # If do_reload() is not implemented then leave this commented out
89        # and leave 'force-reload' as an alias for 'restart'.
90        #
91        #log_daemon_msg "Reloading $DESC" "$NAME"
92        #do_reload
93        #log_end_msg $?
94        #;;
95  restart|force-reload)
96        #
97        # If the "reload" option is implemented then remove the
98        # 'force-reload' alias
99        #
100        log_daemon_msg "Restarting $DESC" "$NAME"
101        do_stop
102        case "$?" in
103          0|1)
104                do_start
105                case "$?" in
106                        0) log_end_msg 0 ;;
107                        1) log_end_msg 1 ;; # Old process is still running
108                        *) log_end_msg 1 ;; # Failed to start
109                esac
110                ;;
111          *)
112                # Failed to stop
113                log_end_msg 1
114                ;;
115        esac
116        ;;
117  *)
118        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
119        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
120        exit 3
121        ;;
122esac
123
124:
Note: See TracBrowser for help on using the repository browser.