source: package_tags/invirt-console-server/0.1.1/debian/invirt-console-server.init @ 2932

Last change on this file since 2932 was 1742, checked in by broder, 16 years ago

Switch to using std-init in invirt-console-server

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/bin/bash
2### BEGIN INIT INFO
3# Provides:          invirt-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: Invirt console proxy server
9# Description:       
10### END INIT INFO
11
12# Author: Invirt project <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="the Invirt console server"
19NAME=invirt-console-server
20DAEMON=/usr/bin/invirt-consolefs
21MOUNTPOINT="/consolefs"
22DAEMON_ARGS="-f $MOUNTPOINT"
23PIDFILE=/var/run/$NAME.pid
24SCRIPTNAME=/etc/init.d/$NAME
25
26# Exit if the package is not installed
27[ -x "$DAEMON" ] || exit 0
28
29. /lib/init/std-init.sh
30
31gen_config()
32{
33    for i in /etc/conserver/invirt-hosts.cf \
34             /etc/remctl/acl/invirt-console-server \
35             /etc/issue.net.no_tkt \
36             /etc/nss-pgsql.conf \
37             ; do
38        mako-render $i.mako > $i
39    done
40}
41
42#
43# Function that starts the daemon/service
44#
45do_start()
46{
47    # Return
48    #   0 if daemon has been started
49    #   1 if daemon was already running
50    #   2 if daemon could not be started
51   
52    # Try to make sure fuse is setup
53    [ -e /dev/fuse ] || modprobe fuse || return 2
54   
55    if cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then
56        return 1
57    fi
58   
59    gen_config
60   
61    daemon -r -O daemon.info -E daemon.err -n $NAME -- $DAEMON $DAEMON_ARGS || return 2
62}
63
64#
65# Function that stops the daemon/service
66#
67do_stop()
68{
69    # Return
70    #   0 if daemon has been stopped
71    #   1 if daemon was already stopped
72    #   2 if daemon could not be stopped
73    #   other if a failure occurred
74   
75    if ! cat /proc/mounts | grep " $MOUNTPOINT " >/dev/null 2>&1; then
76        return 1
77    fi
78   
79    daemon --stop -n $NAME
80    RETVAL="$?"
81    [ "$RETVAL" = 2 ] && return 2
82    # Many daemons don't delete their pidfiles when they exit.
83    rm -f $PIDFILE
84}
85
86do_reload()
87{
88    gen_config
89    invoke-rc.d conserver-server reload
90}
91
92std_init "$1"
Note: See TracBrowser for help on using the repository browser.