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

Last change on this file since 884 was 815, checked in by price, 16 years ago

sipb-xen-console-server is totally configurable

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#! /bin/sh
2### BEGIN INIT INFO
3# Provides:          sipb-xen-console-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: conserver config from invirt config for invirt host
9# Description:       
10### END INIT INFO
11
12# Author: Invirt/XVM Project, MIT SIPB <invirt@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="Invirt host console config"
19NAME=sipb-xen-console-server
20SCRIPTNAME=/etc/init.d/$NAME
21
22# Read configuration variable file if it is present
23[ -r /etc/default/$NAME ] && . /etc/default/$NAME
24
25# Load the VERBOSE setting and other rcS variables
26. /lib/init/vars.sh
27
28# Define LSB log_* functions.
29# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
30. /lib/lsb/init-functions
31
32gen_config()
33{
34        console_ip=$(invirt-getconf console.ip)
35        cat >/etc/conserver/invirt-genconfig.cf <<EOF
36access * {
37       trusted 127.0.0.1;
38       trusted $console_ip;
39       limited *;
40}
41EOF
42}
43
44#
45# Function that starts the daemon/service
46#
47do_start()
48{
49        # Return
50        #   0 if daemon has been started
51        #   1 if daemon was already running
52        #   2 if daemon could not be started
53        gen_config
54        VERBOSE=no /etc/init.d/conserver-server reload
55}
56
57#
58# Function that stops the daemon/service
59#
60do_stop()
61{
62        return 1
63}
64
65do_reload()
66{
67        gen_config
68        VERBOSE=no /etc/init.d/conserver-server reload
69}
70
71case "$1" in
72  start)
73        [ "$VERBOSE" != no ] && log_begin_msg "Starting $DESC" "$NAME"
74        do_start
75        case "$?" in
76                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
77                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
78        esac
79        ;;
80  stop)
81        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
82        do_stop
83        case "$?" in
84                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
85                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
86        esac
87        ;;
88  reload|force-reload)
89        log_daemon_msg "Reloading $DESC" "$NAME"
90        do_reload
91        log_end_msg $?
92        ;;
93  restart)
94        log_daemon_msg "Restarting $DESC" "$NAME"
95        do_stop
96        case "$?" in
97          0|1)
98                do_start
99                case "$?" in
100                        0) log_end_msg 0 ;;
101                        1) log_end_msg 1 ;; # Old process is still running
102                        *) log_end_msg 1 ;; # Failed to start
103                esac
104                ;;
105          *)
106                # Failed to stop
107                log_end_msg 1
108                ;;
109        esac
110        ;;
111  *)
112        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
113        exit 3
114        ;;
115esac
116
117:
Note: See TracBrowser for help on using the repository browser.