buildClusterEnv.sh 2.5 KB
Newer Older
P
Ping Xiao 已提交
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
#!/bin/bash
echo "Executing buildClusterEnv.sh"
DOCKER_DIR=/data
CURR_DIR=`pwd`

if [ $# != 4 ]; then 
  echo "argument list need input : "
  echo "  -n numOfNodes"
  echo "  -v version"  
  exit 1
fi

NUM_OF_NODES=
VERSION=
while getopts "n:v:" arg
do
  case $arg in
    n)
      NUM_OF_NODES=$OPTARG
      ;;
    v)
      VERSION=$OPTARG
      ;;    
    ?)
      echo "unkonwn argument"
      ;;
  esac
done


function createDIR {
  for i in {1.. $2}
  do    
    mkdir -p /data/node$i/data
    mkdir -p /data/node$i/log
    mkdir -p /data/node$i/cfg
37
    mkdir -p /data/node$i/core
P
Ping Xiao 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  done
}

function cleanEnv {    
  for i in {1..3}
  do
    echo /data/node$i/data/*
    rm -rf /data/node$i/data/*
    echo /data/node$i/log/*
    rm -rf /data/node$i/log/*
  done
}

function prepareBuild {

  if [ -d $CURR_DIR/../../../../release ]; then
    echo release exists
    rm -rf $CURR_DIR/../../../../release/*
  fi


59 60 61 62 63 64 65 66
  if [ ! -e $DOCKER_DIR/TDengine-server-$VERSION-Linux-x64.tar.gz && ! -e TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then
    cd $CURR_DIR/../../../../packaging
    ./release.sh -v edge -n $VERSION >> /dev/null

    if [ ! -e $CURR_DIR/../../../../release/TDengine-server-$VERSION-Linux-x64.tar.gz ]; then
      echo "no TDengine install package found"
      exit 1
    fi
P
Ping Xiao 已提交
67

68 69 70 71 72 73 74 75 76
    if [ ! -e $CURR_DIR/../../../../release/TDengine-arbitrator-$VERSION-Linux-x64.tar.gz ]; then
      echo "no arbitrator install package found"
      exit 1
    fi

    cd $CURR_DIR/../../../../release
    mv TDengine-server-$VERSION-Linux-x64.tar.gz $DOCKER_DIR
    mv TDengine-arbitrator-$VERSION-Linux-x64.tar.gz $DOCKER_DIR
  fi
P
Ping Xiao 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  
  rm -rf $DOCKER_DIR/*.yml
  cd $CURR_DIR

  cp docker-compose.yml  $DOCKER_DIR
  cp Dockerfile $DOCKER_DIR

  if [ $NUM_OF_NODES -eq 4 ]; then
    cp ../node4.yml $DOCKER_DIR
  fi

  if [ $NUM_OF_NODES -eq 5 ]; then
    cp ../node5.yml $DOCKER_DIR
  fi
}

function clusterUp {
  
  cd $DOCKER_DIR

  if [ $NUM_OF_NODES -eq 3 ]; then
98
    PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose up -d
P
Ping Xiao 已提交
99 100 101
  fi

  if [ $NUM_OF_NODES -eq 4 ]; then
102
    PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node4.yml up -d
P
Ping Xiao 已提交
103 104 105
  fi

  if [ $NUM_OF_NODES -eq 5 ]; then
106
    PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node4.yml -f node5.yml up -d
P
Ping Xiao 已提交
107 108 109 110
  fi
}

cleanEnv 
111 112
prepareBuild
clusterUp