diff options
| author | makefu <github@syntax-fehler.de> | 2013-07-06 02:20:51 +0200 | 
|---|---|---|
| committer | makefu <github@syntax-fehler.de> | 2013-07-06 02:20:51 +0200 | 
| commit | 99762c1f22ece68c5fa22271de14d56045f0ed6f (patch) | |
| tree | 835baa4217e084e158172bf18e9f615010fd00e2 | |
| parent | 3541ac3154d5e23583054b2ef40a8d918203a33d (diff) | |
add optware for udhcpc
| -rw-r--r-- | usr/lib/autowifi/lib/network | 3 | ||||
| -rwxr-xr-x | usr/lib/autowifi/opt/udhcpc.run | 70 | 
2 files changed, 72 insertions, 1 deletions
diff --git a/usr/lib/autowifi/lib/network b/usr/lib/autowifi/lib/network index 820ccad6..5394e7c9 100644 --- a/usr/lib/autowifi/lib/network +++ b/usr/lib/autowifi/lib/network @@ -32,7 +32,8 @@ ip_start(){              elif exists udhcpc; then                  PIDFILE=/var/run/udhcpc-${interface}.pid                  [ -e $PIDFILE ] && kill `cat $PIDFILE` ||: -                udhcpc -n -i $interface -s /lib/netifd/dhcp.script -C -p /var/run/udhcpc-${interface}.pid +                udhcpc -n -p $PIDFILE -i $interface -s \ +                    "$root/usr/lib/autowifi/opt/udhcpc.run"              fi ;;          *) echo "do not know ip starter $1" >&2;;      esac diff --git a/usr/lib/autowifi/opt/udhcpc.run b/usr/lib/autowifi/opt/udhcpc.run new file mode 100755 index 00000000..2e1b919f --- /dev/null +++ b/usr/lib/autowifi/opt/udhcpc.run @@ -0,0 +1,70 @@ +#!/bin/sh +# shamelessly stolen from http://www.doit.org/udhcpc/S50default + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +RESOLV_CONF="/etc/resolv.conf" + +update_interface() +{ +  [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +  [ -n "$subnet" ] && NETMASK="netmask $subnet" +  ifconfig $interface $ip $BROADCAST $NETMASK +} + +update_routes() +{ +  if [ -n "$router" ] +  then +    echo "deleting routes" +    while route del default gw 0.0.0.0 dev $interface +    do : +    done + +    for i in $router +    do +      route add default gw $i dev $interface +    done +  fi +} + +update_dns() +{ +  echo -n > $RESOLV_CONF +  [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF +  for i in $dns +  do +    echo adding dns $i +    echo nameserver $i >> $RESOLV_CONF +  done +} + +deconfig() +{ +  ifconfig $interface 0.0.0.0 +} + +case "$1" in +  bound) +    update_interface; +    update_routes; +    update_dns; +  ;; + +  renew) +    update_interface; +    update_routes; +    update_dns; +  ;; + +  deconfig) +    deconfig; +  ;; + +  *) +    echo "Usage: $0 {bound|renew|deconfig}" +    exit 1 +    ;; +esac + +exit 0  | 
