--- client/scripts/linux +++ client/scripts/linux 2010/03/04 13:30:09 @@ -29,8 +29,7 @@ # if DHCLIENT_DEBUG is set in sysconfig/network/dhcp # SYSCONFIG_CFG_DIR="/etc/sysconfig/network" -SYSCONFIG_RUN_DIR=`. "$SYSCONFIG_CFG_DIR/scripts/functions" \ - 2>/dev/null && echo "$RUN_FILES_BASE"` +. "$SYSCONFIG_CFG_DIR/scripts/functions" SYSCONFIG_RUN_DIR=${SYSCONFIG_RUN_DIR:-/dev/.sysconfig/network} eval `grep "^DHCLIENT_DEBUG=" "$SYSCONFIG_CFG_DIR/dhcp" 2>/dev/null` if [ "$DHCLIENT_DEBUG" = yes ]; then @@ -40,7 +39,7 @@ if [ "$DHCLIENT_DEBUG" = yes ]; then echo "$0 $*" date echo '----------------' - set + env echo '----------------' ) >> /var/log/dhclient-script.log exec 2>> /var/log/dhclient-script.log @@ -48,6 +47,10 @@ if [ "$DHCLIENT_DEBUG" = yes ]; then set -x fi +is_ifup_controlled() +{ + test -f "$SYSCONFIG_RUN_DIR/if-${interface}" +} # netconfig makes all "additional" modifications as DNS or NTP use_netconfig() { test -x /sbin/netconfig @@ -94,9 +97,7 @@ netconfig_remove() { } set_default_gw_route() { - if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ - -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; - then + if is_ifup_controlled ; then if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; then eval `grep --no-filename '^[[:space:]]*DHCLIENT_SET_DEFAULT_ROUTE=' \ @@ -134,9 +135,7 @@ set_default_gw_route() } set_hostname() { - if test -f "$SYSCONFIG_CFG_DIR/ifcfg-${interface}" -o \ - -f "$SYSCONFIG_RUN_DIR/if-${interface}" ; - then + if is_ifup_controlled ; then if grep -qs '^primary=yes' "$SYSCONFIG_RUN_DIR/if-${interface}" 2>/dev/null ; then eval `grep --no-filename "^[[:space:]]*DHCLIENT_SET_HOSTNAME=" \ @@ -157,13 +156,14 @@ set_hostname() [ "x${current_hostname%%.*}" = "xlocalhost" ] || \ [ "x${current_hostname%%.*}" != "x${new_host_name%%.*}" ]; then - if [ "x${new_host_name%%.*}" != x ]; then + if [ "x${new_host_name%%.*}" != "x" ]; then hostname "${new_host_name%%.*}" else if [ -x /usr/bin/host ] ; then if out=`host -W 2 "$new_ip_address" 2>/dev/null` ; then _hostname="`echo "$out" | sed 's:^.* ::; s:\..*::'`" - if [ "x${_hostname}" != x ]; then + if [ "x${_hostname}" != "x" -a \ + "x${_hostname}" != "x${current_hostname%%.*}" ]; then hostname "${_hostname}" fi fi @@ -171,6 +171,20 @@ set_hostname() fi fi fi + if is_ifup_controlled ; then + # check regardless the DHCLIENT_SET_HOSTNAME setting + # and whether we've set it above or not, because when + # it changed, we've to handle it anyway... + local OLD_HOSTNAME=`read_cached_config_data hostname $interface` + local CUR_HOSTNAME=`hostname 2>/dev/null` + if test "x$OLD_HOSTNAME" != "x$CUR_HOSTNAME" ; then + write_cached_config_data hostname "$CUR_HOSTNAME" $interface + commit_cached_config_data $interface + + # reload syslog so it knows the new hostname + /etc/init.d/syslog reload + fi + fi } resolv_conf_dhclient="/var/lib/dhcp/resolv.conf.dhclient.$interface" @@ -300,7 +314,15 @@ if [ x$reason = xBOUND ] || [ x$reason = # and clear the ARP cache. ifconfig $interface inet 0 + if is_ifup_controlled ; then + write_cached_config_data dhcp4_state "new" $interface + commit_cached_config_data $interface + fi + elif is_ifup_controlled ; then + write_cached_config_data dhcp4_state "up" $interface + commit_cached_config_data $interface fi + if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then @@ -328,7 +350,20 @@ if [ x$reason = xBOUND ] || [ x$reason = make_resolv_conf fi + if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then + if is_ifup_controlled ; then + ifdown $interface -o dhcp + fi + fi + set_hostname + if is_ifup_controlled ; then + # execute ifservice and if-up.d scripts + ifup $interface -o dhcp + + write_cached_config_data dhcp4_state "complete" $interface + commit_cached_config_data $interface + fi exit_with_hooks 0 fi @@ -376,12 +411,26 @@ if [ x$reason = xTIMEOUT ]; then make_resolv_conf fi + set_hostname + if is_ifup_controlled ; then + # execute ifservice and if-up.d scripts + ifup $interface -o dhcp + + write_cached_config_data dhcp4_state "complete" $interface + commit_cached_config_data $interface + fi + exit_with_hooks 0 fi ifconfig $interface inet 0 exit_with_hooks 1 fi +if is_ifup_controlled ; then + write_cached_config_data dhcp4_state "down" $interface + commit_cached_config_data $interface +fi + if use_netconfig ; then netconfig_remove else