[815] | 1 | #! /bin/sh |
---|
| 2 | ### BEGIN INIT INFO |
---|
[1187] | 3 | # Provides: invirt-console-host |
---|
[815] | 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 |
---|
| 17 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
---|
| 18 | DESC="Invirt host console config" |
---|
[1187] | 19 | NAME=invirt-console-host |
---|
[815] | 20 | SCRIPTNAME=/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 | |
---|
| 32 | gen_config() |
---|
| 33 | { |
---|
[889] | 34 | for i in /etc/conserver/invirt-genconfig.cf |
---|
| 35 | do mako-render $i.mako > $i |
---|
| 36 | done |
---|
[815] | 37 | } |
---|
| 38 | |
---|
| 39 | # |
---|
| 40 | # Function that starts the daemon/service |
---|
| 41 | # |
---|
| 42 | do_start() |
---|
| 43 | { |
---|
| 44 | # Return |
---|
| 45 | # 0 if daemon has been started |
---|
| 46 | # 1 if daemon was already running |
---|
| 47 | # 2 if daemon could not be started |
---|
| 48 | gen_config |
---|
| 49 | VERBOSE=no /etc/init.d/conserver-server reload |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | # |
---|
| 53 | # Function that stops the daemon/service |
---|
| 54 | # |
---|
| 55 | do_stop() |
---|
| 56 | { |
---|
| 57 | return 1 |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | do_reload() |
---|
| 61 | { |
---|
| 62 | gen_config |
---|
| 63 | VERBOSE=no /etc/init.d/conserver-server reload |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | case "$1" in |
---|
| 67 | start) |
---|
| 68 | [ "$VERBOSE" != no ] && log_begin_msg "Starting $DESC" "$NAME" |
---|
| 69 | do_start |
---|
| 70 | case "$?" in |
---|
| 71 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 72 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 73 | esac |
---|
| 74 | ;; |
---|
| 75 | stop) |
---|
| 76 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
---|
| 77 | do_stop |
---|
| 78 | case "$?" in |
---|
| 79 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 80 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 81 | esac |
---|
| 82 | ;; |
---|
| 83 | reload|force-reload) |
---|
| 84 | log_daemon_msg "Reloading $DESC" "$NAME" |
---|
| 85 | do_reload |
---|
| 86 | log_end_msg $? |
---|
| 87 | ;; |
---|
| 88 | restart) |
---|
| 89 | log_daemon_msg "Restarting $DESC" "$NAME" |
---|
| 90 | do_stop |
---|
| 91 | case "$?" in |
---|
| 92 | 0|1) |
---|
| 93 | do_start |
---|
| 94 | case "$?" in |
---|
| 95 | 0) log_end_msg 0 ;; |
---|
| 96 | 1) log_end_msg 1 ;; # Old process is still running |
---|
| 97 | *) log_end_msg 1 ;; # Failed to start |
---|
| 98 | esac |
---|
| 99 | ;; |
---|
| 100 | *) |
---|
| 101 | # Failed to stop |
---|
| 102 | log_end_msg 1 |
---|
| 103 | ;; |
---|
| 104 | esac |
---|
| 105 | ;; |
---|
| 106 | *) |
---|
| 107 | echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 |
---|
| 108 | exit 3 |
---|
| 109 | ;; |
---|
| 110 | esac |
---|
| 111 | |
---|
| 112 | : |
---|