#!/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

case "$1" in
start)
    cat << END


******************************************************************************
* /etc/ppp/ppp_on_boot is deprecated. Please configure your system to use
* the standard /etc/network/interfaces method.
* You can consult /usr/share/doc/ppp/README.Debian.gz and interfaces(5)
* for details.
*
* This message has been printed by /etc/init.d/ppp .
******************************************************************************

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

exit 0
