Skip to content

Commit

Permalink
set hostname to ip-...... only if we have an IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Oct 24, 2017
1 parent 03cd577 commit 595f100
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/fai
Expand Up @@ -296,9 +296,11 @@ if [ $do_init_tasks -eq 1 ]; then
read hname < /proc/sys/kernel/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"
echo $HOSTNAME > /proc/sys/kernel/hostname
echo "Using IP for setting the host name: $HOSTNAME"
if [ -n "$myip" ]; then
export HOSTNAME="ip-$myip"
echo $HOSTNAME > /proc/sys/kernel/hostname
echo "Using IP for setting the host name: $HOSTNAME"
fi
fi
unset hname myip

Expand Down

0 comments on commit 595f100

Please sign in to comment.