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
hostname $(get_sn 37).$url
fi
#Add 127.0.0.0 entry to /etc/hosts if it is not already present
grep "127.0.0.0" /etc/hosts > tmp/junk
if [ -s /tmp/junk ]; then
rm /tmp/junk
else
if ! grep -q -i "127.0.0.0" /etc/hosts; then
NAME=$(hostname)
SHORTNAME=$(hostname | cut -b -16)
NEWLINE="127.0.0.0 $NAME $SHORTNAME"
sed -e"/^127.0.0.1/a ${NEWLINE}" /etc/hosts > /tmp/hosts2
mv /tmp/hosts2 /etc/hosts
sed -i "/127.0.0.1/a ${NEWLINE}" /etc/hosts
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