Created
May 27, 2020 21:52
-
-
Save trepidity/14f5f4671251f1ace62074148a6bff69 to your computer and use it in GitHub Desktop.
set machine hostname (FOR NAM)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Creating host entry..." | tee -a $LOG_OUTPUT | |
HOST_NAME=`hostname` | |
IP_ADDR=`ip addr | grep -Po '(?!(inet 127.\d.\d.1))(inet \K(\d{1,3}\.){3}\d{1,3})' | head -n 1` | |
HOST_PRESENT=`grep $HOST_NAME /etc/hosts` | |
if [ -z "$HOST_PRESENT" ] | |
then | |
echo -e "$IP_ADDR\t$HOST_NAME\t$HOST_NAME" >> /etc/hosts | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment