I'd like to propose the following patch to
package/ppp/files/etc/ppp/ip-up.  It means that hotplug scripts can
source the network state and get information about the newly plumbed ppp
interface.

Signed off by: Brian J. Murrell <[EMAIL PROTECTED]>

Index: package/ppp/files/etc/ppp/ip-up
===================================================================
--- package/ppp/files/etc/ppp/ip-up     (revision 10709)
+++ package/ppp/files/etc/ppp/ip-up     (working copy)
@@ -6,11 +6,11 @@
 PPP_REMOTE="$5"
 PPP_IPPARAM="$6"
 export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
-[ -z "$PPP_IPPARAM" ] || env -i ACTION="ifup" INTERFACE="$PPP_IPPARAM" 
DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
 [ -z "$PPP_IPPARAM" -o -z "$PPP_LOCAL" ] || {
        uci_set_state network "$PPP_IPPARAM" ipaddr "$PPP_LOCAL"
        uci_set_state network "$PPP_IPPARAM" gateway "$PPP_REMOTE"
 }
+[ -z "$PPP_IPPARAM" ] || env -i ACTION="ifup" INTERFACE="$PPP_IPPARAM" 
DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
 
 
 [ -d /etc/ppp/ip-up.d ] && {

The need for the above patch was discovered by a new hotplug script I
created in hotplug.d/iface/01-hosts that I'd like to propose for
addition to the standard hotplug scripts.

Signed off by: Brian J. Murrell <[EMAIL PROTECTED]>

config_load network
config_get ifname "$INTERFACE" ifname

config_load /var/state/network

# standard hosts file already has a loopback/localhost entry
[ "$INTERFACE" = loopback ] && exit 0

# need to wait for others to be done
n=0
while [ -f /tmp/edit_hosts -a $n -lt 5 ]; do
        sleep 1
        let n=n+1
done

[ -f /tmp/edit_hosts ] && {
        logger "Unable to update /etc/hosts due to lock file /tmp/edit_hosts 
being present for more than 5 seconds"
        exit 0
}

# tell others we are working
echo $$ > /tmp/edit_hosts

[ ifup = "$ACTION" ] && {
        config_get addr "$INTERFACE" ipaddr

        [ -n "$addr" ] && \
                sed -i -e "/^.* $INTERFACE$/d" -e "\$a$addr     $INTERFACE" 
/etc/hosts
}

[ ifdown = "$ACTION" ] && {
        sed -i -e "/^.* $INTERFACE$/d" /etc/hosts
}

rm -f /tmp/edit_hosts

The result of that script after a reboot of my router is:

[EMAIL PROTECTED]:~# cat /etc/hosts
127.0.0.1 localhost.
10.75.22.254    lan
33.1.73.242     wan1
167.9.10.202    wan0

Cheers,
b.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to