diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-cluster/moosefs/files/mfs.initd-r1 |
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-cluster/moosefs/files/mfs.initd-r1')
-rw-r--r-- | sys-cluster/moosefs/files/mfs.initd-r1 | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/sys-cluster/moosefs/files/mfs.initd-r1 b/sys-cluster/moosefs/files/mfs.initd-r1 new file mode 100644 index 000000000000..89715bf310c9 --- /dev/null +++ b/sys-cluster/moosefs/files/mfs.initd-r1 @@ -0,0 +1,96 @@ +#!/sbin/openrc-run + +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} +} |