#!/sbin/runscript extra_started_commands="reload" depend() { need net } chkconfig() { [ -z "${ROLES}" ] && { eerror "No role defined !"; return 1;} for ROLE in ${ROLES}; do if [ ! -f /etc/mfs/${ROLE}.cfg ]; then eerror "Missing configuration file for role ${ROLE} !" return 1 fi done return 0 } autorestore() { einfo "AUTORESTORE set, trying to restore metadata files" mfsmetarestore -a &>/dev/null return $? } start_role() { local ROLE=$1 local RETURN=0 ebegin "${ROLE}" start-stop-daemon -q --start --exec "${ROLE}" -- start >/dev/null RETURN=$? eend ${RETURN} return ${RETURN} } start_roles() { local RETURN=0 eindent for ROLE in ${ROLES}; do start_role ${ROLE} || RETURN=$? eend ${RETURN} if [ "${RETURN}" != "0" ] && [ "${ROLE}" == "mfsmaster" ] && [ ${AUTORESTORE} -eq 1 ]; then eindent autorestore && start_role ${ROLE} RETURN=$? eoutdent fi [ "${RETURN}" != "0" ] && break done eoutdent return ${RETURN} } start() { ebegin "Starting mfs node" chkconfig && start_roles eend $? } stop() { local RETURN=0 ebegin "Stopping mfs node" eindent local REVERSE=$(echo ${ROLES} | tac -s' ') for ROLE in ${REVERSE}; do ebegin "${ROLE}" start-stop-daemon -q --stop -n ${ROLE} || RETURN=$? eend ${RETURN} done eoutdent eend ${RETURN} } reload() { local RETURN=0 ebegin "Reloading mfs node" eindent for ROLE in ${ROLES}; do ebegin "${ROLE}" start-stop-daemon --signal HUP -n ${ROLE} eend ${RETURN} done eoutdent eend ${RETURN} }