--- a/client/scripts/linux +++ b/client/scripts/linux @@ -44,6 +44,20 @@ set -x fi +if [ -n "${dhc_dbus}" ]; then + /usr/bin/dbus-send \ + --system \ + --dest=com.redhat.dhcp \ + --type=method_call \ + /com/redhat/dhcp/$interface \ + com.redhat.dhcp.set \ + 'string:'"`env | /bin/egrep -v '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"; + if (( ( dhc_dbus & 31 ) == 31 )); then + exit 0; + fi; +fi; + + make_resolv_conf() { # first, look if we are allowed to modify resolv.conf: eval `grep "^MODIFY_RESOLV_CONF_DYNAMICALLY=" /etc/sysconfig/network/config` @@ -167,24 +181,26 @@ 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 - fi - if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ) - then - ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then + if [ x$alias_ip_address != x ]; then + # Bring down alias interface. Its routes will disappear too. + 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 \ 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 - else - ifconfig $interface 0 up - fi + # Add route to make broadcast work. Do not omit netmask. + route add default dev $interface netmask 0.0.0.0 + else + ifconfig $interface 0 up + fi - # We need to give the kernel some time to get the interface up. - sleep 1 + # We need to give the kernel some time to get the interface up. + sleep 1 - exit_with_hooks 0 + exit_with_hooks 0 + fi fi if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then @@ -193,55 +209,65 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then - if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then + 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 - 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 + # Possible new alias. Remove old alias. + 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 + fi 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 \ + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then + 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 ] || \ + fi + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 4 ) != 4 )); then + # 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 + route add default gw $router + done fi - for router in $new_routers; do - 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 + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 2 ) != 2 )); then + 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 + fi fi - make_resolv_conf - eval `grep --no-filename "^DHCLIENT_SET_HOSTNAME=" /etc/sysconfig/network/dhcp` - if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then - - current_hostname=`hostname` - if [ x$current_hostname = x ] || \ - [ x$current_hostname != x$new_host_name ]; then - - if [ x$new_host_name != x ]; then - hostname $new_host_name - else - if [ -x /usr/bin/host ] ; then - hostname `host "$new_ip_address" | sed 's:^.* ::; s:\..*::'` + if [ -z "${dhc_dbus}" ] || (( ( dhc_dbus & 1 ) != 1 )); then + make_resolv_conf + eval `grep --no-filename "^DHCLIENT_SET_HOSTNAME=" /etc/sysconfig/network/dhcp` + if [ "$DHCLIENT_SET_HOSTNAME" = yes ] ; then + + current_hostname=`hostname` + if [ x$current_hostname = x ] || \ + [ x$current_hostname != x$new_host_name ]; then + + if [ x$new_host_name != x ]; then + hostname $new_host_name + else + if [ -x /usr/bin/host ] ; then + hostname `host "$new_ip_address" | sed 's:^.* ::; s:\..*::'` + fi fi - fi - fi + fi + fi fi exit_with_hooks 0 fi