hotplug-based network script rewrite
authorFelix Fietkau <nbd@openwrt.org>
Sat, 19 Nov 2005 03:17:20 +0000 (03:17 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 19 Nov 2005 03:17:20 +0000 (03:17 +0000)
SVN-Revision: 2531

15 files changed:
openwrt/package/base-files/default/bin/firstboot
openwrt/package/base-files/default/etc/functions.sh
openwrt/package/base-files/default/etc/hotplug.d/net/01-wds [deleted file]
openwrt/package/base-files/default/etc/hotplug.d/net/10-net [new file with mode: 0644]
openwrt/package/base-files/default/etc/init.d/S10boot
openwrt/package/base-files/default/etc/init.d/S40network
openwrt/package/base-files/default/etc/nvram.sh
openwrt/package/base-files/default/sbin/hotplug
openwrt/package/base-files/default/sbin/ifdown
openwrt/package/base-files/default/sbin/ifup
openwrt/package/linux-atm/Makefile
openwrt/package/linux-atm/files/br2684.init
openwrt/package/ppp/files/ifup.pppoa
openwrt/package/ppp/files/ifup.pppoe
openwrt/package/pptp/files/ifup.pptp

index 604721873a8ce5a0339e37ea9c08be5c1f7958dc..eff7063b1c136e55a2dd5274c9aabbd7ec321881 100755 (executable)
@@ -60,6 +60,3 @@ mount none /tmp  -t ramfs
 umount /rom/proc
 umount /rom/tmp
 umount /rom/dev
-
-# normally created by boot script
-mkdir -p /var/run
index 9cfc8023579b38ba20438bab70d2ed443ba5808e..e7126473f468254eb5bf0beaed0623f6a8ee15c1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/ash
+#!/bin/sh
 . /etc/nvram.sh
 
 alias debug=${DEBUG:-:}
@@ -7,74 +7,11 @@ alias debug=${DEBUG:-:}
 if_valid () (
   ifconfig "$1" >&- 2>&- ||
   [ "${1%%[0-9]}" = "br" ] ||
-  {
-    [ "${1%%[0-9]}" = "vlan" ] && ( 
-      i=${1#vlan}
-      hwname=$(nvram get vlan${i}hwname)
-      hwaddr=$(nvram get ${hwname}macaddr)
-      [ -z "$hwaddr" ] && return 1
-
-      vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
-      debug "# vlan$i => $vif"
-
-      $DEBUG ifconfig $vif up
-      $DEBUG vconfig add $vif $i 2>&-
-    )
-  } ||
   { debug "# missing interface '$1' ignored"; false; }
 )
 
-do_ifup() {
-       if_proto=$(nvram get ${2}_proto)
-       if=$(nvram get ${2}_ifname)
-       [ "${if%%[0-9]}" = "ppp" ] && if=$(nvram get ${if_proto}_ifname)
-       
-       pidfile=/var/run/${if}.pid
-       [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
-
-       case "$1" in
-       static)
-               ip=$(nvram get ${2}_ipaddr)
-               netmask=$(nvram get ${2}_netmask)
-               gateway=$(nvram get ${2}_gateway)
-
-               $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
-               ${gateway:+$DEBUG route add default gw $gateway}
-
-               [ -f /etc/resolv.conf ] || {
-                       debug "# --- creating /etc/resolv.conf ---"
-                       for dns in $(nvram get ${2}_dns); do
-                               echo "nameserver $dns" >> /etc/resolv.conf
-                       done
-               }
-               
-               env -i ACTION="ifup" INTERFACE="${2}" PROTO=static /sbin/hotplug "iface" &
-       ;;
-       dhcp)
-               DHCP_IP=$(nvram get ${2}_ipaddr)
-               DHCP_NETMASK=$(nvram get ${2}_netmask)
-               $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
-
-               DHCP_ARGS="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
-               DHCP_HOSTNAME=$(nvram get ${2}_hostname)
-               DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*}
-               [ -z $DHCP_HOSTNAME ] || DHCP_ARGS="$DHCP_ARGS -H $DHCP_HOSTNAME"
-               [ "$if_proto" = "pptp" ] && DHCP_ARGS="$DHCP_ARGS -n -q" || DHCP_ARGS="$DHCP_ARGS -R &"
-               oldpid=$(cat $pidfile)
-               ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
-               pidof udhcpc | grep "$oldpid" >&- 2>&- && {
-                       sleep 1
-                       kill -9 $oldpid
-               }
-               # hotplug events are handled by /usr/share/udhcpc/default.script
-       ;;
-       none|"")
-       ;;
-       *)
-               [ -x "/sbin/ifup.$1" ] && { $DEBUG /sbin/ifup.$1 ${2}; exit; }
-               echo "### ifup ${2}: ignored ${2}_proto=\"$1\" (not supported)"
-       ;;
-       esac
+hotplug_dev() {
+       env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
 }
 
 bitcount () {
diff --git a/openwrt/package/base-files/default/etc/hotplug.d/net/01-wds b/openwrt/package/base-files/default/etc/hotplug.d/net/01-wds
deleted file mode 100644 (file)
index 38bd696..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[ "${INTERFACE%%[0-9]*}" = "wds" ] && { 
-       ifconfig $INTERFACE 0.0.0.0 up
-       /usr/sbin/brctl addif br0 $INTERFACE
-}
-               
diff --git a/openwrt/package/base-files/default/etc/hotplug.d/net/10-net b/openwrt/package/base-files/default/etc/hotplug.d/net/10-net
new file mode 100644 (file)
index 0000000..29df1d2
--- /dev/null
@@ -0,0 +1,190 @@
+#!/bin/sh
+setup_eth()
+{
+       [ -f /proc/net/wl0 ] && {
+               lsmod | grep wlcompat >&- || insmod wlcompat
+       }
+       iwconfig "$INTERFACE" 2>&- | grep -v 'no wireless' >&- && {
+               /sbin/wifi
+       }
+       if="$(echo "$INTERFACE" | sed s,eth,et,)"
+       ifconfig "$INTERFACE" up 2>&- >&-
+       for vlan in $(seq 0 15); do
+               [ "$(nvram get vlan${vlan}hwname)" = "$if" ] && \
+                       $DEBUG vconfig add "$INTERFACE" "$vlan"
+       done
+}
+
+find_name()
+{
+       pppoa_ifname="atm0" # hack for ppp over atm, which has no ${proto}_ifname
+       interfaces="lan wan wifi $(nvram get ifnames)"
+       for ifname in $interfaces; do
+               IFTYPE="${ifname}"
+               IFPROTO="$(nvram get ${IFTYPE}_proto)"
+               IFACE="$(nvram get ${IFTYPE}_ifname)"
+               [ -z "$IFPROTO" -o "$IFPROTO" = "none" ] || {
+                       [ "${IFACE}" = "$INTERFACE" ] && return 0
+                       case "$IFPROTO" in
+                               static|dhcp)
+                                       [ "${IFACE%%[0-9]*}" = "br" ] && {
+                                               for part in $(nvram get ${IFTYPE}_ifnames); do
+                                                       [ "$part" = "$INTERFACE" ] && return 0
+                                               done
+                                       }
+                               ;;
+                               *)
+                                       [ "$(nvram get ${IFPROTO}_ifname)" = "$INTERFACE" \
+                                         -a -x /sbin/ifup.${IFPROTO} ] && return 0
+                               ;;
+                       esac
+               }
+       done
+       IFACE=""
+       IFTYPE=""
+       IFPROTO=""
+       return 255
+}
+
+do_ifup() {
+       if="$3"
+       if_proto="$(nvram get ${2}_proto)"
+       
+       pidfile=/var/run/${if}.pid
+       [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
+
+       case "$1" in
+               static)
+                       ip=$(nvram get ${2}_ipaddr)
+                       netmask=$(nvram get ${2}_netmask)
+                       gateway=$(nvram get ${2}_gateway)
+       
+                       $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
+                       ${gateway:+$DEBUG route add default gw $gateway}
+       
+                       [ -f /etc/resolv.conf ] || {
+                               debug "# --- creating /etc/resolv.conf ---"
+                               for dns in $(nvram get ${2}_dns); do
+                                       echo "nameserver $dns" >> /etc/resolv.conf
+                               done
+                       }
+                       
+                       env -i ACTION="ifup" INTERFACE="${2}" PROTO=static /sbin/hotplug "iface" &
+               ;;
+               dhcp)
+                       DHCP_IP=$(nvram get ${2}_ipaddr)
+                       DHCP_NETMASK=$(nvram get ${2}_netmask)
+                       $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
+       
+                       DHCP_ARGS="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
+                       DHCP_HOSTNAME=$(nvram get ${2}_hostname)
+                       DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*}
+                       [ -z $DHCP_HOSTNAME ] || DHCP_ARGS="$DHCP_ARGS -H $DHCP_HOSTNAME"
+                       [ "$if_proto" = "pptp" ] && DHCP_ARGS="$DHCP_ARGS -n -q" || DHCP_ARGS="$DHCP_ARGS -R &"
+                       oldpid=$(cat $pidfile)
+                       ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
+                       pidof udhcpc | grep "$oldpid" >&- 2>&- && {
+                               sleep 1
+                               kill -9 $oldpid
+                       }
+                       # hotplug events are handled by /usr/share/udhcpc/default.script
+               ;;
+               *)
+                       if [ -x "/sbin/ifup.$1" ]; then
+                               ( $DEBUG . /sbin/ifup.$1 ${2} $3 )
+                       fi
+               ;;
+       esac
+}
+
+do_register()
+{
+       case "${INTERFACE%%[0-9]*}" in
+               eth) setup_eth;;
+       esac
+
+       [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
+               find_name || {
+                       case "${INTERFACE%%[0-9]*}" in
+                               wds) 
+                                       for tmp in lan wifi; do
+                                               [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
+                                                       IFPROTO="$(nvram get ${tmp}_proto)"
+                                                       IFTYPE="${tmp}"
+                                               }
+                                       done
+                                       [ -z "$IFPROTO" ] && return 0
+                               ;;
+                               atm)
+                                       for tmp in lan wan wifi $(nvram get ifnames); do
+                                               [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
+                                                       do_ifup "pppoa" "$tmp" "$INTERFACE"
+                                                       return 0
+                                               }
+                                       done
+                               ;;
+                               *)
+                                       return 0
+                               ;;
+                       esac
+               }
+       }
+
+       case "${INTERFACE%%[0-9]*}" in 
+               ppp|atm);;
+               *)
+                       mac=$(nvram get ${IFTYPE}_hwaddr)
+                       ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
+               ;;
+       esac
+
+       if="$(nvram get ${IFTYPE}_ifname)"
+       if [ "${if%%[0-9]}" = "br" ]; then
+               if_valid "$INTERFACE" && {
+                       ifconfig "$if" 2>&- >&- || {
+                               stp=$(nvram get ${IFTYPE}_stp)
+                               $DEBUG brctl addbr "$if"
+                               $DEBUG brctl setfd "$if" 0
+                               $DEBUG brctl stp "$if" "${stp:-0}"
+                       }
+
+                       if [ "$INTERFACE" != "$if" ]; then
+                               $DEBUG ifconfig "$INTERFACE" 0.0.0.0 up
+                               brctl addif "$if" "$INTERFACE"
+                       else
+                               do_ifup "$IFPROTO" "$IFTYPE" "$if"
+                       fi
+               }
+       else
+               do_ifup "$IFPROTO" "$IFTYPE" "$if"
+       fi
+}
+
+do_unregister() {
+       [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig "$INTERFACE" 0.0.0.0 down 2>&-
+       [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
+       [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
+       
+       [ "${IFACE%%[0-9]*}" = "br" ] && {
+               if [ "$INTERFACE" != "$IFACE" ]; then
+                       brctl delif "$IFACE" "$INTERFACE" 2>&- >&-
+               else
+                       brctl delbr "$IFACE" 2>&- >&-
+               fi
+       }
+       
+       case "$IFPROTO" in
+               pppoe|pppoa|pptp) 
+                       killall ifup.${IFPROTO}
+                       killall pppd
+               ;;
+               dhcp)
+                       [ -f /var/run/${INTERFACE}.pid ] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
+               ;;
+       esac
+}
+
+case "$ACTION" in
+       register) do_register;;
+       unregister) do_unregister;;
+esac
index b0dc04eb7e1b15f354eb1dadd58c1b9da2eb7501..d5ec19436a127bde1a93ef983ba9ab06422aa54d 100755 (executable)
@@ -5,10 +5,22 @@
         echo "S" > /proc/jffs2_bbc
 }
 
+vconfig set_name_type VLAN_PLUS_VID_NO_PAD
+
+HOSTNAME=$(nvram get wan_hostname)
+HOSTNAME=${HOSTNAME%%.*}
+echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
+
+# automagically run firstboot
+[ -z "$FAILSAFE" -a -z "$(nvram get no_root_swap)" ] && {
+       { mount|grep "on / type jffs2" 1>&-; } || firstboot
+}
+
 mkdir -p /var/run
 mkdir -p /var/log
 touch /var/log/wtmp
 touch /var/log/lastlog
+[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
 
 sed 's/^[^#]/insmod &/' /etc/modules /etc/modules.d/* 2>&-|ash
 
@@ -20,13 +32,4 @@ ifconfig eth0 promisc
   robocfg show
 }
 
-HOSTNAME=$(nvram get wan_hostname)
-HOSTNAME=${HOSTNAME%%.*}
-echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
-
-vconfig set_name_type VLAN_PLUS_VID_NO_PAD
 
-# automagically run firstboot
-[ -z "$FAILSAFE" -a -z "$(nvram get no_root_swap)" ] && {
-       { mount|grep "on / type jffs2" 1>&-; } || firstboot
-}
index df7c6b351556a072228455ffbff8d6a37a329a16..168fd2979bfc59dac3376777611959ecebaa777f 100755 (executable)
@@ -3,10 +3,10 @@
 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
 case "$1" in
   start|restart)
-    ifup lan
-    ifup wan
-    ifup wifi
-    wifi up
+#    ifup lan
+#    ifup wan
+#    ifup wifi
+#    wifi up
 
     for route in $(nvram get static_route); do {
       eval "set $(echo $route | sed 's/:/ /g')"
index f1170ac470fa8c2840a16fb5d8d2297c5c4a0ca5..4d39a102047676d7aac5de7a4357a4092257593c 100644 (file)
@@ -4,8 +4,8 @@
 nvram () {
   if [ -x /usr/sbin/nvram ]; then
     case $1 in
-      get) eval "echo \${$2:-\$(command nvram get $2)}";;
-      *) command nvram $*;;
+      get) eval "echo \${$2:-\$(/usr/sbin/nvram get $2)}";;
+      *) /usr/sbin/nvram $*;;
     esac
   else
     case $1 in
index 4e009593af3b56c8aba1d4bc1f8c708b7562d619..e53b2afcc57f31e28a403b0d03017ba4e24f48a1 100755 (executable)
@@ -1,7 +1,11 @@
 #!/bin/sh
+[ -e /tmp/.failsafe ] && {
+       export FAILSAFE=true
+} || {
+       [ -e /etc/config/network ] && . /etc/config/network
+}
 . /etc/functions.sh
 . /etc/network.overrides
-[ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
 
 PATH=/bin:/sbin:/usr/bin:/usr/sbin
 LOGNAME=root
index f2f8bbfe8168d9065aa3b30162c802a1ba346c5d..3ebc251f72034afb17fcddf031fe1b9ead915907 100755 (executable)
@@ -1,19 +1,29 @@
 #!/bin/sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
 . /etc/functions.sh
-. /etc/network.overrides  
+. /etc/network.overrides
 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
 
-type=$1
 debug "### ifdown $type ###"
+type=$1
 
+if_proto=$(nvram get ${type}_proto)
 if=$(nvram get ${type}_ifname)
-proto=$(nvram get ${type}_proto)
-if_valid $if && $DEBUG ifconfig $if down
-kill $(cat /var/run/${if}.pid 2>&-) 2>&-
-killall ifup.$proto >&- 2>&-
-case "$proto" in
-       pptp|pppoe) killall pppd >&- 2>&- ;;
-       static) env -i ACTION="ifdown" INTERFACE="$if" PROTO=static /sbin/hotplug "iface" ;;
+
+case "$if_proto" in
+       pppoa) hotplug_dev unregister atm0; exit 0 ;;
+       pppoe) 
+               [ "$(nvram get pppoe_atm)" = 1 ] && {
+                       hotplug_dev unregister atm0
+                       exit
+               }
+       ;;
 esac
 
+if [ "${if%%[0-9]}" = "br" ]; then
+       for sif in $(nvram get ${type}_ifnames); do
+               hotplug_dev unregister "$sif"
+       done
+fi
+       
+hotplug_dev unregister "$if"
index be7075bf146d9064fb500b0336cb27e515673020..0d75cefeb6ca842b3361703515a6d8874492251b 100755 (executable)
@@ -1,36 +1,31 @@
-#!/bin/ash
+#!/bin/sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
-
 . /etc/functions.sh
 . /etc/network.overrides
 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
 
-type=$1
+ifdown $1
+
 debug "### ifup $type ###"
+type=$1
 
 if_proto=$(nvram get ${type}_proto)
 if=$(nvram get ${type}_ifname)
-[ "${if%%[0-9]}" = "ppp" ] && if=$(nvram get ${if_proto}_ifname)
 
-if_valid $if || [ "$if_proto" = "pptp" ] || exit 
-mac=$(nvram get ${type}_hwaddr)
-$DEBUG ifconfig $if down 2>&-
+case "$if_proto" in
+       pppoa) hotplug_dev register atm0; exit 0 ;;
+       pppoe) 
+               [ "$(nvram get pppoe_atm)" = 1 ] && {
+                       hotplug_dev register atm0
+                       exit
+               }
+       ;;
+esac
 
 if [ "${if%%[0-9]}" = "br" ]; then
-       stp=$(nvram get ${type}_stp)
-       $DEBUG brctl delbr $if 2>&-
-       $DEBUG brctl addbr $if
-       $DEBUG brctl setfd $if 0
-       $DEBUG brctl stp $if ${stp:-0}
-
        for sif in $(nvram get ${type}_ifnames); do
-               if_valid $sif || continue
-               ${mac:+$DEBUG ifconfig $sif down hw ether $mac}
-               $DEBUG ifconfig $sif 0.0.0.0 up
-               $DEBUG brctl addif $if $sif
+               hotplug_dev register "$sif"
        done
 else
-       ${mac:+$DEBUG ifconfig $if down hw ether $mac}
+       hotplug_dev register "$if"
 fi
-
-do_ifup $if_proto $type
index d36c7c39e3e35e7c25fa7dca6e131e6344a0e779..3c7bf9c5b54f18d901f0743eafb3b309b1722a5d 100644 (file)
@@ -63,8 +63,8 @@ $(IPKG_LINUX_ATM):
 $(IPKG_BR2684CTL): 
        install -d -m0755 $(IDIR_BR2684CTL)/usr/sbin
        cp -fpR $(PKG_INSTALL_DIR)/usr/sbin/br2684ctl $(IDIR_BR2684CTL)/usr/sbin/
-       install -d -m0755 $(IDIR_BR2684CTL)/etc/init.d
-       install -m0755 ./files/br2684.init $(IDIR_BR2684CTL)/etc/init.d/S30br2684
+       install -d -m0755 $(IDIR_BR2684CTL)/etc/hotplug.d/net
+       install -m0644 ./files/br2684.init $(IDIR_BR2684CTL)/etc/hotplug.d/net/30-br2684
        $(RSTRIP) $(IDIR_BR2684CTL)/
        $(IPKG_BUILD) $(IDIR_BR2684CTL) $(PACKAGE_DIR)
 
index 90ba36521de6a5514f004ed5866cb7f04375f4c6..88f40e76b62d58bf7d8759057ac36706bd3896ab 100644 (file)
@@ -1,22 +1,21 @@
-#!/bin/sh
-. /etc/functions.sh
-[ -e /etc/config/network ] && . /etc/config/network
-
-killall br2684ctl 2>&- >&-
-[ "$(nvram get pppoe_atm)" = 1 ] && {
-  VPI=$(nvram get atm_vpi)
-  VCI=$(nvram get atm_vci)
-  case "$(nvram get atm_encaps)" in
-    0|vc)
-      ENCAPS=0
-      ;;
-    1|llc)
-      ENCAPS=1
-      ;;
-    *)
-      ENCAPS=0
-      ;;
-  esac
-  insmod br2684
-  br2684ctl -c0 -e${ENCAPS} -a${VPI:-8}.${VCI:-35} &
+[ "${INTERFACE%%[0-9]*}" = "atm" ] && {
+       case "$ACTION" in
+               register)
+                       [ "$(nvram get pppoe_atm)" = 1 ] && {
+                               VPI=$(nvram get atm_vpi)
+                               VCI=$(nvram get atm_vci)
+                               case "$(nvram get atm_encaps)" in
+                                       0|vc) ENCAPS=0 ;;
+                                       1|llc) ENCAPS=1 ;;
+                                       *) ENCAPS=0 ;;
+                               esac
+                               insmod br2684 2>&- >&-
+                               br2684ctl -c0 -e${ENCAPS} -a${VPI:-8}.${VCI:-35} &
+                       }
+               ;;
+               unregister)
+                       killall br2684ctl 2>&- >&-
+                       rmmod br2684
+               ;;
+       esac
 }
index 5f42a39d08e5d6f8ff5f0d58c8a7ad0c9965b0bd..6539c3ae8eae9c3b85c2e817eb17129c777538b9 100644 (file)
@@ -14,36 +14,31 @@ for module in slhc ppp_generic pppoatm; do
        /sbin/insmod $module 2>&- >&-
 done
 
-while :; do
-       VPI=$(nvram get atm_vpi)
-       VCI=$(nvram get atm_vci)
-       USERNAME=$(nvram get ppp_username)
-       PASSWORD=$(nvram get ppp_passwd)
-       KEEPALIVE=$(nvram get ppp_redialperiod)
-       KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
-       DEMAND=$(nvram get ppp_demand)
-       case "$DEMAND" in
-               on|1|enabled)
-                       DEMAND=$(nvram get ppp_idletime)
-                       DEMAND=${IDLETIME:+demand idle $IDLETIME}
-               ;;
-               *) DEMAND="";;
-       esac
-       MTU=$(nvram get ppp_mtu)
-       MTU=${MTU:-1500}
+VPI=$(nvram get atm_vpi)
+VCI=$(nvram get atm_vci)
+USERNAME=$(nvram get ppp_username)
+PASSWORD=$(nvram get ppp_passwd)
+KEEPALIVE=$(nvram get ppp_redialperiod)
+KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
+DEMAND=$(nvram get ppp_demand)
+case "$DEMAND" in
+       on|1|enabled)
+               DEMAND=$(nvram get ppp_idletime)
+               DEMAND=${IDLETIME:+demand idle $IDLETIME}
+       ;;
+       *) DEMAND="persist";;
+esac
+MTU=$(nvram get ppp_mtu)
+MTU=${MTU:-1500}
 
-       /usr/sbin/pppd nodetach \
+/usr/sbin/pppd nodetach \
        plugin pppoatm.so ${VPI:-8}.${VCI:-35} \
-               usepeerdns \
-               defaultroute \
-               linkname $type \
-               ipparam $type \
-               user "$USERNAME" \
-               password "$PASSWORD" \
-               mtu $MTU mru $MTU \
-               $DEMAND \
-               $KEEPALIVE
-       
-       # Read settings again (might have changed)
-       [ -e /etc/config/network ] && . /etc/config/network
-done &
+       usepeerdns \
+       defaultroute \
+       linkname $type \
+       ipparam $type \
+       user "$USERNAME" \
+       password "$PASSWORD" \
+       mtu $MTU mru $MTU \
+       $DEMAND \
+       $KEEPALIVE
index 36bbe30299503d57d607e7a68e7cbc7f24aea709..4c42fa5bb26df14dccd3d16540240e08549ff07e 100644 (file)
@@ -14,38 +14,34 @@ for module in slhc ppp_generic pppox pppoe; do
        /sbin/insmod $module 2>&- >&-
 done
 
-while :; do
-       IFNAME=$(nvram get pppoe_ifname)
-       USERNAME=$(nvram get ppp_username)
-       PASSWORD=$(nvram get ppp_passwd)
-       KEEPALIVE=$(nvram get ppp_redialperiod)
-       KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
-       DEMAND=$(nvram get ppp_demand)
-       case "$DEMAND" in
-               on|1|enabled)
-                       DEMAND=$(nvram get ppp_idletime)
-                       DEMAND=${IDLETIME:+demand idle $IDLETIME}
-               ;;
-               *) DEMAND="";;
-       esac
-       MTU=$(nvram get ppp_mtu)
-       MTU=${MTU:-1492}
+IFNAME=$(nvram get pppoe_ifname)
+USERNAME=$(nvram get ppp_username)
+PASSWORD=$(nvram get ppp_passwd)
+KEEPALIVE=$(nvram get ppp_redialperiod)
+KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
+DEMAND=$(nvram get ppp_demand)
+case "$DEMAND" in
+       on|1|enabled)
+               DEMAND=$(nvram get ppp_idletime)
+               DEMAND=${IDLETIME:+demand idle $IDLETIME}
+       ;;
+       *) DEMAND="persist";;
+esac
+MTU=$(nvram get ppp_mtu)
+MTU=${MTU:-1492}
+
+ifconfig $IFNAME up
+/usr/sbin/pppd nodetach \
+       plugin rp-pppoe.so \
+       connect /bin/true \
+       usepeerdns \
+       defaultroute \
+       linkname $type \
+       ipparam $type \
+       user "$USERNAME" \
+       password "$PASSWORD" \
+       mtu $MTU mru $MTU \
+       $DEMAND \
+       $KEEPALIVE \
+       nic-$IFNAME
 
-       ifconfig $IFNAME up
-       /usr/sbin/pppd nodetach \
-               plugin rp-pppoe.so \
-               connect /bin/true \
-               usepeerdns \
-               defaultroute \
-               linkname $type \
-               ipparam $type \
-               user "$USERNAME" \
-               password "$PASSWORD" \
-               mtu $MTU mru $MTU \
-               $DEMAND \
-               $KEEPALIVE \
-               nic-$IFNAME
-       
-       # Read settings again (might have changed)
-       [ -e /etc/config/network ] && . /etc/config/network
-done &
index 23cad08050c0a0895c38017ea0bb3bfd7e5204b5..eda78e44029786329020c925358ff76a010093ca 100644 (file)
@@ -10,46 +10,44 @@ for module in slhc ppp_generic ppp_async ip_gre; do
        /sbin/insmod $module 2>&- >&-
 done
 
-while :; do
-       PPTP_PROTO="$(nvram get pptp_proto)"
-       [ "$PPTP_PROTO" = "static" ] || PPTP_PROTO=""
-       PPTP_PROTO="${PPTP_PROTO:-dhcp}"
-       IP=$(nvram get pptp_server_ip)
-       USERNAME=$(nvram get ppp_username)
-       PASSWORD=$(nvram get ppp_passwd)
-       KEEPALIVE=$(nvram get ppp_redialperiod)
-       KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
-       DEMAND=$(nvram get ppp_demand)
-       case "$DEMAND" in
-               on|1|enabled)
-                       DEMAND=$(nvram get ppp_idletime)
-                       DEMAND=${IDLETIME:+demand idle $IDLETIME}
-               ;;
-               *) DEMAND="";;
-       esac
-       MTU=$(nvram get ppp_mtu)
-       MTU=${MTU:-1452}
-
-       do_ifup $PPTP_PROTO $type
-       
-       # hack for some buggy ISPs
-       NETMASK=$(nvram get ${type}_netmask)
-       IFNAME=$(nvram get pptp_ifname)
-       [ -z "$NETMASK" -o -z "$IFNAME" ] || ifconfig $IFNAME netmask $NETMASK
-
-       /usr/sbin/pppd nodetach \
-               pty "/usr/sbin/pptp $IP --loglevel 0 --nolaunchpppd" \
-               file /etc/ppp/options.pptp \
-               connect /bin/true \
-               usepeerdns \
-               defaultroute \
-               replacedefaultroute \
-               linkname "$type" \
-               ipparam "$type" \
-               user "$USERNAME" \
-               password "$PASSWORD" \
-               mtu $MTU mru $MTU \
-               $DEMAND \
-               $KEEPALIVE
-done &
+PPTP_PROTO="$(nvram get pptp_proto)"
+[ "$PPTP_PROTO" = "static" ] || PPTP_PROTO=""
+PPTP_PROTO="${PPTP_PROTO:-dhcp}"
+IP=$(nvram get pptp_server_ip)
+USERNAME=$(nvram get ppp_username)
+PASSWORD=$(nvram get ppp_passwd)
+KEEPALIVE=$(nvram get ppp_redialperiod)
+KEEPALIVE=${KEEPALIVE:+lcp-echo-interval 10 lcp-echo-failure $KEEPALIVE}
+DEMAND=$(nvram get ppp_demand)
+case "$DEMAND" in
+       on|1|enabled)
+               DEMAND=$(nvram get ppp_idletime)
+               DEMAND=${IDLETIME:+demand idle $IDLETIME}
+       ;;
+       *) DEMAND="persist";;
+esac
+MTU=$(nvram get ppp_mtu)
+MTU=${MTU:-1452}
+
+do_ifup $PPTP_PROTO $type
+
+# hack for some buggy ISPs
+NETMASK=$(nvram get ${type}_netmask)
+IFNAME=$(nvram get pptp_ifname)
+[ -z "$NETMASK" -o -z "$IFNAME" ] || ifconfig $IFNAME netmask $NETMASK
+
+/usr/sbin/pppd nodetach \
+       pty "/usr/sbin/pptp $IP --loglevel 0 --nolaunchpppd" \
+       file /etc/ppp/options.pptp \
+       connect /bin/true \
+       usepeerdns \
+       defaultroute \
+       replacedefaultroute \
+       linkname "$type" \
+       ipparam "$type" \
+       user "$USERNAME" \
+       password "$PASSWORD" \
+       mtu $MTU mru $MTU \
+       $DEMAND \
+       $KEEPALIVE