Home | History | Annotate | Line # | Download | only in scripts
netbsd revision 1.1.1.1.2.2
      1  1.1.1.1.2.2  pgoyette #!/bin/sh
      2  1.1.1.1.2.2  pgoyette 
      3  1.1.1.1.2.2  pgoyette make_resolv_conf() {
      4  1.1.1.1.2.2  pgoyette   if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
      5  1.1.1.1.2.2  pgoyette     cat /dev/null > /etc/resolv.conf.dhclient
      6  1.1.1.1.2.2  pgoyette     if [ "x$new_domain_search" != x ]; then
      7  1.1.1.1.2.2  pgoyette       echo search $new_domain_search >> /etc/resolv.conf.dhclient
      8  1.1.1.1.2.2  pgoyette     elif [ "x$new_domain_name" != x ]; then
      9  1.1.1.1.2.2  pgoyette       # Note that the DHCP 'Domain Name Option' is really just a domain
     10  1.1.1.1.2.2  pgoyette       # name, and that this practice of using the domain name option as
     11  1.1.1.1.2.2  pgoyette       # a search path is both nonstandard and deprecated.
     12  1.1.1.1.2.2  pgoyette       echo search $new_domain_name >> /etc/resolv.conf.dhclient
     13  1.1.1.1.2.2  pgoyette     fi
     14  1.1.1.1.2.2  pgoyette     for nameserver in $new_domain_name_servers; do
     15  1.1.1.1.2.2  pgoyette       echo nameserver $nameserver >>/etc/resolv.conf.dhclient
     16  1.1.1.1.2.2  pgoyette     done
     17  1.1.1.1.2.2  pgoyette 
     18  1.1.1.1.2.2  pgoyette     mv /etc/resolv.conf.dhclient /etc/resolv.conf
     19  1.1.1.1.2.2  pgoyette   elif [ "x${new_dhcp6_name_servers}" != x ] ; then
     20  1.1.1.1.2.2  pgoyette     cat /dev/null > /etc/resolv.conf.dhclient6
     21  1.1.1.1.2.2  pgoyette     chmod 644 /etc/resolv.conf.dhclient6
     22  1.1.1.1.2.2  pgoyette 
     23  1.1.1.1.2.2  pgoyette     if [ "x${new_dhcp6_domain_search}" != x ] ; then
     24  1.1.1.1.2.2  pgoyette       echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
     25  1.1.1.1.2.2  pgoyette     fi
     26  1.1.1.1.2.2  pgoyette     for nameserver in ${new_dhcp6_name_servers} ; do
     27  1.1.1.1.2.2  pgoyette       # If the nameserver has a link-local address
     28  1.1.1.1.2.2  pgoyette       # add a <zone_id> (interface name) to it.
     29  1.1.1.1.2.2  pgoyette       case $nameserver in
     30  1.1.1.1.2.2  pgoyette 	fe80:*) zone_id="%$interface";;
     31  1.1.1.1.2.2  pgoyette 	FE80:*) zone_id="%$interface";;
     32  1.1.1.1.2.2  pgoyette 	*)      zone_id="";;
     33  1.1.1.1.2.2  pgoyette       esac
     34  1.1.1.1.2.2  pgoyette       echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
     35  1.1.1.1.2.2  pgoyette     done
     36  1.1.1.1.2.2  pgoyette 
     37  1.1.1.1.2.2  pgoyette     mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
     38  1.1.1.1.2.2  pgoyette   fi
     39  1.1.1.1.2.2  pgoyette }
     40  1.1.1.1.2.2  pgoyette 
     41  1.1.1.1.2.2  pgoyette # Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
     42  1.1.1.1.2.2  pgoyette exit_with_hooks() {
     43  1.1.1.1.2.2  pgoyette   exit_status=$1
     44  1.1.1.1.2.2  pgoyette   if [ -f /etc/dhclient-exit-hooks ]; then
     45  1.1.1.1.2.2  pgoyette     . /etc/dhclient-exit-hooks
     46  1.1.1.1.2.2  pgoyette   fi
     47  1.1.1.1.2.2  pgoyette # probably should do something with exit status of the local script
     48  1.1.1.1.2.2  pgoyette   exit $exit_status
     49  1.1.1.1.2.2  pgoyette }
     50  1.1.1.1.2.2  pgoyette 
     51  1.1.1.1.2.2  pgoyette # This function was largely borrowed from dhclient-script that
     52  1.1.1.1.2.2  pgoyette # ships with Centos, authored by Jiri Popelka and David Cantrell
     53  1.1.1.1.2.2  pgoyette # of Redhat. Thanks guys.
     54  1.1.1.1.2.2  pgoyette add_ipv6_addr_with_DAD() {
     55  1.1.1.1.2.2  pgoyette     ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
     56  1.1.1.1.2.2  pgoyette 
     57  1.1.1.1.2.2  pgoyette     if [ ${dad_wait_time} -le 0 ]
     58  1.1.1.1.2.2  pgoyette     then
     59  1.1.1.1.2.2  pgoyette         # if we're not waiting for DAD, assume we're good
     60  1.1.1.1.2.2  pgoyette         return 0
     61  1.1.1.1.2.2  pgoyette     fi
     62  1.1.1.1.2.2  pgoyette 
     63  1.1.1.1.2.2  pgoyette     # Repeatedly test whether newly added address passed
     64  1.1.1.1.2.2  pgoyette     # duplicate address detection (DAD)
     65  1.1.1.1.2.2  pgoyette     for i in $(seq 1 ${dad_wait_time}); do
     66  1.1.1.1.2.2  pgoyette         sleep 1 # give the DAD some time
     67  1.1.1.1.2.2  pgoyette 
     68  1.1.1.1.2.2  pgoyette         addr=$(ifconfig ${interface} \
     69  1.1.1.1.2.2  pgoyette             | grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")
     70  1.1.1.1.2.2  pgoyette 
     71  1.1.1.1.2.2  pgoyette         # tentative flag == DAD is still not complete
     72  1.1.1.1.2.2  pgoyette         tentative=$(echo "${addr}" | grep tentative)
     73  1.1.1.1.2.2  pgoyette         # dadfailed flag == address is already in use somewhere else
     74  1.1.1.1.2.2  pgoyette         dadfailed=$(echo "${addr}" | grep duplicated)
     75  1.1.1.1.2.2  pgoyette 
     76  1.1.1.1.2.2  pgoyette         if [ -n "${dadfailed}" ] ; then
     77  1.1.1.1.2.2  pgoyette             # dad failed, remove the address
     78  1.1.1.1.2.2  pgoyette             ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -alias
     79  1.1.1.1.2.2  pgoyette             exit_with_hooks 3
     80  1.1.1.1.2.2  pgoyette         fi
     81  1.1.1.1.2.2  pgoyette 
     82  1.1.1.1.2.2  pgoyette         if [ -z "${tentative}" ] ; then
     83  1.1.1.1.2.2  pgoyette             if [ -n "${addr}" ]; then
     84  1.1.1.1.2.2  pgoyette                 # DAD is over
     85  1.1.1.1.2.2  pgoyette                 return 0
     86  1.1.1.1.2.2  pgoyette             else
     87  1.1.1.1.2.2  pgoyette                 # address was auto-removed (or not added at all)
     88  1.1.1.1.2.2  pgoyette                 exit_with_hooks 3
     89  1.1.1.1.2.2  pgoyette             fi
     90  1.1.1.1.2.2  pgoyette         fi
     91  1.1.1.1.2.2  pgoyette     done
     92  1.1.1.1.2.2  pgoyette 
     93  1.1.1.1.2.2  pgoyette     return 0
     94  1.1.1.1.2.2  pgoyette }
     95  1.1.1.1.2.2  pgoyette 
     96  1.1.1.1.2.2  pgoyette # Invoke the local dhcp client enter hooks, if they exist.
     97  1.1.1.1.2.2  pgoyette if [ -f /etc/dhclient-enter-hooks ]; then
     98  1.1.1.1.2.2  pgoyette   exit_status=0
     99  1.1.1.1.2.2  pgoyette   . /etc/dhclient-enter-hooks
    100  1.1.1.1.2.2  pgoyette   # allow the local script to abort processing of this state
    101  1.1.1.1.2.2  pgoyette   # local script must set exit_status variable to nonzero.
    102  1.1.1.1.2.2  pgoyette   if [ $exit_status -ne 0 ]; then
    103  1.1.1.1.2.2  pgoyette     exit $exit_status
    104  1.1.1.1.2.2  pgoyette   fi
    105  1.1.1.1.2.2  pgoyette fi
    106  1.1.1.1.2.2  pgoyette 
    107  1.1.1.1.2.2  pgoyette if [ x$new_network_number != x ]; then
    108  1.1.1.1.2.2  pgoyette    echo New Network Number: $new_network_number
    109  1.1.1.1.2.2  pgoyette fi
    110  1.1.1.1.2.2  pgoyette 
    111  1.1.1.1.2.2  pgoyette if [ x$new_broadcast_address != x ]; then
    112  1.1.1.1.2.2  pgoyette  echo New Broadcast Address: $new_broadcast_address
    113  1.1.1.1.2.2  pgoyette   new_broadcast_arg="broadcast $new_broadcast_address"
    114  1.1.1.1.2.2  pgoyette fi
    115  1.1.1.1.2.2  pgoyette if [ x$old_broadcast_address != x ]; then
    116  1.1.1.1.2.2  pgoyette   old_broadcast_arg="broadcast $old_broadcast_address"
    117  1.1.1.1.2.2  pgoyette fi
    118  1.1.1.1.2.2  pgoyette if [ x$new_subnet_mask != x ]; then
    119  1.1.1.1.2.2  pgoyette   new_netmask_arg="netmask $new_subnet_mask"
    120  1.1.1.1.2.2  pgoyette fi
    121  1.1.1.1.2.2  pgoyette if [ x$old_subnet_mask != x ]; then
    122  1.1.1.1.2.2  pgoyette   old_netmask_arg="netmask $old_subnet_mask"
    123  1.1.1.1.2.2  pgoyette fi
    124  1.1.1.1.2.2  pgoyette if [ x$alias_subnet_mask != x ]; then
    125  1.1.1.1.2.2  pgoyette   alias_subnet_arg="netmask $alias_subnet_mask"
    126  1.1.1.1.2.2  pgoyette fi
    127  1.1.1.1.2.2  pgoyette  if [ x$new_interface_mtu != x ]; then
    128  1.1.1.1.2.2  pgoyette    mtu_arg="mtu $new_interface_mtu"
    129  1.1.1.1.2.2  pgoyette  fi
    130  1.1.1.1.2.2  pgoyette if [ x$IF_METRIC != x ]; then
    131  1.1.1.1.2.2  pgoyette   metric_arg="metric $IF_METRIC"
    132  1.1.1.1.2.2  pgoyette fi
    133  1.1.1.1.2.2  pgoyette 
    134  1.1.1.1.2.2  pgoyette if [ x$reason = xMEDIUM ]; then
    135  1.1.1.1.2.2  pgoyette   eval "ifconfig $interface $medium"
    136  1.1.1.1.2.2  pgoyette   eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
    137  1.1.1.1.2.2  pgoyette   sleep 1
    138  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    139  1.1.1.1.2.2  pgoyette fi
    140  1.1.1.1.2.2  pgoyette 
    141  1.1.1.1.2.2  pgoyette ###
    142  1.1.1.1.2.2  pgoyette ### DHCPv4 Handlers
    143  1.1.1.1.2.2  pgoyette ###
    144  1.1.1.1.2.2  pgoyette 
    145  1.1.1.1.2.2  pgoyette if [ x$reason = xPREINIT ]; then
    146  1.1.1.1.2.2  pgoyette   if [ x$alias_ip_address != x ]; then
    147  1.1.1.1.2.2  pgoyette     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    148  1.1.1.1.2.2  pgoyette     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
    149  1.1.1.1.2.2  pgoyette   fi
    150  1.1.1.1.2.2  pgoyette   ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
    151  1.1.1.1.2.2  pgoyette 		broadcast 255.255.255.255 up
    152  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    153  1.1.1.1.2.2  pgoyette fi
    154  1.1.1.1.2.2  pgoyette 
    155  1.1.1.1.2.2  pgoyette if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
    156  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    157  1.1.1.1.2.2  pgoyette fi
    158  1.1.1.1.2.2  pgoyette   
    159  1.1.1.1.2.2  pgoyette if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
    160  1.1.1.1.2.2  pgoyette    [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
    161  1.1.1.1.2.2  pgoyette   current_hostname=`hostname`
    162  1.1.1.1.2.2  pgoyette   if [ x$current_hostname = x ] || \
    163  1.1.1.1.2.2  pgoyette      [ x$current_hostname = x$old_host_name ]; then
    164  1.1.1.1.2.2  pgoyette     if [ x$current_hostname = x ] || \
    165  1.1.1.1.2.2  pgoyette        [ x$new_host_name != x$old_host_name ]; then
    166  1.1.1.1.2.2  pgoyette       hostname $new_host_name
    167  1.1.1.1.2.2  pgoyette     fi
    168  1.1.1.1.2.2  pgoyette   fi
    169  1.1.1.1.2.2  pgoyette     
    170  1.1.1.1.2.2  pgoyette   if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
    171  1.1.1.1.2.2  pgoyette 		[ x$alias_ip_address != x$old_ip_address ]; then
    172  1.1.1.1.2.2  pgoyette     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    173  1.1.1.1.2.2  pgoyette     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
    174  1.1.1.1.2.2  pgoyette   fi
    175  1.1.1.1.2.2  pgoyette   if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
    176  1.1.1.1.2.2  pgoyette    then
    177  1.1.1.1.2.2  pgoyette     eval "ifconfig $interface inet -alias $old_ip_address $medium"
    178  1.1.1.1.2.2  pgoyette     route delete $old_ip_address 127.1 >/dev/null 2>&1
    179  1.1.1.1.2.2  pgoyette     for router in $old_routers; do
    180  1.1.1.1.2.2  pgoyette       route delete default $router >/dev/null 2>&1
    181  1.1.1.1.2.2  pgoyette     done
    182  1.1.1.1.2.2  pgoyette     if [ "$old_static_routes" != "" ]; then
    183  1.1.1.1.2.2  pgoyette       set $old_static_routes
    184  1.1.1.1.2.2  pgoyette       while [ $# -gt 1 ]; do
    185  1.1.1.1.2.2  pgoyette 	route delete $1 $2
    186  1.1.1.1.2.2  pgoyette 	shift; shift
    187  1.1.1.1.2.2  pgoyette       done
    188  1.1.1.1.2.2  pgoyette     fi
    189  1.1.1.1.2.2  pgoyette     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
    190  1.1.1.1.2.2  pgoyette   fi
    191  1.1.1.1.2.2  pgoyette   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
    192  1.1.1.1.2.2  pgoyette      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
    193  1.1.1.1.2.2  pgoyette     eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
    194  1.1.1.1.2.2  pgoyette 			$new_broadcast_arg $mtu_arg $metric_arg $medium"
    195  1.1.1.1.2.2  pgoyette     route add $new_ip_address 127.1 >/dev/null 2>&1
    196  1.1.1.1.2.2  pgoyette     for router in $new_routers; do
    197  1.1.1.1.2.2  pgoyette       route add default $router >/dev/null 2>&1
    198  1.1.1.1.2.2  pgoyette     done
    199  1.1.1.1.2.2  pgoyette     if [ "$new_static_routes" != "" ]; then
    200  1.1.1.1.2.2  pgoyette       set $new_static_routes
    201  1.1.1.1.2.2  pgoyette       while [ $# -gt 1 ]; do
    202  1.1.1.1.2.2  pgoyette 	route add $1 $2
    203  1.1.1.1.2.2  pgoyette 	shift; shift
    204  1.1.1.1.2.2  pgoyette       done
    205  1.1.1.1.2.2  pgoyette     fi
    206  1.1.1.1.2.2  pgoyette   else                                                                        
    207  1.1.1.1.2.2  pgoyette     # we haven't changed the address, have we changed other options           
    208  1.1.1.1.2.2  pgoyette     # that we wish to update?
    209  1.1.1.1.2.2  pgoyette     if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
    210  1.1.1.1.2.2  pgoyette       # if we've changed routers delete the old and add the new.
    211  1.1.1.1.2.2  pgoyette       $LOGGER "New Routers: $new_routers"
    212  1.1.1.1.2.2  pgoyette       for router in $old_routers; do
    213  1.1.1.1.2.2  pgoyette         route delete default $router >/dev/null 2>&1
    214  1.1.1.1.2.2  pgoyette       done
    215  1.1.1.1.2.2  pgoyette       for router in $new_routers; do
    216  1.1.1.1.2.2  pgoyette         route add default $router >/dev/null 2>&1
    217  1.1.1.1.2.2  pgoyette       done
    218  1.1.1.1.2.2  pgoyette     fi
    219  1.1.1.1.2.2  pgoyette   fi
    220  1.1.1.1.2.2  pgoyette   if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
    221  1.1.1.1.2.2  pgoyette    then
    222  1.1.1.1.2.2  pgoyette     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
    223  1.1.1.1.2.2  pgoyette     route add $alias_ip_address 127.0.0.1
    224  1.1.1.1.2.2  pgoyette   fi
    225  1.1.1.1.2.2  pgoyette   make_resolv_conf
    226  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    227  1.1.1.1.2.2  pgoyette fi
    228  1.1.1.1.2.2  pgoyette 
    229  1.1.1.1.2.2  pgoyette if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
    230  1.1.1.1.2.2  pgoyette    || [ x$reason = xSTOP ]; then
    231  1.1.1.1.2.2  pgoyette   if [ x$alias_ip_address != x ]; then
    232  1.1.1.1.2.2  pgoyette     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    233  1.1.1.1.2.2  pgoyette     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
    234  1.1.1.1.2.2  pgoyette   fi
    235  1.1.1.1.2.2  pgoyette   if [ x$old_ip_address != x ]; then
    236  1.1.1.1.2.2  pgoyette     eval "ifconfig $interface inet -alias $old_ip_address $medium"
    237  1.1.1.1.2.2  pgoyette     route delete $old_ip_address 127.1 >/dev/null 2>&1
    238  1.1.1.1.2.2  pgoyette     for router in $old_routers; do
    239  1.1.1.1.2.2  pgoyette       route delete default $router >/dev/null 2>&1
    240  1.1.1.1.2.2  pgoyette     done
    241  1.1.1.1.2.2  pgoyette     if [ "$old_static_routes" != "" ]; then
    242  1.1.1.1.2.2  pgoyette       set $old_static_routes
    243  1.1.1.1.2.2  pgoyette       while [ $# -gt 1 ]; do
    244  1.1.1.1.2.2  pgoyette 	route delete $1 $2
    245  1.1.1.1.2.2  pgoyette 	shift; shift
    246  1.1.1.1.2.2  pgoyette       done
    247  1.1.1.1.2.2  pgoyette     fi
    248  1.1.1.1.2.2  pgoyette     arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
    249  1.1.1.1.2.2  pgoyette 						|sh >/dev/null 2>&1
    250  1.1.1.1.2.2  pgoyette   fi
    251  1.1.1.1.2.2  pgoyette   if [ x$alias_ip_address != x ]; then
    252  1.1.1.1.2.2  pgoyette     ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
    253  1.1.1.1.2.2  pgoyette     route add $alias_ip_address 127.0.0.1
    254  1.1.1.1.2.2  pgoyette   fi
    255  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    256  1.1.1.1.2.2  pgoyette fi
    257  1.1.1.1.2.2  pgoyette 
    258  1.1.1.1.2.2  pgoyette if [ x$reason = xTIMEOUT ]; then
    259  1.1.1.1.2.2  pgoyette   if [ x$alias_ip_address != x ]; then
    260  1.1.1.1.2.2  pgoyette     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
    261  1.1.1.1.2.2  pgoyette     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
    262  1.1.1.1.2.2  pgoyette   fi
    263  1.1.1.1.2.2  pgoyette   eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
    264  1.1.1.1.2.2  pgoyette 			$new_broadcast_arg $mtu_arg $metric_arg $medium"
    265  1.1.1.1.2.2  pgoyette   sleep 1
    266  1.1.1.1.2.2  pgoyette   if [ "$new_routers" != "" ]; then
    267  1.1.1.1.2.2  pgoyette     set $new_routers
    268  1.1.1.1.2.2  pgoyette     if ping -q -c 1 -w 1 $1; then
    269  1.1.1.1.2.2  pgoyette       if [ x$new_ip_address != x$alias_ip_address ] && \
    270  1.1.1.1.2.2  pgoyette 			[ x$alias_ip_address != x ]; then
    271  1.1.1.1.2.2  pgoyette 	ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
    272  1.1.1.1.2.2  pgoyette 	route add $alias_ip_address 127.0.0.1
    273  1.1.1.1.2.2  pgoyette       fi
    274  1.1.1.1.2.2  pgoyette       route add $new_ip_address 127.1 >/dev/null 2>&1
    275  1.1.1.1.2.2  pgoyette       for router in $new_routers; do
    276  1.1.1.1.2.2  pgoyette 	route add default $router >/dev/null 2>&1
    277  1.1.1.1.2.2  pgoyette       done
    278  1.1.1.1.2.2  pgoyette       set $new_static_routes
    279  1.1.1.1.2.2  pgoyette       while [ $# -gt 1 ]; do
    280  1.1.1.1.2.2  pgoyette 	route add $0 $1
    281  1.1.1.1.2.2  pgoyette 	shift; shift
    282  1.1.1.1.2.2  pgoyette       done
    283  1.1.1.1.2.2  pgoyette       make_resolv_conf
    284  1.1.1.1.2.2  pgoyette       exit_with_hooks 0
    285  1.1.1.1.2.2  pgoyette     fi
    286  1.1.1.1.2.2  pgoyette   fi
    287  1.1.1.1.2.2  pgoyette   eval "ifconfig $interface inet -alias $new_ip_address $medium"
    288  1.1.1.1.2.2  pgoyette   for router in $old_routers; do
    289  1.1.1.1.2.2  pgoyette     route delete default $router >/dev/null 2>&1
    290  1.1.1.1.2.2  pgoyette   done
    291  1.1.1.1.2.2  pgoyette   if [ "$old_static_routes" != "" ]; then
    292  1.1.1.1.2.2  pgoyette     set $old_static_routes
    293  1.1.1.1.2.2  pgoyette     while [ $# -gt 1 ]; do
    294  1.1.1.1.2.2  pgoyette       route delete $1 $2
    295  1.1.1.1.2.2  pgoyette       shift; shift
    296  1.1.1.1.2.2  pgoyette     done
    297  1.1.1.1.2.2  pgoyette   fi
    298  1.1.1.1.2.2  pgoyette   arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
    299  1.1.1.1.2.2  pgoyette 							|sh >/dev/null 2>&1
    300  1.1.1.1.2.2  pgoyette   exit_with_hooks 1
    301  1.1.1.1.2.2  pgoyette fi
    302  1.1.1.1.2.2  pgoyette 
    303  1.1.1.1.2.2  pgoyette ###
    304  1.1.1.1.2.2  pgoyette ### DHCPv6 Handlers
    305  1.1.1.1.2.2  pgoyette ###
    306  1.1.1.1.2.2  pgoyette 
    307  1.1.1.1.2.2  pgoyette if [ ${reason} = PREINIT6 ] ; then
    308  1.1.1.1.2.2  pgoyette   # Ensure interface is up.
    309  1.1.1.1.2.2  pgoyette   ifconfig ${interface} up
    310  1.1.1.1.2.2  pgoyette 
    311  1.1.1.1.2.2  pgoyette   # XXX: Remove any stale addresses from aborted clients.
    312  1.1.1.1.2.2  pgoyette 
    313  1.1.1.1.2.2  pgoyette   # We need to give the kernel some time to active interface
    314  1.1.1.1.2.2  pgoyette   interface_up_wait_time=5
    315  1.1.1.1.2.2  pgoyette   for i in $(seq 0 ${interface_up_wait_time})
    316  1.1.1.1.2.2  pgoyette   do
    317  1.1.1.1.2.2  pgoyette       ifconfig ${interface} | grep inactive >/dev/null 2>&1
    318  1.1.1.1.2.2  pgoyette       if [ $? -ne 0 ]; then
    319  1.1.1.1.2.2  pgoyette           break;
    320  1.1.1.1.2.2  pgoyette       fi
    321  1.1.1.1.2.2  pgoyette       sleep 1
    322  1.1.1.1.2.2  pgoyette   done
    323  1.1.1.1.2.2  pgoyette 
    324  1.1.1.1.2.2  pgoyette   # Wait for duplicate address detection for this interface if the
    325  1.1.1.1.2.2  pgoyette   # --dad-wait-time parameter has been specified and is greater than
    326  1.1.1.1.2.2  pgoyette   # zero.
    327  1.1.1.1.2.2  pgoyette   if [ ${dad_wait_time} -gt 0 ]; then
    328  1.1.1.1.2.2  pgoyette       # Check if any IPv6 address on this interface is marked as
    329  1.1.1.1.2.2  pgoyette       # tentative.
    330  1.1.1.1.2.2  pgoyette       ifconfig ${interface} | grep inet6 | grep tentative \
    331  1.1.1.1.2.2  pgoyette           >/dev/null 2>&1
    332  1.1.1.1.2.2  pgoyette       if [ $? -eq 0 ]; then
    333  1.1.1.1.2.2  pgoyette           # Wait for duplicate address detection to complete or for
    334  1.1.1.1.2.2  pgoyette           # the timeout specified as --dad-wait-time.
    335  1.1.1.1.2.2  pgoyette           for i in $(seq 0 $dad_wait_time)
    336  1.1.1.1.2.2  pgoyette           do
    337  1.1.1.1.2.2  pgoyette               # We're going to poll for the tentative flag every second.
    338  1.1.1.1.2.2  pgoyette               sleep 1
    339  1.1.1.1.2.2  pgoyette               ifconfig ${interface} | grep inet6 | grep tentative \
    340  1.1.1.1.2.2  pgoyette                   >/dev/null 2>&1
    341  1.1.1.1.2.2  pgoyette               if [ $? -ne 0 ]; then
    342  1.1.1.1.2.2  pgoyette                   break;
    343  1.1.1.1.2.2  pgoyette               fi
    344  1.1.1.1.2.2  pgoyette           done
    345  1.1.1.1.2.2  pgoyette       fi
    346  1.1.1.1.2.2  pgoyette   fi
    347  1.1.1.1.2.2  pgoyette 
    348  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    349  1.1.1.1.2.2  pgoyette fi
    350  1.1.1.1.2.2  pgoyette 
    351  1.1.1.1.2.2  pgoyette if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
    352  1.1.1.1.2.2  pgoyette     echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
    353  1.1.1.1.2.2  pgoyette 
    354  1.1.1.1.2.2  pgoyette     exit_with_hooks 0
    355  1.1.1.1.2.2  pgoyette fi
    356  1.1.1.1.2.2  pgoyette 
    357  1.1.1.1.2.2  pgoyette if [ ${reason} = BOUND6 ] ; then
    358  1.1.1.1.2.2  pgoyette   if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
    359  1.1.1.1.2.2  pgoyette     exit_with_hooks 2;
    360  1.1.1.1.2.2  pgoyette   fi
    361  1.1.1.1.2.2  pgoyette 
    362  1.1.1.1.2.2  pgoyette   # Add address to interface, check for DAD if dad_wait_time > 0
    363  1.1.1.1.2.2  pgoyette   add_ipv6_addr_with_DAD
    364  1.1.1.1.2.2  pgoyette 
    365  1.1.1.1.2.2  pgoyette   # Check for nameserver options.
    366  1.1.1.1.2.2  pgoyette   make_resolv_conf
    367  1.1.1.1.2.2  pgoyette 
    368  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    369  1.1.1.1.2.2  pgoyette fi
    370  1.1.1.1.2.2  pgoyette 
    371  1.1.1.1.2.2  pgoyette if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
    372  1.1.1.1.2.2  pgoyette   # Make sure nothing has moved around on us.
    373  1.1.1.1.2.2  pgoyette 
    374  1.1.1.1.2.2  pgoyette   # Nameservers/domains/etc.
    375  1.1.1.1.2.2  pgoyette   if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
    376  1.1.1.1.2.2  pgoyette      [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
    377  1.1.1.1.2.2  pgoyette     make_resolv_conf
    378  1.1.1.1.2.2  pgoyette   fi
    379  1.1.1.1.2.2  pgoyette 
    380  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    381  1.1.1.1.2.2  pgoyette fi
    382  1.1.1.1.2.2  pgoyette 
    383  1.1.1.1.2.2  pgoyette if [ ${reason} = DEPREF6 ] ; then
    384  1.1.1.1.2.2  pgoyette   if [ x${new_ip6_prefixlen} = x ] ; then
    385  1.1.1.1.2.2  pgoyette     exit_with_hooks 2;
    386  1.1.1.1.2.2  pgoyette   fi
    387  1.1.1.1.2.2  pgoyette 
    388  1.1.1.1.2.2  pgoyette   # XXX:
    389  1.1.1.1.2.2  pgoyette   # There doesn't appear to be a way to update an addr to indicate
    390  1.1.1.1.2.2  pgoyette   # preference.
    391  1.1.1.1.2.2  pgoyette 
    392  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    393  1.1.1.1.2.2  pgoyette fi
    394  1.1.1.1.2.2  pgoyette 
    395  1.1.1.1.2.2  pgoyette if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
    396  1.1.1.1.2.2  pgoyette   if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
    397  1.1.1.1.2.2  pgoyette     exit_with_hooks 2;
    398  1.1.1.1.2.2  pgoyette   fi
    399  1.1.1.1.2.2  pgoyette 
    400  1.1.1.1.2.2  pgoyette   ifconfig ${interface} inet6 -alias ${old_ip6_address}/${old_ip6_prefixlen}
    401  1.1.1.1.2.2  pgoyette 
    402  1.1.1.1.2.2  pgoyette   exit_with_hooks 0
    403  1.1.1.1.2.2  pgoyette fi
    404  1.1.1.1.2.2  pgoyette 
    405  1.1.1.1.2.2  pgoyette exit_with_hooks 0
    406