#!/bin/sh
#
# $NetBSD$
#
# Gfarm filesystem metaserver
#
# PROVIDE: gfmd
# REQUIRE: DAEMON

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

CONF="@config_gfarm_gfmd_config@"
OPTIONS="@config_gfarm_gfmd_option@"

name="gfmd"
FILE=${name}
rcvar=${name}
command="@config_gfarm_prefix@/sbin/${name}"
pidfile="@config_gfarm_gfmd_pid_file@"
required_files="$CONF"
export GLOBUS_THREAD_MODEL=pthread

CMD=$1
case X$CMD in
    Xslavestart)
	OPTIONS="-S $OPTIONS"
	CMD=start
	;;
    Xkill)
	sig_stop=SIGKILL
	CMD=stop
	;;
esac

# add more flags through ${${name}_flags}
command_args="-P $pidfile $OPTIONS"

if [ -f /etc/rc.subr ]; then
	load_rc_config ${FILE}
	run_rc_command "$CMD"
else
	echo -n " ${name}"
	${command} ${gfmd_flags} ${command_args}
fi
