#!/bin/sh
#
# mcserv	The Midnight Commander file server
#
# chkconfig:	345 86 30
#
# description:	The Midnight Commander server allows users on remote machines \
#		to use the Midnight Commander file manager to manipulate their \
#		files on the machine running the server. The server \
#		authenticates the user through PAM, which by default requires \
#		a username/password combination before allowing access.
#
# processname:	mcserv


# Source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/mcserv ] && . /etc/sysconfig/mcserv

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down mcserv
		exit 1
	fi
else
	exit 0
fi


# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/mcserv ]; then
		msg_starting mcserv
		is_yes $VERBOSE && OPTS="$OPTS -v"
		is_yes $QUIET && OPTS="$OPTS -v"
		[ "$PORT" != "" ] && OPTS="$POPTS -p $PORT"
		daemon mcserv -d $OPTS
		touch /var/lock/subsys/mcserv
	else
		msg_already_running mcserv
	fi
	;;
  status)
	status mcserv
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  stop)
	if [ -f /var/lock/subsys/mcserv ]; then
		msg_stopping mcserv
		killproc mcserv
		rm -f /var/lock/subsys/mcserv >/dev/null 2>&1
	else
		msg_not_running mcserv
	fi
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit 0
