source: trunk/packages/sipb-xen-console/debian/sipb-xen-console.init @ 706

Last change on this file since 706 was 699, checked in by price, 16 years ago

generate console config from /etc/invirt/* at start/reload

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#! /bin/sh
2### BEGIN INIT INFO
3# Provides:          sipb-xen-console
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: sipb-xen Console Server homedir filesystem
9# Description:       
10### END INIT INFO
11
12# Author: SIPB Xen Project <sipb-xen@mit.edu>
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
18DESC="The sipb-xen console server"
19NAME=sipb-xen-console
20DAEMON=/usr/bin/sipb-xen-consolefs
21DAEMON_ARGS="/consolefs"
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
38gen_config()
39{
40        perl -pe 's|^|#include /etc/conserver/conf.d/|' \
41            </etc/invirt/hosts >/etc/conserver/invirt-hosts.cf
42        INVIRT_REALM="$(cat /etc/invirt/realm)"
43        perl -pe "s|^|host/|; s|\$|\@$INVIRT_REALM|" \
44            </etc/invirt/hosts >/etc/remctl/acl/invirt-console
45}
46
47#
48# Function that starts the daemon/service
49#
50do_start()
51{
52        # Return
53        #   0 if daemon has been started
54        #   1 if daemon was already running
55        #   2 if daemon could not be started
56        modprobe fuse
57        gen_config
58        daemon --running -n $NAME && return 1
59        daemon -r -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2
60}
61
62#
63# Function that stops the daemon/service
64#
65do_stop()
66{
67        # Return
68        #   0 if daemon has been stopped
69        #   1 if daemon was already stopped
70        #   2 if daemon could not be stopped
71        #   other if a failure occurred
72        daemon --stop -n $NAME
73        RETVAL="$?"
74        [ "$RETVAL" = 2 ] && return 2
75        # Many daemons don't delete their pidfiles when they exit.
76        rm -f $PIDFILE
77        umount "$DAEMON_ARGS"
78        return "$RETVAL"
79}
80
81do_reload()
82{
83        gen_config
84        /etc/init.d/conserver-server reload
85}
86
87case "$1" in
88  start)
89        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
90        do_start
91        case "$?" in
92                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
93                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
94        esac
95        ;;
96  stop)
97        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
98        do_stop
99        case "$?" in
100                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
101                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
102        esac
103        ;;
104  reload|force-reload)
105        log_daemon_msg "Reloading $DESC" "$NAME"
106        do_reload
107        log_end_msg $?
108        ;;
109  restart)
110        log_daemon_msg "Restarting $DESC" "$NAME"
111        do_stop
112        case "$?" in
113          0|1)
114                do_start
115                case "$?" in
116                        0) log_end_msg 0 ;;
117                        1) log_end_msg 1 ;; # Old process is still running
118                        *) log_end_msg 1 ;; # Failed to start
119                esac
120                ;;
121          *)
122                # Failed to stop
123                log_end_msg 1
124                ;;
125        esac
126        ;;
127  *)
128        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
129        exit 3
130        ;;
131esac
132
133:
Note: See TracBrowser for help on using the repository browser.