#!/bin/sh
#
# portfwd	this program starts and stops the portfwd
#	        daemon.
#
# chkconfig: 345 82 18
# description: portfwd is a program that forwards connections \
#              from the local machine to another machine.
# probe: false

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/sbin/portfwd ] || exit 0

[ -f /etc/portfwd.cfg ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
        # Start daemons.
        echo -n "Starting portfwd: "
        daemon /usr/sbin/portfwd -c /etc/portfwd.cfg
	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/portfwd
	echo
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down portfwd: "
        killproc portfwd 2
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/portfwd
        echo
        ;;
  restart)
	$0 stop
	$0 start
	;;
  *)

        echo "Usage: portfwd {start|stop|restart}"
        exit 1
esac

exit $RETVAL

