blob: 501563ca8795093c3f2e1fa9cda9146afc8ec4ba (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
depend() {
need localmount logger
after bootmisc sshd
use net
}
DAEMON_UTIL="/usr/lib/ganeti/daemon-util"
is_master() {
[ -z "${ganeti_master}" ] && ganeti_master="$(gnt-cluster getmaster)"
[ -z "${local_hostname}" ] && local_hostname="$(hostname -f)"
[ "${ganeti_master}" = "${local_hostname}" ]
}
start() {
if ! [ -e ${DAEMON_UTIL} ]; then
eerror "Could not find daemon utility at ${DAEMON_UTIL}"
return 1
elif ! ${DAEMON_UTIL} check-config ; then
eerror "Incomplete configuration, will not run."
return 1
fi
local daemon retval=0 optsvar started_daemons daemon_opts
for daemon in $(${DAEMON_UTIL} list-start-daemons); do
optsvar="${daemon//-/_}"
case "${daemon#ganeti-}" in
masterd|rapi|luxid) is_master || continue;;
esac
eval daemon_opts=\"\$\{${optsvar^^*}_OPTS\}\"
ebegin "Starting ${daemon}"
eindent
${DAEMON_UTIL} start ${daemon} ${GANETI_OPTS} ${daemon_opts} || retval=${?}
if [ ${retval} != 0 ] && [ -n "${started_daemons}" ]; then
case ${daemon} in
*-kvmd) retval=0; ewarn "Failed to start kvmd, continuing anyway";;
*)
eerror "Stopping already started daemons"
eindent
eend ${code} "$(${DAEMON_UTIL} check-exitcode ${code})"
for daemon in ${started_daemons}; do
ebegin "Stopping ${daemon}"
${DAEMON_UTIL} stop ${daemon} ${GANETI_OPTS}
eend ${?}
done
eoutdent; eoutdent
return ${retval}
;;
esac
fi
eoutdent
started_daemons="${started_daemons} ${daemon}"
done
}
stop() {
if ! [ -e ${DAEMON_UTIL} ]; then
eerror "Could not find daemon utility at ${DAEMON_UTIL}"
return 1
fi
local daemon
for daemon in $(${DAEMON_UTIL} list-stop-daemons) ; do \
case "${daemon#ganeti-}" in
masterd|rapi|luxid) is_master || continue;;
esac
${DAEMON_UTIL} stop ${daemon} ${GANETI_OPTS}
done
}
# vim:ft=gentoo-init-d:ts=4:sts=4:sw=4:noet:
|