jazz/Hadoop_Env_Setup: IP_Hostname.sh

File IP_Hostname.sh, 463 bytes (added by waue, 15 years ago)
Line 
1#!/bin/bash
2
3
4IP=`/sbin/ifconfig eth0|grep 'inet' |awk '{print $2}' |sed -e "s/addr\://"` 
5
6#ans=`echo $IP |awk 'BEGIN {FS="."} {print $1 " " $2 " "  $3 " " $4}'`
7
8id=`echo $IP |awk 'BEGIN {FS="."} {print $4}'`
9
10if [ "$id" -gt "99" ]; then
11  name="node$id"
12elif [ "$id" -gt "9" ]; then
13  name="node0$id"
14else
15  name="node00$id"
16fi
17
18echo "$name" > ./hostname
19sudo mv ./hostname /etc/hostname
20sudo /bin/hostname -F /etc/hostname
21sudo /sbin/reboot