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

Last change on this file since 853 was 844, checked in by y_z, 16 years ago

generate issue.net.no_tkt from debian init script

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/bash
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    {
41        for i in $(invirt-getconf --ls hosts); do
42            local hostname=$(invirt-getconf hosts.$i.hostname)
43            echo "#include /etc/conserver/conf.d/$hostname"
44        done
45    } > /etc/conserver/invirt-hosts.cf
46    local realm=$(invirt-getconf authn.0.realm)
47    {
48        for i in $(invirt-getconf --ls hosts); do
49            local hostname=$(invirt-getconf hosts.$i.hostname)
50            echo "host/$hostname@$realm"
51        done
52    } > /etc/remctl/acl/invirt-console
53
54    cat > /etc/nss-pgsql.conf << EOF
55host            = $(invirt-getconf db.host)
56port            = $(invirt-getconf db.port)
57database        = $(invirt-getconf db.dbname)
58login           = $(invirt-getconf db.user)
59
60querypasswd = SELECT name, NULL, machine_id + 1000 as uid, machine_id + 1000 as gid, '', '/consolefs/'|| name, '/usr/bin/sipb-xen-consolesh' FROM machines
61querygroup = SELECT name, NULL, machine_id + 1000 as gid FROM machines
62querymembers = SELECT name FROM machines WHERE 1000 + machine_id = %d
63queryids = SELECT 1000 + machine_id AS gid FROM machines LIMIT 0
64
65passwd_name = name
66passwd_uid = 1000 + machine_id
67
68group_name = name
69group_gid = 1000 + machine_id
70EOF
71
72    fmt > /etc/issue.net.no_tkt << EOF
73You must login to the $(invirt-getconf console.hostname) console server using
74Kerberos tickets, but your ssh client did not pass a valid ticket to the
75console server.
76EOF
77}
78
79#
80# Function that starts the daemon/service
81#
82do_start()
83{
84        # Return
85        #   0 if daemon has been started
86        #   1 if daemon was already running
87        #   2 if daemon could not be started
88        modprobe fuse
89        gen_config
90        daemon --running -n $NAME && return 1
91        daemon -r -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2
92}
93
94#
95# Function that stops the daemon/service
96#
97do_stop()
98{
99        # Return
100        #   0 if daemon has been stopped
101        #   1 if daemon was already stopped
102        #   2 if daemon could not be stopped
103        #   other if a failure occurred
104        daemon --stop -n $NAME
105        RETVAL="$?"
106        [ "$RETVAL" = 2 ] && return 2
107        # Many daemons don't delete their pidfiles when they exit.
108        rm -f $PIDFILE
109        umount "$DAEMON_ARGS"
110        return "$RETVAL"
111}
112
113do_reload()
114{
115        gen_config
116        /etc/init.d/conserver-server reload
117}
118
119case "$1" in
120  start)
121        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
122        do_start
123        case "$?" in
124                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
125                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
126        esac
127        ;;
128  stop)
129        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
130        do_stop
131        case "$?" in
132                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
133                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
134        esac
135        ;;
136  reload|force-reload)
137        log_daemon_msg "Reloading $DESC" "$NAME"
138        do_reload
139        log_end_msg $?
140        ;;
141  restart)
142        log_daemon_msg "Restarting $DESC" "$NAME"
143        do_stop
144        case "$?" in
145          0|1)
146                do_start
147                case "$?" in
148                        0) log_end_msg 0 ;;
149                        1) log_end_msg 1 ;; # Old process is still running
150                        *) log_end_msg 1 ;; # Failed to start
151                esac
152                ;;
153          *)
154                # Failed to stop
155                log_end_msg 1
156                ;;
157        esac
158        ;;
159  *)
160        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
161        exit 3
162        ;;
163esac
164
165:
Note: See TracBrowser for help on using the repository browser.