#!/bin/bash


IP=`/sbin/ifconfig eth0|grep 'inet' |awk '{print $2}' |sed -e "s/addr\://"` 

#ans=`echo $IP |awk 'BEGIN {FS="."} {print $1 " " $2 " "  $3 " " $4}'`

id=`echo $IP |awk 'BEGIN {FS="."} {print $4}'`

if [ "$id" -gt "99" ]; then
	name="node$id"
elif [ "$id" -gt "9" ]; then
	name="node0$id"
else
	name="node00$id"
fi

echo "$name" > ./hostname
sudo mv ./hostname /etc/hostname
sudo /bin/hostname -F /etc/hostname
sudo /sbin/reboot
