ganeti.initd 1.86 KB
Newer Older
Iustin Pop's avatar
Iustin Pop committed
1
2
3
4
#! /bin/sh
# ganeti node daemon starter script
# based on skeleton from Debian GNU/Linux

5
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
6
7
NODED=/usr/local/sbin/ganeti-noded
MASTER=/usr/local/sbin/ganeti-master
Iustin Pop's avatar
Iustin Pop committed
8
9
NAME=ganeti-noded
SCRIPTNAME=/etc/init.d/ganeti
10
DESC="Ganeti cluster"
Iustin Pop's avatar
Iustin Pop committed
11

12
test -f $NODED || exit 0
Iustin Pop's avatar
Iustin Pop committed
13
14
15
16

. /lib/lsb/init-functions

check_config() {
Michael Hanselmann's avatar
Michael Hanselmann committed
17
18
19
20
21
22
23
    for fname in /var/lib/ganeti/ssconf_node_pass /var/lib/ganeti/server.pem; do
        if ! [ -f "$fname" ]; then
            log_end_msg 0
            log_warning_msg "Config $fname not there, will not run."
            exit 0
        fi
    done
Iustin Pop's avatar
Iustin Pop committed
24
25
}

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
master_action() {
    log_action_begin_msg "ganeti-master"; $MASTER "$1"
    RC=$?
    case $RC in
        0)
            log_action_end_msg 0
            ;;
        11)
            log_action_end_msg 0 "not master"
            ;;
        *)
            log_action_end_msg 1 "exit code $RC"
            ;;
    esac
}

Iustin Pop's avatar
Iustin Pop committed
42
case "$1" in
Michael Hanselmann's avatar
Michael Hanselmann committed
43
    start)
44
        log_daemon_msg "Starting $DESC" "$NAME"
Michael Hanselmann's avatar
Michael Hanselmann committed
45
        check_config
46
47
48
49
50
51
        if start-stop-daemon --start --quiet --exec $NODED; then
            log_end_msg 0
        else
            log_end_msg 1
        fi
        master_action start
Michael Hanselmann's avatar
Michael Hanselmann committed
52
53
    ;;
    stop)
54
55
56
57
58
59
60
        log_daemon_msg "Stopping $DESC" "$NAME"
        if start-stop-daemon --stop --quiet --name $NAME; then
            log_end_msg 0
        else
            log_end_msg 1
        fi
        master_action stop
Michael Hanselmann's avatar
Michael Hanselmann committed
61
62
    ;;
    restart|force-reload)
63
        log_daemon_msg "Reloading $DESC"
Michael Hanselmann's avatar
Michael Hanselmann committed
64
65
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
        check_config
66
67
68
69
70
71
        start-stop-daemon --start --quiet --exec $NODED
        log_end_msg $?

        $MASTER stop
        master_action start
     ;;
Michael Hanselmann's avatar
Michael Hanselmann committed
72
73
74
75
    *)
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
        exit 1
    ;;
Iustin Pop's avatar
Iustin Pop committed
76
77
78
esac

exit 0
Michael Hanselmann's avatar
Michael Hanselmann committed
79
80

# vim: set sw=4 sts=4 et foldmethod=marker :