root / doc / examples / ganeti.initd.in @ b81ef751
History | View | Annotate | Download (2.3 kB)
1 | c1671c0e | Michael Hanselmann | #!/bin/sh |
---|---|---|---|
2 | a8083063 | Iustin Pop | # ganeti node daemon starter script |
3 | a8083063 | Iustin Pop | # based on skeleton from Debian GNU/Linux |
4 | 24d48647 | Guido Trotter | ### BEGIN INIT INFO |
5 | 24d48647 | Guido Trotter | # Provides: ganeti |
6 | 24d48647 | Guido Trotter | # Required-Start: $syslog $remote_fs xend |
7 | 24d48647 | Guido Trotter | # Required-Stop: $syslog $remote_fs xend |
8 | 24d48647 | Guido Trotter | # Default-Start: 2 3 4 5 |
9 | 24d48647 | Guido Trotter | # Default-Stop: S 0 1 6 |
10 | 24d48647 | Guido Trotter | # Short-Description: Ganeti Xen Cluster Manager |
11 | 24d48647 | Guido Trotter | # Description: Ganeti Xen Cluster Manager |
12 | 24d48647 | Guido Trotter | ### END INIT INFO |
13 | a8083063 | Iustin Pop | |
14 | 880478f8 | Iustin Pop | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin |
15 | 9bd7f742 | Iustin Pop | DESC="Ganeti cluster" |
16 | c1671c0e | Michael Hanselmann | NAME=ganeti-noded |
17 | c1671c0e | Michael Hanselmann | NODED=@PREFIX@/sbin/ganeti-noded |
18 | c1671c0e | Michael Hanselmann | MASTER=@PREFIX@/sbin/ganeti-master |
19 | c1671c0e | Michael Hanselmann | SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti |
20 | b81ef751 | Iustin Pop | RUNDIR="@LOCALSTATEDIR@/run/ganeti" |
21 | a8083063 | Iustin Pop | |
22 | 9bd7f742 | Iustin Pop | test -f $NODED || exit 0 |
23 | a8083063 | Iustin Pop | |
24 | a8083063 | Iustin Pop | . /lib/lsb/init-functions |
25 | a8083063 | Iustin Pop | |
26 | a8083063 | Iustin Pop | check_config() { |
27 | c1671c0e | Michael Hanselmann | for fname in \ |
28 | c1671c0e | Michael Hanselmann | "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \ |
29 | c1671c0e | Michael Hanselmann | "@LOCALSTATEDIR@/lib/ganeti/server.pem" |
30 | c1671c0e | Michael Hanselmann | do |
31 | 3c9a0742 | Michael Hanselmann | if ! [ -f "$fname" ]; then |
32 | 3c9a0742 | Michael Hanselmann | log_end_msg 0 |
33 | 3c9a0742 | Michael Hanselmann | log_warning_msg "Config $fname not there, will not run." |
34 | 3c9a0742 | Michael Hanselmann | exit 0 |
35 | 3c9a0742 | Michael Hanselmann | fi |
36 | 3c9a0742 | Michael Hanselmann | done |
37 | a8083063 | Iustin Pop | } |
38 | a8083063 | Iustin Pop | |
39 | 9bd7f742 | Iustin Pop | master_action() { |
40 | 9bd7f742 | Iustin Pop | log_action_begin_msg "ganeti-master"; $MASTER "$1" |
41 | 9bd7f742 | Iustin Pop | RC=$? |
42 | 9bd7f742 | Iustin Pop | case $RC in |
43 | 9bd7f742 | Iustin Pop | 0) |
44 | 9bd7f742 | Iustin Pop | log_action_end_msg 0 |
45 | 9bd7f742 | Iustin Pop | ;; |
46 | 9bd7f742 | Iustin Pop | 11) |
47 | 9bd7f742 | Iustin Pop | log_action_end_msg 0 "not master" |
48 | 9bd7f742 | Iustin Pop | ;; |
49 | 9bd7f742 | Iustin Pop | *) |
50 | 9bd7f742 | Iustin Pop | log_action_end_msg 1 "exit code $RC" |
51 | 9bd7f742 | Iustin Pop | ;; |
52 | 9bd7f742 | Iustin Pop | esac |
53 | 9bd7f742 | Iustin Pop | } |
54 | 9bd7f742 | Iustin Pop | |
55 | a8083063 | Iustin Pop | case "$1" in |
56 | 3c9a0742 | Michael Hanselmann | start) |
57 | 9bd7f742 | Iustin Pop | log_daemon_msg "Starting $DESC" "$NAME" |
58 | 3c9a0742 | Michael Hanselmann | check_config |
59 | b81ef751 | Iustin Pop | test -e "$RUNDIR" || mkdir -p "$RUNDIR" |
60 | 9bd7f742 | Iustin Pop | if start-stop-daemon --start --quiet --exec $NODED; then |
61 | 9bd7f742 | Iustin Pop | log_end_msg 0 |
62 | 9bd7f742 | Iustin Pop | else |
63 | 9bd7f742 | Iustin Pop | log_end_msg 1 |
64 | 9bd7f742 | Iustin Pop | fi |
65 | 9bd7f742 | Iustin Pop | master_action start |
66 | 3c9a0742 | Michael Hanselmann | ;; |
67 | 3c9a0742 | Michael Hanselmann | stop) |
68 | 9bd7f742 | Iustin Pop | log_daemon_msg "Stopping $DESC" "$NAME" |
69 | 9bd7f742 | Iustin Pop | if start-stop-daemon --stop --quiet --name $NAME; then |
70 | 9bd7f742 | Iustin Pop | log_end_msg 0 |
71 | 9bd7f742 | Iustin Pop | else |
72 | 9bd7f742 | Iustin Pop | log_end_msg 1 |
73 | 9bd7f742 | Iustin Pop | fi |
74 | 9bd7f742 | Iustin Pop | master_action stop |
75 | 3c9a0742 | Michael Hanselmann | ;; |
76 | 3c9a0742 | Michael Hanselmann | restart|force-reload) |
77 | 9bd7f742 | Iustin Pop | log_daemon_msg "Reloading $DESC" |
78 | 3c9a0742 | Michael Hanselmann | start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME |
79 | 3c9a0742 | Michael Hanselmann | check_config |
80 | 9bd7f742 | Iustin Pop | start-stop-daemon --start --quiet --exec $NODED |
81 | 9bd7f742 | Iustin Pop | log_end_msg $? |
82 | 9bd7f742 | Iustin Pop | |
83 | 9bd7f742 | Iustin Pop | $MASTER stop |
84 | 9bd7f742 | Iustin Pop | master_action start |
85 | 9bd7f742 | Iustin Pop | ;; |
86 | 3c9a0742 | Michael Hanselmann | *) |
87 | 3c9a0742 | Michael Hanselmann | log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}" |
88 | 3c9a0742 | Michael Hanselmann | exit 1 |
89 | 3c9a0742 | Michael Hanselmann | ;; |
90 | a8083063 | Iustin Pop | esac |
91 | a8083063 | Iustin Pop | |
92 | a8083063 | Iustin Pop | exit 0 |
93 | 3c9a0742 | Michael Hanselmann | |
94 | 3c9a0742 | Michael Hanselmann | # vim: set sw=4 sts=4 et foldmethod=marker : |