1#!/bin/sh 2# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. 3# 4# Based on the busybox example scripts and the old udhcp source 5# package default.* scripts. 6 7RESOLV_CONF="/etc/resolv.conf" 8IPCMD=`which ip` 9 10case $1 in 11 bound|renew) 12 $IPCMD address add broadcast $broadcast $ip/$subnet dev $interface 13 14 if [ -n "$router" ]; then 15 echo "$0: Resetting default routes" 16 while $IPCMD route del default dev $interface; do :; done 17 18 metric=0 19 for i in $router; do 20 $IPCMD route add default dev $interface via $router metric $metric 21 metric=$(($metric + 1)) 22 done 23 fi 24 25 # Update resolver configuration file 26 R="" 27 [ -n "$domain" ] && R="domain $domain 28" 29 for i in $dns; do 30 echo "$0: Adding DNS $i" 31 R="${R}nameserver $i 32" 33 done 34 35 if [ -x /sbin/resolvconf ]; then 36 echo -n "$R" | resolvconf -a "${interface}.udhcpc" 37 else 38 echo -n "$R" > "$RESOLV_CONF" 39 fi 40 ;; 41 42 deconfig) 43 if [ -x /sbin/resolvconf ]; then 44 resolvconf -d "${interface}.udhcpc" 45 fi 46 $IPCMD address flush dev $interface 47 ;; 48 49 leasefail) 50 echo "$0: Lease failed: $message" 51 ;; 52 53 nak) 54 echo "$0: Received a NAK: $message" 55 ;; 56 57 *) 58 echo "$0: Unknown udhcpc command: $1"; 59 exit 1; 60 ;; 61esac 62