#!/bin/sh
#
# ipxtund	tool for IPX over IP tunneling
#
# chkconfig:	345 45 55
#
# description:	tool for IPX over IP tunneling
#
# $Id: ipxtund.init,v 1.9 2005/12/08 01:02:49 glen Exp $


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

# Get network config
. /etc/sysconfig/network

# Get service config - may override defaults
[ -f /etc/sysconfig/ipxtund ] && . /etc/sysconfig/ipxtund

# 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 ipxtund
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/ipxtund ]; then
		msg_starting ipxtund; busy
		# we can't get status report from background job
		# but we can only do simple file check
		if [ -r /etc/ipxtund.conf -a -w /var/log ]; then
			ipxtund &
			RETVAL=$?
			[ $RETVAL -eq 0 ] && ok || fail
		else
			fail
			RETVAL=6
		fi
		[ $RETVAL -eq 0 ] && log_success "ipxtund startup" || log_failed "ipxtund startup"
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ipxtund
	else
		msg_already_running ipxtund
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/ipxtund ]; then
		msg_stopping ipxtund
		killproc ipxtund
		rm -f /var/lock/subsys/ipxtund
	else
		msg_not_running ipxtund
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status ipxtund
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
