Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd.in @ 24d48647

History | View | Annotate | Download (2.2 kB)

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

    
14
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
15
DESC="Ganeti cluster"
16
NAME=ganeti-noded
17
NODED=@PREFIX@/sbin/ganeti-noded
18
MASTER=@PREFIX@/sbin/ganeti-master
19
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
20

    
21
test -f $NODED || exit 0
22

    
23
. /lib/lsb/init-functions
24

    
25
check_config() {
26
    for fname in \
27
        "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
28
        "@LOCALSTATEDIR@/lib/ganeti/server.pem"
29
    do
30
        if ! [ -f "$fname" ]; then
31
            log_end_msg 0
32
            log_warning_msg "Config $fname not there, will not run."
33
            exit 0
34
        fi
35
    done
36
}
37

    
38
master_action() {
39
    log_action_begin_msg "ganeti-master"; $MASTER "$1"
40
    RC=$?
41
    case $RC in
42
        0)
43
            log_action_end_msg 0
44
            ;;
45
        11)
46
            log_action_end_msg 0 "not master"
47
            ;;
48
        *)
49
            log_action_end_msg 1 "exit code $RC"
50
            ;;
51
    esac
52
}
53

    
54
case "$1" in
55
    start)
56
        log_daemon_msg "Starting $DESC" "$NAME"
57
        check_config
58
        if start-stop-daemon --start --quiet --exec $NODED; then
59
            log_end_msg 0
60
        else
61
            log_end_msg 1
62
        fi
63
        master_action start
64
    ;;
65
    stop)
66
        log_daemon_msg "Stopping $DESC" "$NAME"
67
        if start-stop-daemon --stop --quiet --name $NAME; then
68
            log_end_msg 0
69
        else
70
            log_end_msg 1
71
        fi
72
        master_action stop
73
    ;;
74
    restart|force-reload)
75
        log_daemon_msg "Reloading $DESC"
76
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
77
        check_config
78
        start-stop-daemon --start --quiet --exec $NODED
79
        log_end_msg $?
80

    
81
        $MASTER stop
82
        master_action start
83
     ;;
84
    *)
85
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
86
        exit 1
87
    ;;
88
esac
89

    
90
exit 0
91

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