[843] | 1 | #!/bin/bash |
---|
[335] | 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 |
---|
| 17 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
---|
[699] | 18 | DESC="The sipb-xen console server" |
---|
[335] | 19 | NAME=sipb-xen-console |
---|
| 20 | DAEMON=/usr/bin/sipb-xen-consolefs |
---|
| 21 | DAEMON_ARGS="/consolefs" |
---|
| 22 | PIDFILE=/var/run/$NAME.pid |
---|
| 23 | SCRIPTNAME=/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 | |
---|
[699] | 38 | gen_config() |
---|
| 39 | { |
---|
[888] | 40 | for i in /etc/conserver/invirt-hosts.cf \ |
---|
| 41 | /etc/remctl/acl/invirt-console \ |
---|
| 42 | /etc/issue.net.no_tkt \ |
---|
| 43 | /etc/nss-pgsql.conf \ |
---|
| 44 | ; do |
---|
| 45 | mako-render $i.mako > $i |
---|
| 46 | done |
---|
[699] | 47 | } |
---|
| 48 | |
---|
[335] | 49 | # |
---|
| 50 | # Function that starts the daemon/service |
---|
| 51 | # |
---|
| 52 | do_start() |
---|
| 53 | { |
---|
| 54 | # Return |
---|
| 55 | # 0 if daemon has been started |
---|
| 56 | # 1 if daemon was already running |
---|
| 57 | # 2 if daemon could not be started |
---|
[380] | 58 | modprobe fuse |
---|
[699] | 59 | gen_config |
---|
[335] | 60 | daemon --running -n $NAME && return 1 |
---|
| 61 | daemon -r -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2 |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | # |
---|
| 65 | # Function that stops the daemon/service |
---|
| 66 | # |
---|
| 67 | do_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 | daemon --stop -n $NAME |
---|
| 75 | RETVAL="$?" |
---|
| 76 | [ "$RETVAL" = 2 ] && return 2 |
---|
| 77 | # Many daemons don't delete their pidfiles when they exit. |
---|
| 78 | rm -f $PIDFILE |
---|
[344] | 79 | umount "$DAEMON_ARGS" |
---|
[335] | 80 | return "$RETVAL" |
---|
| 81 | } |
---|
| 82 | |
---|
[699] | 83 | do_reload() |
---|
| 84 | { |
---|
| 85 | gen_config |
---|
| 86 | /etc/init.d/conserver-server reload |
---|
| 87 | } |
---|
| 88 | |
---|
[335] | 89 | case "$1" in |
---|
| 90 | start) |
---|
| 91 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
---|
| 92 | do_start |
---|
| 93 | case "$?" in |
---|
| 94 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 95 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 96 | esac |
---|
| 97 | ;; |
---|
| 98 | stop) |
---|
| 99 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
---|
| 100 | do_stop |
---|
| 101 | case "$?" in |
---|
| 102 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 103 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 104 | esac |
---|
| 105 | ;; |
---|
[699] | 106 | reload|force-reload) |
---|
| 107 | log_daemon_msg "Reloading $DESC" "$NAME" |
---|
| 108 | do_reload |
---|
| 109 | log_end_msg $? |
---|
| 110 | ;; |
---|
| 111 | restart) |
---|
[335] | 112 | log_daemon_msg "Restarting $DESC" "$NAME" |
---|
| 113 | do_stop |
---|
| 114 | case "$?" in |
---|
| 115 | 0|1) |
---|
| 116 | do_start |
---|
| 117 | case "$?" in |
---|
| 118 | 0) log_end_msg 0 ;; |
---|
| 119 | 1) log_end_msg 1 ;; # Old process is still running |
---|
| 120 | *) log_end_msg 1 ;; # Failed to start |
---|
| 121 | esac |
---|
| 122 | ;; |
---|
| 123 | *) |
---|
| 124 | # Failed to stop |
---|
| 125 | log_end_msg 1 |
---|
| 126 | ;; |
---|
| 127 | esac |
---|
| 128 | ;; |
---|
| 129 | *) |
---|
[699] | 130 | echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 |
---|
[335] | 131 | exit 3 |
---|
| 132 | ;; |
---|
| 133 | esac |
---|
| 134 | |
---|
| 135 | : |
---|