#!/sbin/runscript # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/sys-cluster/pvfs2/files/pvfs2-server.rc,v 1.1 2007/10/05 14:03:13 mabi Exp $ checkconfig() { local piddir=$(dirname "${PVFS2_PIDFILE}") if [ ! -d "${piddir}" ]; then mkdir -p "${piddir}" || return 1 fi # verify presence of server binary if ! [ -x "${PVFS2SERVER}" ]; then eerror "Error: could not find executable ${PVFS2SERVER}" return 1 fi # look for fs conf if [ -n "${PVFS2_FS_CONF}" ]; then PVFS2_FS_CONF="${PVFS2_CONF_PATH}/${PVFS2_FS_CONF}" else PVFS2_FS_CONF="${PVFS2_CONF_PATH}"/pvfs2-fs.conf fi if ! [ -r "${PVFS2_FS_CONF}" ]; then eerror "Error: could not read ${PVFS2_FS_CONF}" return 1 fi # look for server conf if [ -n "${PVFS2_SERVER_CONF_BASE}" ]; then local myhost=`hostname -s` if [ "${myhost}" == "localhost" ]; then ewarn "Warning: detected hostname as localhost, may confuse PVFS2 startup" fi PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/${PVFS2_SERVER_CONF_BASE}-${myhost}" elif [ -n "${PVFS2_SERVER_CONF}" ]; then PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/${PVFS2_SERVER_CONF}" else PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/pvfs2-server.conf" fi if ! [ -r "${PVFS2_SERVER_CONF}" ]; then eerror "Error: could not read ${PVFS2_SERVER_CONF}" return 1 fi } depend() { after localmount netmount nfsmount dns use net } start() { ebegin "Starting PVFS2 server" local rc checkconfig || return 1 start-stop-daemon -b --start --quiet \ --pidfile "${PVFS2_PIDFILE}" \ --exec "${PVFS2SERVER}" -- -p "${PVFS2_PIDFILE}" ${PVFS2_OPTIONS} \ "${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}" rc=$? # Optionally force pvfs2-server to generate the pvfs2 filesystem. if [[ $PVFS2_AUTO_MKFS -ne 0 ]]; then local test_pid sleep 1 test_pid=$(pidof pvfs2-server) if [ -z "$test_pid" ] || [ ! -f "${PVFS2_PIDFILE}" ] || [[ $test_pid -ne `cat ${PVFS2_PIDFILE}` ]]; then rm -f "${PVFS2_PIDFILE}" &>/dev/null ewarn "Initializing the file system storage with --mkfs" "${PVFS2SERVER}" --mkfs "${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}" rc=$? if [[ $rc -ne 0 ]]; then eerror "Failed to initialize the filesystem storage with --mkfs" eend ${rc} return 1 fi start-stop-daemon -b --start --quiet \ --pidfile ${PVFS2_PIDFILE} \ --exec ${PVFS2SERVER} -- -p "${PVFS2_PIDFILE}" ${PVFS2_OPTIONS} \ "${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}" rc=$? fi fi if [[ $rc -ne 0 ]]; then eend $rc "Error starting PVFS2 server" return 1 else eend 0 return 0 fi } stop() { ebegin "Stopping PVFS2 server" start-stop-daemon --stop --quiet --pidfile "${PVFS2_PIDFILE}" eend $? "Error stopping PVFS2 server" } restart() { svc_stop sleep 2 svc_start }