Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/examples/udhcp/simple.script

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Sat Sep 1 22:45:15 2007 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
   
2  # udhcpc script edited by Tim Riker <Tim@Rikers.org>  # udhcpc script edited by Tim Riker <Tim@Rikers.org>
3    
 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1  
   
4  RESOLV_CONF="/etc/resolv.conf"  RESOLV_CONF="/etc/resolv.conf"
5  [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"  
6    [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
7    
8    NETMASK=""
9  [ -n "$subnet" ] && NETMASK="netmask $subnet"  [ -n "$subnet" ] && NETMASK="netmask $subnet"
10    BROADCAST="broadcast +"
11    [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
12    
13  case "$1" in  case "$1" in
14   deconfig)   deconfig)
15   /sbin/ifconfig $interface 0.0.0.0   echo "Setting IP address 0.0.0.0 on $interface"
16     ifconfig $interface 0.0.0.0
17   ;;   ;;
18    
19   renew|bound)   renew|bound)
20   /sbin/ifconfig $interface $ip $BROADCAST $NETMASK   echo "Setting IP address $ip on $interface"
21     ifconfig $interface $ip $NETMASK $BROADCAST
22    
23   if [ -n "$router" ] ; then   if [ -n "$router" ] ; then
24   echo "deleting routers"   echo "Deleting routers"
25   while route del default gw 0.0.0.0 dev $interface ; do   while route del default gw 0.0.0.0 dev $interface ; do
26   :   :
27   done   done
28    
29   metric=0   metric=0
30   for i in $router ; do   for i in $router ; do
31     echo "Adding router $i"
32   route add default gw $i dev $interface metric $((metric++))   route add default gw $i dev $interface metric $((metric++))
33   done   done
34   fi   fi
35    
36   echo -n > $RESOLV_CONF   echo "Recreating $RESOLV_CONF"
37   [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF   echo -n > $RESOLV_CONF-$$
38     [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
39   for i in $dns ; do   for i in $dns ; do
40   echo adding dns $i   echo " Adding DNS server $i"
41   echo nameserver $i >> $RESOLV_CONF   echo "nameserver $i" >> $RESOLV_CONF-$$
42   done   done
43     mv $RESOLV_CONF-$$ $RESOLV_CONF
44   ;;   ;;
45  esac  esac
46    

Legend:
Removed from v.983  
changed lines
  Added in v.984