aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/rc.sysinit
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2009-03-23 13:24:05 -0400
committerBill Nottingham <notting@redhat.com>2009-03-23 13:24:05 -0400
commitdcd2526f079cad6a27fc72284f0977780a8fe198 (patch)
treee49d27bc52b640830709433f16ba2cb58d5ed81e /rc.d/rc.sysinit
parent23985b14531dab30732b743938b1b1d3ccdd314b (diff)
downloadinitscripts-dcd2526f079cad6a27fc72284f0977780a8fe198.tar
initscripts-dcd2526f079cad6a27fc72284f0977780a8fe198.tar.gz
initscripts-dcd2526f079cad6a27fc72284f0977780a8fe198.tar.bz2
initscripts-dcd2526f079cad6a27fc72284f0977780a8fe198.tar.xz
initscripts-dcd2526f079cad6a27fc72284f0977780a8fe198.zip
Handle multiple IP addresses without choking in the stateless code. (#443945)
If you have multiple addresses that resolve to different things, it will still be unpredictable. In which case... set your hostname yourself.
Diffstat (limited to 'rc.d/rc.sysinit')
-rwxr-xr-xrc.d/rc.sysinit5
1 files changed, 3 insertions, 2 deletions
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index 65bf678e..5e5698fe 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -489,9 +489,10 @@ if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then
ipaddr=
if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then
ipaddr=$(ip addr show to 0.0.0.0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }')
- if [ -n "$ipaddr" ]; then
+ for ip in $ipaddr ; do
+ HOSTNAME=
eval $(ipcalc -h $ipaddr 2>/dev/null)
- hostname ${HOSTNAME}
+ [ -n "$HOSTNAME" ] && { hostname ${HOSTNAME} ; break; }
fi
fi