Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd @ 04daec5d

History | View | Annotate | Download (1.9 kB)

1
#! /bin/sh
2
# ganeti node daemon starter script
3
# based on skeleton from Debian GNU/Linux
4

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

    
12
test -f $NODED || exit 0
13

    
14
. /lib/lsb/init-functions
15

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

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

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

    
69
        $MASTER stop
70
        master_action start
71
     ;;
72
    *)
73
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
74
        exit 1
75
    ;;
76
esac
77

    
78
exit 0
79

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