aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig')
-rwxr-xr-xsysconfig/network-scripts/ifup6
-rwxr-xr-xsysconfig/network-scripts/ifup-post12
-rw-r--r--sysconfig/network-scripts/network-functions16
3 files changed, 25 insertions, 9 deletions
diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup
index 672f803c..5ea30db9 100755
--- a/sysconfig/network-scripts/ifup
+++ b/sysconfig/network-scripts/ifup
@@ -5,6 +5,8 @@ cd /etc/sysconfig/network-scripts
. network-functions
+need_hostname
+
CONFIG=$1
[ -z "$CONFIG" ] && {
@@ -160,8 +162,8 @@ if [ "$IPSETUP" != yes ]; then
done
fi
- if [ -n "$BOOTPHOSTNAME" -a "`hostname`" = "(none)" ]; then
- hostname $BOOTPHOSTNAME
+ if [ -n "$BOOTPHOSTNAME" -a -n "$NEEDHOSTNAME" ]; then
+ set_hostname $BOOTPHOSTNAME
fi
fi
fi
diff --git a/sysconfig/network-scripts/ifup-post b/sysconfig/network-scripts/ifup-post
index 6a57d866..35c9a6d2 100755
--- a/sysconfig/network-scripts/ifup-post
+++ b/sysconfig/network-scripts/ifup-post
@@ -5,6 +5,7 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
. network-functions
+need_hostname
source_config
DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
@@ -25,13 +26,10 @@ if [ "$ISALIAS" = no ] ; then
unset allow_null_glob_expansion
fi
-if [ `hostname` = '(none)' -o `hostname` = localhost -a ${DEVICE} != lo ]; then
- IPADDR=`ifconfig ${DEVICE} | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{ print $1 }'`
- host=`host ${IPADDR} | grep Name: | awk '{ print $2 }'`
- if [ -n "$host" ]; then
- echo "$host" > /etc/HOSTNAME
- hostname $host
- fi
+if [ -n "$NEEDHOSTNAME" -a ${DEVICE} != lo ]; then
+ IPADDR=`ifconfig ${DEVICE} | grep 'inet addr' |
+ awk -F: '{ print $2 } ' | awk '{ print $1 }'`
+ eval `/sbin/ipcalc --silent --hostname ${IPADDR}` && set_hostname $HOSTNAME
fi
# Notify programs that have requested notification
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index ca202407..2578ac46 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -28,3 +28,19 @@ do_netreport ()
done
)
}
+
+need_hostname()
+{
+ if [ "`hostname`" = "(none)" -o "`hostname`" = "localhost" -o
+ "`hostname`" = "localhost.localdomain" ]; then
+ NEEDHOSTNAME=yes
+ else
+ unset NEEDHOSTNAME
+ fi
+}
+
+set_hostname()
+{
+ echo "$1" > /etc/HOSTNAME
+ hostname $1
+}