[ptxdist] [PATCH v3 07/16] [dhclient] Update dhclient script
Use full path in dhclient-script If the dhclient-script is executed by the init.d scripts the PATH is not yet set so use the full path for ip, ifconfig and route tools Signed-off-by: Bart vdr. Meulen bartvdrmeu...@gmail.com Signed-off-by: Remy Bohmer li...@bohmer.net --- generic/etc/dhclient-script | 58 +++ 1 files changed, 31 insertions(+), 27 deletions(-) diff --git a/generic/etc/dhclient-script b/generic/etc/dhclient-script index 8b4d7a4..eccaae9 100644 --- a/generic/etc/dhclient-script +++ b/generic/etc/dhclient-script @@ -22,8 +22,12 @@ # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious # of the $1 in its args. -# 'ip' just looks too weird. /sbin/ip looks less weird. -ip=/sbin/ip +# busybox installs /bin/ip but iproute2 installs /sbin/ip, so put both +# locations in the PATH to make sure it can be found if either is used +PATH=$PATH:/bin:/sbin +ip=ip +ifconfig=/sbin/ifconfig +route=/sbin/route make_resolv_conf() { if [ x$new_domain_name_servers != x ]; then @@ -111,16 +115,16 @@ fi if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then # Bring down alias interface. Its routes will disappear too. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] [ $relminor -eq 0 ] ) then -ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ +${ifconfig} $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up # Add route to make broadcast work. Do not omit netmask. -route add default dev $interface netmask 0.0.0.0 +${route} add default dev $interface netmask 0.0.0.0 else -ifconfig $interface 0 up +${ifconfig} $interface 0 up fi # We need to give the kernel some time to get the interface up. @@ -147,36 +151,36 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ if [ x$old_ip_address != x ] [ x$alias_ip_address != x ] \ [ x$alias_ip_address != x$old_ip_address ]; then # Possible new alias. Remove old alias. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ x$old_ip_address != x ] [ x$old_ip_address != x$new_ip_address ]; then # IP address changed. Bringing down the interface will delete all routes, # and clear the ARP cache. -ifconfig $interface inet 0 down +${ifconfig} $interface inet 0 down fi if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then -ifconfig $interface inet $new_ip_address $new_subnet_arg \ +${ifconfig} $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg # Add a network route to the computed network address. if [ $relmajor -lt 2 ] || \ ( [ $relmajor -eq 2 ] [ $relminor -eq 0 ] ); then - route add -net $new_network_number $new_subnet_arg dev $interface + ${route} add -net $new_network_number $new_subnet_arg dev $interface fi for router in $new_routers; do if [ x$new_subnet_mask = x255.255.255.255 ] ; then - route add -host $router dev $interface + ${route} add -host $router dev $interface fi - route add default gw $router + ${route} add default gw $router done fi if [ x$new_ip_address != x$alias_ip_address ] [ x$alias_ip_address != x ]; then -ifconfig $interface:0- inet 0 -ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg -route add -host $alias_ip_address $interface:0 +${ifconfig} $interface:0- inet 0 +${ifconfig} $interface:0 inet $alias_ip_address $alias_subnet_arg +${route} add -host $alias_ip_address $interface:0 fi make_resolv_conf exit_with_hooks 0 @@ -186,46 +190,46 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ || [ x$reason = xSTOP ]; then if [ x$alias_ip_address != x ]; then # Turn off alias interface. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ x$old_ip_address != x ]; then # Shut down interface, which will delete routes and clear arp cache. -ifconfig $interface inet 0 down +${ifconfig} $interface inet 0 down fi if [ x$alias_ip_address != x ]; then -ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg -route add -host $alias_ip_address $interface:0 +${ifconfig} $interface:0 inet $alias_ip_address $alias_subnet_arg +${route} add -host $alias_ip_address $interface:0 fi exit_with_hooks 0 fi if [ x$reason = xTIMEOUT ]; then if [ x$alias_ip_address != x ]; then -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi - ifconfig $interface inet $new_ip_address $new_subnet_arg \ + ${ifconfig} $interface inet $new_ip_address $new_subnet_arg \
Re: [ptxdist] [PATCH v3 07/16] [dhclient] Update dhclient script
On Tue, Jun 01, 2010 at 11:25:05PM +0200, Remy Bohmer wrote: Use full path in dhclient-script If the dhclient-script is executed by the init.d scripts the PATH is not yet set so use the full path for ip, ifconfig and route tools Signed-off-by: Bart vdr. Meulen bartvdrmeu...@gmail.com Signed-off-by: Remy Bohmer li...@bohmer.net --- generic/etc/dhclient-script | 58 +++ 1 files changed, 31 insertions(+), 27 deletions(-) diff --git a/generic/etc/dhclient-script b/generic/etc/dhclient-script index 8b4d7a4..eccaae9 100644 --- a/generic/etc/dhclient-script +++ b/generic/etc/dhclient-script @@ -22,8 +22,12 @@ # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious # of the $1 in its args. -# 'ip' just looks too weird. /sbin/ip looks less weird. -ip=/sbin/ip +# busybox installs /bin/ip but iproute2 installs /sbin/ip, so put both +# locations in the PATH to make sure it can be found if either is used +PATH=$PATH:/bin:/sbin I think the path should be: PATH=/sbin:/usr/sbin:/bin:/usr/bin and don't replace ifconfig/route +ip=ip +ifconfig=/sbin/ifconfig +route=/sbin/route make_resolv_conf() { if [ x$new_domain_name_servers != x ]; then @@ -111,16 +115,16 @@ fi if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then # Bring down alias interface. Its routes will disappear too. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] [ $relminor -eq 0 ] ) then -ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ +${ifconfig} $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up # Add route to make broadcast work. Do not omit netmask. -route add default dev $interface netmask 0.0.0.0 +${route} add default dev $interface netmask 0.0.0.0 else -ifconfig $interface 0 up +${ifconfig} $interface 0 up fi # We need to give the kernel some time to get the interface up. @@ -147,36 +151,36 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ if [ x$old_ip_address != x ] [ x$alias_ip_address != x ] \ [ x$alias_ip_address != x$old_ip_address ]; then # Possible new alias. Remove old alias. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ x$old_ip_address != x ] [ x$old_ip_address != x$new_ip_address ]; then # IP address changed. Bringing down the interface will delete all routes, # and clear the ARP cache. -ifconfig $interface inet 0 down +${ifconfig} $interface inet 0 down fi if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then -ifconfig $interface inet $new_ip_address $new_subnet_arg \ +${ifconfig} $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg # Add a network route to the computed network address. if [ $relmajor -lt 2 ] || \ ( [ $relmajor -eq 2 ] [ $relminor -eq 0 ] ); then - route add -net $new_network_number $new_subnet_arg dev $interface + ${route} add -net $new_network_number $new_subnet_arg dev $interface fi for router in $new_routers; do if [ x$new_subnet_mask = x255.255.255.255 ] ; then - route add -host $router dev $interface + ${route} add -host $router dev $interface fi - route add default gw $router + ${route} add default gw $router done fi if [ x$new_ip_address != x$alias_ip_address ] [ x$alias_ip_address != x ]; then -ifconfig $interface:0- inet 0 -ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg -route add -host $alias_ip_address $interface:0 +${ifconfig} $interface:0- inet 0 +${ifconfig} $interface:0 inet $alias_ip_address $alias_subnet_arg +${route} add -host $alias_ip_address $interface:0 fi make_resolv_conf exit_with_hooks 0 @@ -186,46 +190,46 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ || [ x$reason = xSTOP ]; then if [ x$alias_ip_address != x ]; then # Turn off alias interface. -ifconfig $interface:0- inet 0 +${ifconfig} $interface:0- inet 0 fi if [ x$old_ip_address != x ]; then # Shut down interface, which will delete routes and clear arp cache. -ifconfig $interface inet 0 down +${ifconfig} $interface inet 0 down fi if [ x$alias_ip_address != x ]; then -ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg -route add -host $alias_ip_address $interface:0 +${ifconfig} $interface:0 inet $alias_ip_address $alias_subnet_arg +${route} add -host $alias_ip_address $interface:0 fi exit_with_hooks 0 fi if [ x$reason = xTIMEOUT ]; then if