On Wed, Jan 18, 2012 at 10:27:26PM +0000, Lee Essen wrote:
> > On Wed, Jan 18, 2012 at 01:22:10PM +0000, lee.es...@nowonline.co.uk wrote:
> >> The attached patch adds a "notify" script to the dsl_cpe_control app
> >> to bring the relevant pppoa interface up (or down) whenever there is
> >> a line status change.
> >> 
> >> As far as I can tell the existing hotplug mechanism doesn't work for
> >> non-br2684 based systems as there is no nas0 interface created, and
> >> hence no hotplug event ... so the ppp link stays down until you
> >> manually start it, people may be surviving by having an erroneous
> >> bridge configured (which seems to be the default), but clearly this
> >> isn't the right behaviour.
> >> 
> >> The patch largely replicates the code from the atm hotplug script
> >> (with the addition of support for the link going down.)

I have tested the patch and on dsl cable plug/unplug ppp interface goes
up/down as well. I have done some cosmetic changes to the patch.

I think this can be applied. John?

Luka

Index: package/ltq-dsl-app/files/dsl_notify.sh
===================================================================
--- package/ltq-dsl-app/files/dsl_notify.sh     (revision 0)
+++ package/ltq-dsl-app/files/dsl_notify.sh     (working copy)
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /etc/functions.sh
+
+include /lib/network
+scan_interfaces
+
+local found=0
+local ifc
+for ifc in $interfaces; do
+       local up
+       config_get_bool up "$ifc" up 0
+
+       local auto
+       config_get_bool auto "$ifc" auto 1
+
+       local proto
+       config_get proto "$ifc" proto
+
+       if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+               if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; 
then
+                       found=1
+                       ( sleep 1; ifup "$ifc" ) &
+               fi
+       else 
+               if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; 
then
+                       found=1
+                       ( sleep 1; ifdown "$ifc" ) &
+               fi
+       fi
+done
+
+if [ "$found" != 1 ]; then
+       logger "Found no matching interface for DSL notification 
($DSL_INTERFACE_STATUS)"
+fi
Index: package/ltq-dsl-app/files/ifx_cpe_control_init.sh
===================================================================
--- package/ltq-dsl-app/files/ifx_cpe_control_init.sh   (revision 29875)
+++ package/ltq-dsl-app/files/ifx_cpe_control_init.sh   (working copy)
@@ -1,21 +1,15 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2008 OpenWrt.org
+# Copyright (C) 2008-2012 OpenWrt.org
 START=99
 
 start() {
-
        # start CPE dsl daemon in the background
-       /sbin/dsl_cpe_control -i -f /lib/firmware/ModemHWE.bin &
+       /sbin/dsl_cpe_control -i \
+                       -n /sbin/dsl_notify.sh \
+                       -f /lib/firmware/ModemHWE.bin &
 
-#      PS=`ps`
-#      echo $PS | grep -q dsl_cpe_control && {
-#              # workaround for nfs: allow write to pipes for non-root
-#              while [ ! -e /tmp/pipe/dsl_cpe1_ack ] ; do sleep 1; done
-#              chmod a+w /tmp/pipe/dsl_*
-#      }
        echo $PS | grep -q dsl_cpe_control || {
-               echo "Start of dsl_cpe_control failed!!!"
+               echo "Start of dsl_cpe_control failed!"
                false
        }
-
 }
Index: package/ltq-dsl-app/Makefile
===================================================================
--- package/ltq-dsl-app/Makefile        (revision 29875)
+++ package/ltq-dsl-app/Makefile        (working copy)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2011 OpenWrt.org
+# Copyright (C) 2011-2012 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -87,10 +87,10 @@
 
 define Package/ltq-dsl-app/install
        $(INSTALL_DIR) $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/ifx_cpe_control_init.sh $(1)/etc/init.d/
-
+       $(INSTALL_BIN) ./files/ifx_cpe_control_init.sh $(1)/etc/init.d
        $(INSTALL_DIR) $(1)/sbin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin
+       $(INSTALL_BIN) ./files/dsl_notify.sh $(1)/sbin
 endef
 
 $(eval $(call BuildPackage,ltq-dsl-app))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to