move_dnode.sh 1.4 KB
Newer Older
1 2 3 4
#!/bin/bash

echo "Executing move_dnode.sh"

G
Ganlin Zhao 已提交
5 6 7
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`

8 9 10
SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`
G
Ganlin Zhao 已提交
11
echo "SCRIPT_DIR: $SCRIPT_DIR"
12 13 14 15 16 17 18 19 20 21 22

IN_TDINTERNAL="community"
if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then
  cd ../../..
else
  cd ../../
fi

TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`

G
Ganlin Zhao 已提交
23 24 25 26 27 28
if [[ "$OS_TYPE" != "Darwin" ]]; then
  cut_opt="--field="
else
  cut_opt="-f "
fi

29
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
G
Ganlin Zhao 已提交
30
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
31
else
G
Ganlin Zhao 已提交
32
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
fi

BUILD_DIR=$TAOS_DIR/$BIN_DIR/build

SIM_DIR=$TAOS_DIR/sim

NODE_DIR=$SIM_DIR/$NODE_NAME

if [ -d "$SIM_DIR/$2" ];then
  rm -rf $SIM_DIR/$2
fi
mv $SIM_DIR/$1 $SIM_DIR/$2

if [[ $2 =~ "dnode2" ]];then
  sed -i 's/serverPort             7100/serverPort             7200/g' $SIM_DIR/$2/cfg/taos.cfg
  sed -i 's/dnode1/dnode2/g' $SIM_DIR/$2/cfg/taos.cfg
  sed -i 's/7100/7200/g' $SIM_DIR/$2/data/dnode/dnodeEps.json
elif [[ $2 =~ "dnode4" ]];then
  sed -i 's/serverPort             7100/serverPort             7400/g' $SIM_DIR/$2/cfg/taos.cfg
  sed -i 's/dnode1/dnode4/g' $SIM_DIR/$2/cfg/taos.cfg
  sed -i 's/7100/7400/g' $SIM_DIR/dnode2/data/dnode/dnodeEps.json
  sed -i 's/7100/7400/g' $SIM_DIR/dnode3/data/dnode/dnodeEps.json
  sed -i 's/7100/7400/g' $SIM_DIR/$2/data/dnode/dnodeEps.json
fi