Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd.in @ c1671c0e

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
DESC="Ganeti cluster"
7
NAME=ganeti-noded
8
NODED=@PREFIX@/sbin/ganeti-noded
9
MASTER=@PREFIX@/sbin/ganeti-master
10
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
11

    
12
test -f $NODED || exit 0
13

    
14
. /lib/lsb/init-functions
15

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

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

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

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

    
81
exit 0
82

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