ganeti.initd.in 1.91 KB
Newer Older
1
#!/bin/sh
Iustin Pop's avatar
Iustin Pop committed
2 3 4
# 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
DESC="Ganeti cluster"
7 8 9 10
NAME=ganeti-noded
NODED=@PREFIX@/sbin/ganeti-noded
MASTER=@PREFIX@/sbin/ganeti-master
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
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() {
17 18 19 20
    for fname in \
        "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
        "@LOCALSTATEDIR@/lib/ganeti/server.pem"
    do
Michael Hanselmann's avatar
Michael Hanselmann committed
21 22 23 24 25 26
        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
27 28
}

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
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
45
case "$1" in
Michael Hanselmann's avatar
Michael Hanselmann committed
46
    start)
47
        log_daemon_msg "Starting $DESC" "$NAME"
Michael Hanselmann's avatar
Michael Hanselmann committed
48
        check_config
49 50 51 52 53 54
        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
55 56
    ;;
    stop)
57 58 59 60 61 62 63
        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
64 65
    ;;
    restart|force-reload)
66
        log_daemon_msg "Reloading $DESC"
Michael Hanselmann's avatar
Michael Hanselmann committed
67 68
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
        check_config
69 70 71 72 73 74
        start-stop-daemon --start --quiet --exec $NODED
        log_end_msg $?

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

exit 0
Michael Hanselmann's avatar
Michael Hanselmann committed
82 83

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