summaryrefslogtreecommitdiffstats
path: root/recon/autowifi/usr/lib/autowifi/opt/udhcpc.run
diff options
context:
space:
mode:
Diffstat (limited to 'recon/autowifi/usr/lib/autowifi/opt/udhcpc.run')
-rwxr-xr-xrecon/autowifi/usr/lib/autowifi/opt/udhcpc.run70
1 files changed, 70 insertions, 0 deletions
diff --git a/recon/autowifi/usr/lib/autowifi/opt/udhcpc.run b/recon/autowifi/usr/lib/autowifi/opt/udhcpc.run
new file mode 100755
index 00000000..2e1b919f
--- /dev/null
+++ b/recon/autowifi/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