Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd @ 7c18ef8e

History | View | Annotate | Download (1.9 kB)

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