#!/sbin/runscript # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/app-emulation/ganeti/files/ganeti-2.1.initd,v 1.4 2011/08/09 06:57:04 ramereth Exp $ depend() { need localmount after bootmisc } DAEMON_UTIL="/usr/lib/ganeti/daemon-util" check_config() { if ! $DAEMON_UTIL check-config ; then eend 0 "Incomplete configuration, will not run." fi } check_exitcode() { RC=${1} if errmsg=$(${DAEMON_UTIL} check-exitcode ${RC}) ; then eend 0 "${errmsg}" else eend 1 "${errmsg}" fi } start_action() { # called as start_action daemon-name local daemon="${1}" ebegin "Starting ${daemon}" ${DAEMON_UTIL} start "${@}" check_exitcode ${?} } stop_action() { # called as stop_action daemon-name local daemon="${1}" ebegin "Stopping ${daemon}" ${DAEMON_UTIL} stop "${@}" check_exitcode ${?} } maybe_do() { requested="${1}"; shift action="${1}"; shift target="${1}" if [ -z "${requested}" -o "${requested}" = "${target}" ] ; then ${action} "${@}" fi } start_all() { check_config for i in $($DAEMON_UTIL list-start-daemons); do \ case "${i}" in ganeti-masterd) GANETI_OPTS="${GANETI_OPTS} ${GANETI_MASTERD_OPTS}" ;; ganeti-rapid) GANETI_OPTS="${GANETI_OPTS} ${GANETI_RAPI_OPTS}" ;; esac maybe_do "${1}" start_action ${i} ${GANETI_OPTS} done } stop_all() { for i in $($DAEMON_UTIL list-stop-daemons) ; do \ maybe_do "${1}" stop_action ${i} done } start() { start_all } stop() { stop_all }