Make sure we have a hostname when we grep for it
We attempt to set hostname in /etc/hosts if the hostname does not exist there. However when the $HOSTNAME variable is empty we grep for /etc/hosts from stdin which has no data. Check that $HOSTNAME is not empty before we grep for it. Change-Id: Ie35fd997f2f569ebea6614f91609281a991f8d6a
This commit is contained in:
parent
0c078ac5ae
commit
87a64d1587
@ -32,7 +32,7 @@ forward-zone:
|
||||
EOF
|
||||
|
||||
sudo hostname $HOSTNAME
|
||||
if ! grep -q $HOSTNAME /etc/hosts
|
||||
if [ -n "$HOSTNAME" ] && ! grep -q $HOSTNAME /etc/hosts
|
||||
then
|
||||
echo "127.0.1.1 $HOSTNAME" | sudo tee -a /etc/hosts
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user