Add PPTP over DHCP support to red

This commit is contained in:
Arne Fitzenreiter
2009-09-20 12:14:08 +02:00
parent 3c00493401
commit fd850b7e3b

View File

@@ -74,16 +74,13 @@ if [ "${TYPE}" == "STATIC" ]; then
echo_failure
exit 1
fi
elif [ "${TYPE}" == "DHCP" ]; then
fi
PIDFILE="/var/run/dhcpcd-${DEVICE}.pid"
LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.info"
DHCP_START="-N -R -L /var/ipfire/dhcpc -c /var/ipfire/dhcpc/dhcpcd.exe "
DHCP_STOP="-k -c /var/ipfire/dhcpc/dhcpcd.exe "
fi
case "${1}" in
start)
if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then
@@ -264,8 +261,6 @@ case "${1}" in
if [ "${RED_VDSL_IPTV_DISABLE}" == "0" ]; then
PIDFILE="/var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid"
LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.info"
DHCP_START="-N -R -L /var/ipfire/dhcpc -c /var/ipfire/dhcpc/dhcpcd.exe "
DHCP_STOP="-k -c /var/ipfire/dhcpc/dhcpcd.exe "
# Test to see if there is a stale pid file
if [ -f "$PIDFILE" ]; then
@@ -329,8 +324,48 @@ case "${1}" in
boot_mesg "Bringing up the $TYPE interface on $PPP_NIC ..."
ip addr flush dev $PPP_NIC >/dev/null 2>&1
if [ "$TYPE" == "pptp" ]; then
if [ "$PPTP_NICCFG" == "dhcp" ]; then
# Test to see if there is a stale pid file
if [ -f "$PIDFILE" ]; then
ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
if [ $? != 0 ]; then
rm -f /var/run/dhcpcd-${DEVICE}.${RED_VDSL_IPTV_VLAN}.pid > /dev/null
fi
fi
if [ ! -f "$PIDFILE" ]; then
boot_mesg -n "Starting dhcpcd on the ${DEVICE}.${RED_VDSL_IPTV_VLAN} interface..."
/sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
RET="$?"
if [ "$RET" = "0" ]; then
. /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
echo ""
echo_ok
boot_mesg " DHCP Assigned Settings for ${DEVICE}:"
boot_mesg_flush
boot_mesg " IP Address: $IPADDR"
boot_mesg_flush
boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
boot_mesg_flush
boot_mesg " Subnet Mask: $NETMASK"
boot_mesg_flush
boot_mesg " Default Gateway: $GATEWAY"
boot_mesg_flush
boot_mesg " DNS Server: $DNS"
boot_mesg_flush
else
echo ""
$(exit "$RET")
evaluate_retval
fi
fi
else
ip addr add $PPTP_NICCFG dev $PPP_NIC
fi
fi
ip link set ${PPP_NIC} up
else
boot_mesg "Bringing up the PPP via ${TYPE} on ${COMPORT}..."
@@ -480,9 +515,20 @@ case "${1}" in
fi
run_subdir ${rc_base}/init.d/networking/red.down/
elif [ "$TYPE" == "DHCP" ]; then
boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
elif [ "$TYPE" == "PPPOE" ]; then
boot_mesg "Bringing down the PPP interface ..."
## Disable vnstat collection
/usr/bin/vnstat -u -i ppp0 -r --disable > /dev/null 2>&1
rm -f /var/ipfire/red/keepconnected
killall -w -s TERM /usr/sbin/pppd 2>/dev/null
evaluate_retval
# Add a NaN value to ppp0 rrd to supress spikes at reconnect
rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
$(date +%s):: > /dev/null 2>&1
fi
if [ -e $LEASEINFO ]; then
boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
. $LEASEINFO
if [ "$LEASETIME" = "4294967295" ]; then
# do nothing, just echo ok
@@ -507,22 +553,6 @@ case "${1}" in
killproc dhcpcd
fi
fi
else
boot_mesg -n "LEASEINFO Test failed! - " ${WARNING}
boot_mesg "dhcpcd is not running!" ${WARNING}
echo_warning
fi
elif [ "$TYPE" == "PPPOE" ]; then
boot_mesg "Bringing down the PPP interface ..."
## Disable vnstat collection
/usr/bin/vnstat -u -i ppp0 -r --disable > /dev/null 2>&1
rm -f /var/ipfire/red/keepconnected
killall -w -s TERM /usr/sbin/pppd 2>/dev/null
evaluate_retval
# Add a NaN value to ppp0 rrd to supress spikes at reconnect
rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
$(date +%s):: > /dev/null 2>&1
fi
if [ "$DEVICE" != "${GREEN_DEV}" ] && [ "$DEVICE" != "" ]; then