root / doc / examples / ganeti.initd.in @ 26c7e094
History | View | Annotate | Download (1.9 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 | a8083063 | Iustin Pop | |
5 | 880478f8 | Iustin Pop | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin |
6 | 9bd7f742 | Iustin Pop | DESC="Ganeti cluster" |
7 | c1671c0e | Michael Hanselmann | NAME=ganeti-noded |
8 | c1671c0e | Michael Hanselmann | NODED=@PREFIX@/sbin/ganeti-noded |
9 | c1671c0e | Michael Hanselmann | MASTER=@PREFIX@/sbin/ganeti-master |
10 | c1671c0e | Michael Hanselmann | SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti |
11 | a8083063 | Iustin Pop | |
12 | 9bd7f742 | Iustin Pop | test -f $NODED || exit 0 |
13 | a8083063 | Iustin Pop | |
14 | a8083063 | Iustin Pop | . /lib/lsb/init-functions |
15 | a8083063 | Iustin Pop | |
16 | a8083063 | Iustin Pop | check_config() { |
17 | c1671c0e | Michael Hanselmann | for fname in \ |
18 | c1671c0e | Michael Hanselmann | "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \ |
19 | c1671c0e | Michael Hanselmann | "@LOCALSTATEDIR@/lib/ganeti/server.pem" |
20 | c1671c0e | Michael Hanselmann | do |
21 | 3c9a0742 | Michael Hanselmann | if ! [ -f "$fname" ]; then |
22 | 3c9a0742 | Michael Hanselmann | log_end_msg 0 |
23 | 3c9a0742 | Michael Hanselmann | log_warning_msg "Config $fname not there, will not run." |
24 | 3c9a0742 | Michael Hanselmann | exit 0 |
25 | 3c9a0742 | Michael Hanselmann | fi |
26 | 3c9a0742 | Michael Hanselmann | done |
27 | a8083063 | Iustin Pop | } |
28 | a8083063 | Iustin Pop | |
29 | 9bd7f742 | Iustin Pop | master_action() { |
30 | 9bd7f742 | Iustin Pop | log_action_begin_msg "ganeti-master"; $MASTER "$1" |
31 | 9bd7f742 | Iustin Pop | RC=$? |
32 | 9bd7f742 | Iustin Pop | case $RC in |
33 | 9bd7f742 | Iustin Pop | 0) |
34 | 9bd7f742 | Iustin Pop | log_action_end_msg 0 |
35 | 9bd7f742 | Iustin Pop | ;; |
36 | 9bd7f742 | Iustin Pop | 11) |
37 | 9bd7f742 | Iustin Pop | log_action_end_msg 0 "not master" |
38 | 9bd7f742 | Iustin Pop | ;; |
39 | 9bd7f742 | Iustin Pop | *) |
40 | 9bd7f742 | Iustin Pop | log_action_end_msg 1 "exit code $RC" |
41 | 9bd7f742 | Iustin Pop | ;; |
42 | 9bd7f742 | Iustin Pop | esac |
43 | 9bd7f742 | Iustin Pop | } |
44 | 9bd7f742 | Iustin Pop | |
45 | a8083063 | Iustin Pop | case "$1" in |
46 | 3c9a0742 | Michael Hanselmann | start) |
47 | 9bd7f742 | Iustin Pop | log_daemon_msg "Starting $DESC" "$NAME" |
48 | 3c9a0742 | Michael Hanselmann | check_config |
49 | 9bd7f742 | Iustin Pop | if start-stop-daemon --start --quiet --exec $NODED; then |
50 | 9bd7f742 | Iustin Pop | log_end_msg 0 |
51 | 9bd7f742 | Iustin Pop | else |
52 | 9bd7f742 | Iustin Pop | log_end_msg 1 |
53 | 9bd7f742 | Iustin Pop | fi |
54 | 9bd7f742 | Iustin Pop | master_action start |
55 | 3c9a0742 | Michael Hanselmann | ;; |
56 | 3c9a0742 | Michael Hanselmann | stop) |
57 | 9bd7f742 | Iustin Pop | log_daemon_msg "Stopping $DESC" "$NAME" |
58 | 9bd7f742 | Iustin Pop | if start-stop-daemon --stop --quiet --name $NAME; then |
59 | 9bd7f742 | Iustin Pop | log_end_msg 0 |
60 | 9bd7f742 | Iustin Pop | else |
61 | 9bd7f742 | Iustin Pop | log_end_msg 1 |
62 | 9bd7f742 | Iustin Pop | fi |
63 | 9bd7f742 | Iustin Pop | master_action stop |
64 | 3c9a0742 | Michael Hanselmann | ;; |
65 | 3c9a0742 | Michael Hanselmann | restart|force-reload) |
66 | 9bd7f742 | Iustin Pop | log_daemon_msg "Reloading $DESC" |
67 | 3c9a0742 | Michael Hanselmann | start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME |
68 | 3c9a0742 | Michael Hanselmann | check_config |
69 | 9bd7f742 | Iustin Pop | start-stop-daemon --start --quiet --exec $NODED |
70 | 9bd7f742 | Iustin Pop | log_end_msg $? |
71 | 9bd7f742 | Iustin Pop | |
72 | 9bd7f742 | Iustin Pop | $MASTER stop |
73 | 9bd7f742 | Iustin Pop | master_action start |
74 | 9bd7f742 | Iustin Pop | ;; |
75 | 3c9a0742 | Michael Hanselmann | *) |
76 | 3c9a0742 | Michael Hanselmann | log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}" |
77 | 3c9a0742 | Michael Hanselmann | exit 1 |
78 | 3c9a0742 | Michael Hanselmann | ;; |
79 | a8083063 | Iustin Pop | esac |
80 | a8083063 | Iustin Pop | |
81 | a8083063 | Iustin Pop | exit 0 |
82 | 3c9a0742 | Michael Hanselmann | |
83 | 3c9a0742 | Michael Hanselmann | # vim: set sw=4 sts=4 et foldmethod=marker : |