ganeti.initd.in 2.3 KB
Newer Older
1
#!/bin/sh
Iustin Pop's avatar
Iustin Pop committed
2
3
# ganeti node daemon starter script
# based on skeleton from Debian GNU/Linux
4
5
6
7
8
9
10
11
12
### BEGIN INIT INFO
# Provides:          ganeti
# Required-Start:    $syslog $remote_fs xend
# Required-Stop:     $syslog $remote_fs xend
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Ganeti Xen Cluster Manager
# Description:       Ganeti Xen Cluster Manager 
### END INIT INFO
Iustin Pop's avatar
Iustin Pop committed
13

14
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
15
DESC="Ganeti cluster"
16
17
18
19
NAME=ganeti-noded
NODED=@PREFIX@/sbin/ganeti-noded
MASTER=@PREFIX@/sbin/ganeti-master
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
20
RUNDIR="@LOCALSTATEDIR@/run/ganeti"
Iustin Pop's avatar
Iustin Pop committed
21

22
test -f $NODED || exit 0
Iustin Pop's avatar
Iustin Pop committed
23
24
25
26

. /lib/lsb/init-functions

check_config() {
27
28
29
30
    for fname in \
        "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
        "@LOCALSTATEDIR@/lib/ganeti/server.pem"
    do
Michael Hanselmann's avatar
Michael Hanselmann committed
31
32
33
34
35
36
        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
37
38
}

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
55
case "$1" in
Michael Hanselmann's avatar
Michael Hanselmann committed
56
    start)
57
        log_daemon_msg "Starting $DESC" "$NAME"
Michael Hanselmann's avatar
Michael Hanselmann committed
58
        check_config
59
        test -e "$RUNDIR" || mkdir -p "$RUNDIR"
60
61
62
63
64
65
        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
66
67
    ;;
    stop)
68
69
70
71
72
73
74
        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
75
76
    ;;
    restart|force-reload)
77
        log_daemon_msg "Reloading $DESC"
Michael Hanselmann's avatar
Michael Hanselmann committed
78
79
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
        check_config
80
81
82
83
84
85
        start-stop-daemon --start --quiet --exec $NODED
        log_end_msg $?

        $MASTER stop
        master_action start
     ;;
Michael Hanselmann's avatar
Michael Hanselmann committed
86
87
88
89
    *)
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
        exit 1
    ;;
Iustin Pop's avatar
Iustin Pop committed
90
91
92
esac

exit 0
Michael Hanselmann's avatar
Michael Hanselmann committed
93
94

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