#!/bin/sh
#
# Start or stop wanpipe
#
# modification history:
# original:	Robert Leslie <rob@mars.org>
# current:	tony mancill <tmancill@debian.org>
# tm	981215	added calls to wanpipe_routes and wanpipe_monitor
# 19990419/tm	code for bug #35652 (do not shutdown interfaces on upgrade)
######################################################################

test -x /usr/sbin/wanpipe || exit 0

[ -f /var/lock/wanpipe_upgrade ] && {
   echo "$0:  /var/lock/wanpipe_upgrade exists - no action taken!"
   echo "\t(if you receive this message and are not in the middle of"
   echo "\t an upgrade, please log a bug at http://bugs.debian.org)"
   exit 0
} 

case "$1" in
   start)
      /usr/sbin/wanpipe start
      retval=$?
#      if (($retval == 0)) ; then
      [ -x /etc/wanpipe/wanpipe_routes ] && {
         echo "executing /etc/wanpipe/wanpipe_routes start"
         /etc/wanpipe/wanpipe_routes start
      }
      [ -x /etc/wanpipe/wanpipe_monitor ] && {
         echo "executing /etc/wanpipe/wanpipe_monitor start"
         /etc/wanpipe/wanpipe_monitor start
      }
#      fi
   ;;

   stop)
      /usr/sbin/wanpipe stop
      [ -x /etc/wanpipe/wanpipe_routes ] && {
         echo "executing /etc/wanpipe/wanpipe_routes stop"
         /etc/wanpipe/wanpipe_routes stop
      }
      [ -x /etc/wanpipe/wanpipe_monitor ] && {
         echo "executing /etc/wanpipe/wanpipe_monitor stop"
         /etc/wanpipe/wanpipe_monitor stop
      }
   ;;

   restart)
      $0 stop
      $0 start
   ;;
    
   reload)
      echo -n "Reloading wanpipe..."
      $0 restart
   ;;

   force-reload)
      $0 restart
   ;;

   *)
      echo "Usage: /etc/init.d/wanpipe {start|stop|reload|restart}" >&2
      exit 1
   ;;
esac

exit 0
