[834] | 1 | #! /bin/bash |
---|
[815] | 2 | ### BEGIN INIT INFO |
---|
[834] | 3 | # Provides: sipb-xen-remctl-auto |
---|
[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" |
---|
[834] | 19 | NAME=sipb-xen-remctl-auto |
---|
[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 | { |
---|
[834] | 34 | echo "host/$(invirt-getconf remote.hostname)@$(invirt-getconf authn.0.realm)" \ |
---|
| 35 | > /etc/remctl/acl/remote |
---|
[815] | 36 | } |
---|
| 37 | |
---|
| 38 | # |
---|
| 39 | # Function that starts the daemon/service |
---|
| 40 | # |
---|
| 41 | do_start() |
---|
| 42 | { |
---|
| 43 | # Return |
---|
| 44 | # 0 if daemon has been started |
---|
| 45 | # 1 if daemon was already running |
---|
| 46 | # 2 if daemon could not be started |
---|
| 47 | gen_config |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | # |
---|
| 51 | # Function that stops the daemon/service |
---|
| 52 | # |
---|
| 53 | do_stop() |
---|
| 54 | { |
---|
[834] | 55 | return 0 |
---|
[815] | 56 | } |
---|
| 57 | |
---|
| 58 | do_reload() |
---|
| 59 | { |
---|
| 60 | gen_config |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | case "$1" in |
---|
| 64 | start) |
---|
| 65 | [ "$VERBOSE" != no ] && log_begin_msg "Starting $DESC" "$NAME" |
---|
| 66 | do_start |
---|
| 67 | case "$?" in |
---|
| 68 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 69 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 70 | esac |
---|
| 71 | ;; |
---|
| 72 | stop) |
---|
| 73 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
---|
| 74 | do_stop |
---|
| 75 | case "$?" in |
---|
| 76 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
| 77 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
| 78 | esac |
---|
| 79 | ;; |
---|
| 80 | reload|force-reload) |
---|
| 81 | log_daemon_msg "Reloading $DESC" "$NAME" |
---|
| 82 | do_reload |
---|
| 83 | log_end_msg $? |
---|
| 84 | ;; |
---|
| 85 | restart) |
---|
| 86 | log_daemon_msg "Restarting $DESC" "$NAME" |
---|
| 87 | do_stop |
---|
| 88 | case "$?" in |
---|
| 89 | 0|1) |
---|
| 90 | do_start |
---|
| 91 | case "$?" in |
---|
| 92 | 0) log_end_msg 0 ;; |
---|
| 93 | 1) log_end_msg 1 ;; # Old process is still running |
---|
| 94 | *) log_end_msg 1 ;; # Failed to start |
---|
| 95 | esac |
---|
| 96 | ;; |
---|
| 97 | *) |
---|
| 98 | # Failed to stop |
---|
| 99 | log_end_msg 1 |
---|
| 100 | ;; |
---|
| 101 | esac |
---|
| 102 | ;; |
---|
| 103 | *) |
---|
| 104 | echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 |
---|
| 105 | exit 3 |
---|
| 106 | ;; |
---|
| 107 | esac |
---|
| 108 | |
---|
| 109 | : |
---|