do not reobot machines

This commit is contained in:
Donald Burr 2015-02-21 09:33:38 -08:00
parent f24ce99391
commit 6ede4e0f23
2 changed files with 9 additions and 3 deletions

View file

@ -3,6 +3,10 @@
MAC=`/sbin/ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tr '[A-Z]' '[a-z]'`
if grep -q $MAC HOSTS; then
HOSTNAME=`grep $MAC HOSTS | cut -d\| -f1`
if [ "$HOSTNAME" = "`hostname`" ]; then
echo 'hostname is already correct'
exit 1
fi
echo "setting hostname to $HOSTNAME"
echo "$HOSTNAME" > /tmp/HOSTNAME.$$
sudo rm -f /etc/hostname
@ -10,7 +14,8 @@ if grep -q $MAC HOSTS; then
sudo chown root:root /etc/hostname
sudo chmod 644 /etc/hostname
sudo /etc/init.d/hostname.sh
exit 0
else
echo "cannot determine hostname"
exit 1
fi
exit 1