Skip to content

Commit

Permalink
if no hostname was set, use IP for setting the hostname
Browse files Browse the repository at this point in the history
otherwise the hostname is set to (none)
  • Loading branch information
Thomas Lange committed Nov 2, 2015
1 parent 7ea532e commit 9966320
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bin/fai
Expand Up @@ -294,9 +294,19 @@ if [ $do_init_tasks -eq 1 ]; then
esac
done
unset word
if [ -n "$HOSTNAME" ]; then
export hostname $HOSTNAME
fi

hostname $HOSTNAME
export HOSTNAME
# if the host name is still not set, use the IP for setting the hostname
hname=$(hostname)
if [ -z "$HOSTNAME" -o $HOSTNAME = '(none)' -o -z "$hname" ]; then
myip=$(ip ad show up | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1 | grep -v 127.0.0.1| tr '.' '-')
export HOSTNAME="ip-$myip"
hostname $HOSTNAME
echo "Using IP for setting the host name: $hostname"
fi
unset hname myip

renewclass=1 # always renew class list when installing
mkdir -p /var/lib/discover /var/discover /etc/sysconfig
Expand Down

0 comments on commit 9966320

Please sign in to comment.