Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd.in @ 40dacb4d

History | View | Annotate | Download (2.7 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:      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
MASTERD_NAME=ganeti-masterd
20
MASTERD="@PREFIX@/sbin/$MASTERD_NAME"
21
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
22

    
23
test -f $NODED || exit 0
24

    
25
. /lib/lsb/init-functions
26

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

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

    
56
case "$1" in
57
    start)
58
        log_daemon_msg "Starting $DESC" "$NAME"
59
        check_config
60
        if start-stop-daemon --start --quiet --exec $NODED; then
61
            log_end_msg 0
62
        else
63
            log_end_msg 1
64
        fi
65
        master_action start
66
        if start-stop-daemon --start --quiet --exec $MASTERD; then
67
            log_end_msg 0
68
        else
69
            log_end_msg 1
70
        fi
71
     ;;
72
    stop)
73
        log_daemon_msg "Stopping $DESC" "$NAME"
74
        if start-stop-daemon --stop --quiet --name $NAME; then
75
            log_end_msg 0
76
        else
77
            log_end_msg 1
78
        fi
79
        if start-stop-daemon --stop --quiet --name $MASTERD_NAME; then
80
            log_end_msg 0
81
        else
82
            log_end_msg 1
83
        fi
84
         master_action stop
85
    ;;
86
    restart|force-reload)
87
        log_daemon_msg "Reloading $DESC"
88
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
89
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $MASTERD_NAME
90
        check_config
91
        start-stop-daemon --start --quiet --exec $NODED
92
        start-stop-daemon --start --quiet --exec $MASTERD
93
        log_end_msg $?
94

    
95
        $MASTER stop
96
        master_action start
97
     ;;
98
    *)
99
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
100
        exit 1
101
    ;;
102
esac
103

    
104
exit 0