Skip to content
Snippets Groups Projects
Commit e74c3d7e authored by Pete Tucker's avatar Pete Tucker
Browse files

improve hostname.sh changes

parent f105dbba
No related branches found
No related tags found
No related merge requests found
...@@ -71,14 +71,9 @@ else ...@@ -71,14 +71,9 @@ else
hostname $(get_sn 37).$url hostname $(get_sn 37).$url
fi fi
#Add 127.0.0.0 entry to /etc/hosts if it is not already present if ! grep -q -i "127.0.0.0" /etc/hosts; then
grep "127.0.0.0" /etc/hosts > tmp/junk
if [ -s /tmp/junk ]; then
rm /tmp/junk
else
NAME=$(hostname) NAME=$(hostname)
SHORTNAME=$(hostname | cut -b -16) SHORTNAME=$(hostname | cut -b -16)
NEWLINE="127.0.0.0 $NAME $SHORTNAME" NEWLINE="127.0.0.0 $NAME $SHORTNAME"
sed -e"/^127.0.0.1/a ${NEWLINE}" /etc/hosts > /tmp/hosts2 sed -i "/127.0.0.1/a ${NEWLINE}" /etc/hosts
mv /tmp/hosts2 /etc/hosts
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment