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

Last change on this file since 834 was 800, checked in by price, 16 years ago

use invirt-getconf to generate config in sipb-xen-console

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