#!/bin/sh
#
# See also /etc/opt/ipf/ipf.conf and /etc/hosts.allow
#
# $Cambridge: hermes/src/2hermes/rc.fixfwd,v 1.7 2004/07/21 16:51:43 fanf2 Exp $
#
### BEGIN INIT INFO
# Provides:                     fixfwd
# Required-Start:               $local_fs $remote_fs $network
# X-UnitedLinux-Should-Start:   $named $syslog $time
# Required-Stop:
# X-UnitedLinux-Should-Stop:
# Default-Start:                3 5
# Default-Stop:                 0 1 2 6
# Short-Description:            2hermes fixfwd daemon
# Description:                  2hermes fixfwd daemon
### END INIT INFO

PATH=/bin:/usr/bin

kill_service() {
   if [ -f "/var/run/$1.pid" ]; then
       pid=`cat /var/run/$1.pid`
       if [ "x$pid" != "x" ]; then
           kill $pid
       fi
   fi
}

case $1 in
'start')
    if [ -x /opt/2hermes/fixfwd -a \
         -x /usr/sbin/stunnel ]
    then
        /usr/sbin/stunnel /opt/2hermes/stunnel.conf
        /opt/2hermes/fixfwd
    fi
    ;;
'stop')
    kill_service "stunnel"
    kill_service "fixfwd"
    ;;
*)
    echo "usage: /etc/init.d/fixfwd {start|stop}"
    ;;
esac
