#!/bin/sh -e
#
#   /etc/init.d/ppp: start or stop PPP link.
#
# This configuration method is deprecated, please use /etc/network/interfaces.

[ -x /usr/sbin/pppd -a -f /etc/ppp/ppp_on_boot ] || exit 0
if [ -x /etc/ppp/ppp_on_boot ]; then RUNFILE=1; fi
. /lib/lsb/init-functions

case "$1" in
  start)
      log_begin_msg "Starting up PPP link..."
      if [ "$RUNFILE" = "1" ]; then
        /etc/ppp/ppp_on_boot
      else
        pppd call provider
      fi
      log_end_msg $?
    ;;
  stop)
      log_begin_msg "Shutting down PPP link..."
      if [ "$RUNFILE" = "1" ]; then
        poff -a
      else
        poff provider
      fi
      log_end_msg $?
    ;;
  restart|force-reload)
      log_begin_msg "Restarting PPP link..."
      if [ "$RUNFILE" = "1" ]; then      
        poff -a
        sleep 5
        /etc/ppp/ppp_on_boot
      else                  
        poff provider
        sleep 5
        pppd call provider
      fi
      log_end_msg $?
    ;;
  *)
      log_success_msg "Usage: /etc/init.d/ppp {start|stop|restart|force-reload}"
      exit 1
    ;;
esac

exit 0
