modify hostname.sh to add 127.0.0.0 entry to /etc/hosts if not already present
... | ... | @@ -70,3 +70,15 @@ else |
# unit serial number set, use it | ||
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 | ||
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 | ||
fi |