summaryrefslogtreecommitdiff
blob: 924f7e60eb4d4a906bed327c4f6b875850d770f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/ganeti/files/ganeti2.initd,v 1.1 2009/10/02 22:12:19 ramereth Exp $

depend() {
    need localmount drbd
    after bootmisc
}

checkconfig() {
    for fname in /var/lib/ganeti/server.pem
    do
        if [[ ! -f "$fname" ]]
        then
            eerror "Config file $fname not found, will not run."
            return 1
        fi
    done

    return 0
}

start_action() {
    # called as start_action daemon pidfile
    local daemon="${1}"; shift
    local pidfile="${1}"; shift
    ebegin "Starting ${daemon}"
    start-stop-daemon --start --quiet --exec "${daemon}" --pidfile "${pidfile}" \
        -- "${@}"
    eend ${?}
}

stop_action() {
    # called as stop_action daemon pidfile
    ebegin "Stopping ${1}"
    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "${2}"
    eend ${?}
}


start() {
    checkconfig || return 1
    start_action /usr/sbin/ganeti-noded /var/run/ganeti/ganeti-noded.pid
    start_action /usr/sbin/ganeti-masterd /var/run/ganeti/ganeti-masterd.pid
    start_action /usr/sbin/ganeti-rapi /var/run/ganeti/ganeti-rapi.pid
    return 0
}

stop() {
    stop_action /usr/sbin/ganeti-rapi /var/run/ganeti/ganeti-rapi.pid
    stop_action /usr/sbin/ganeti-masterd /var/run/ganeti/ganeti-masterd.pid
    stop_action /usr/sbin/ganeti-noded /var/run/ganeti/ganeti-noded.pid
    return 0
}