1 | #! /bin/sh |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: xvm-iscsi-config |
---|
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: XVM iSCSI config |
---|
9 | # Description: Re-generate the iSCSI config for XVM's shared storage |
---|
10 | ### END INIT INFO |
---|
11 | |
---|
12 | # Author: SIPB XVM Project <xvm@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="Re-generate the iSCSI config" |
---|
19 | NAME=xvm-iscsi-config |
---|
20 | |
---|
21 | # Read configuration variable file if it is present |
---|
22 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME |
---|
23 | |
---|
24 | # Load the VERBOSE setting and other rcS variables |
---|
25 | . /lib/init/vars.sh |
---|
26 | |
---|
27 | # Define LSB log_* functions. |
---|
28 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. |
---|
29 | . /lib/lsb/init-functions |
---|
30 | |
---|
31 | # |
---|
32 | # Function that starts the daemon/service |
---|
33 | # |
---|
34 | do_start() |
---|
35 | { |
---|
36 | # Return |
---|
37 | # 0 if daemon has been started |
---|
38 | # 1 if daemon was already running |
---|
39 | # 2 if daemon could not be started |
---|
40 | for i in /etc/iscsi/iscsid.conf.xvm |
---|
41 | do mako-render $i.mako > $i |
---|
42 | done |
---|
43 | } |
---|
44 | |
---|
45 | # |
---|
46 | # Function that stops the daemon/service |
---|
47 | # |
---|
48 | do_stop() |
---|
49 | { |
---|
50 | # Return |
---|
51 | # 0 if daemon has been stopped |
---|
52 | # 1 if daemon was already stopped |
---|
53 | # 2 if daemon could not be stopped |
---|
54 | # other if a failure occurred |
---|
55 | return 0 |
---|
56 | } |
---|
57 | |
---|
58 | case "$1" in |
---|
59 | start) |
---|
60 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
---|
61 | do_start |
---|
62 | case "$?" in |
---|
63 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
64 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
65 | esac |
---|
66 | ;; |
---|
67 | stop) |
---|
68 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
---|
69 | do_stop |
---|
70 | case "$?" in |
---|
71 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
---|
72 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
---|
73 | esac |
---|
74 | ;; |
---|
75 | restart|force-reload) |
---|
76 | log_daemon_msg "Restarting $DESC" "$NAME" |
---|
77 | do_stop |
---|
78 | case "$?" in |
---|
79 | 0|1) |
---|
80 | do_start |
---|
81 | case "$?" in |
---|
82 | 0) log_end_msg 0 ;; |
---|
83 | 1) log_end_msg 1 ;; # Old process is still running |
---|
84 | *) log_end_msg 1 ;; # Failed to start |
---|
85 | esac |
---|
86 | ;; |
---|
87 | *) |
---|
88 | # Failed to stop |
---|
89 | log_end_msg 1 |
---|
90 | ;; |
---|
91 | esac |
---|
92 | ;; |
---|
93 | *) |
---|
94 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
---|
95 | exit 3 |
---|
96 | ;; |
---|
97 | esac |
---|
98 | |
---|
99 | : |
---|