addFqdnToHost.sh 673 字节
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/bash
#
# deploy test cluster

set -e
#set -x

dnodeNumber=1
subnet="172.33.0.0/16"

while getopts "hn:s:" arg
do
  case $arg in
    n)
      dnodeNumber=$(echo $OPTARG)
      ;;
    s)
      subnet=$(echo $OPTARG)
      ;;
    h)
      echo "Usage: `basename $0` -n [ dnode number] "
      echo "                -s [ subnet] "
      exit 0
      ;;
    ?) #unknow option
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

addFqdnToHosts() {
  index=$1
  ipPrefix=$2
  let ipIndex=index+1
  echo "${ipPrefix}.${ipIndex}  node${i}"  >> /etc/hosts
}

ipPrefix=${subnet%.*}
for ((i=1; i<=${dnodeNumber}; i++)); do
  addFqdnToHosts ${i} ${ipPrefix}
done