###!/bin/sh
#
#   Rename this file to ppp_on_boot and pppd will be fired up as
#   soon as the system comes up, connecting to `provider'.
#
#   If you also make this file executable, and replace the first line
#   with just "#!/bin/sh", the commands below will be executed instead.
#

if [ -e /etc/default/ppp ];then
        source /etc/default/ppp
else
	exit 0
fi

if [ "${ENABLE}" != "1" ];then
	exit 0
fi

PPP_OPTS="noipdefault usepeerdns persist noauth holdoff 30 maxfail 0 plugin rp-pppoe.so";

# The location of the ppp daemon itself (shouldn't need to be changed)
PPPD=/usr/sbin/pppd

if [ "${USER}" ];then
  PPP_OPTS="${PPP_OPTS} user ${USER}"
fi;

if [ "${PASS}" ];then
  PPP_OPTS="${PPP_OPTS} password ${PASS}"
fi;

if [ "${MRU}" ];then
  PPP_OPTS="${PPP_OPTS} mru ${MRU}"
 else
  PPP_OPTS="${PPP_OPTS} mru 1492"
fi;

if [ "${SERVICE}" ];then
  PPP_OPTS="${PPP_OPTS} rp_pppoe_service ${SERVICE}"
fi;

if [ "${VLAN}" ];then
  if [ ! -d /sys/class/net/eth0.${VLAN} ];then
    /sbin/ip link add link eth0 name eth0.${VLAN} type vlan id ${VLAN}
    /sbin/ip link set eth0.${VLAN} up
  fi;
  PPP_OPTS="${PPP_OPTS} nic-eth0.${VLAN}"
else
  PPP_OPTS="${PPP_OPTS} nic-eth0"
fi;

# The default provider to connect to
$PPPD ${PPP_OPTS}

# Additional connections, which would just use settings from
# /etc/ppp/options.<tty>
#$PPPD ttyS0
#$PPPD ttyS1
#$PPPD ttyS2
#$PPPD ttyS3
