clear.sh 3.4 KB
Newer Older
1
#!/bin/bash
S
slguan 已提交
2 3 4

echo "Executing clear.sh"

G
Ganlin Zhao 已提交
5
if [ $# != 6 ]; then
S
slguan 已提交
6 7 8 9 10 11 12
  echo "argument list need input : "
  echo "  -n nodeName"
  echo "  -i nodeIp"
  echo "  -m masterIp"
  exit 1
fi

G
Ganlin Zhao 已提交
13 14
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
S
slguan 已提交
15 16 17
NODE_NAME=
NODE_IP=
MSATER_IP=
G
Ganlin Zhao 已提交
18
while getopts "n:i:m:" arg
S
slguan 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
do
  case $arg in
    n)
      NODE_NAME=$OPTARG
      ;;
    i)
      NODE_IP=$OPTARG
      ;;
    m)
      MASTER_IP=$OPTARG
      ;;
    ?)
      echo "unkonw argument"
      ;;
  esac
done

SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`
G
Ganlin Zhao 已提交
39
echo "SCRIPT_DIR: $SCRIPT_DIR"
S
slguan 已提交
40

41 42
IN_TDINTERNAL="community"
if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then
43 44 45 46 47
  cd ../../..
else
  cd ../../
fi

S
slguan 已提交
48
TAOS_DIR=`pwd`
S
Shuduo Sang 已提交
49
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
S
slguan 已提交
50

G
Ganlin Zhao 已提交
51 52 53 54 55 56
if [[ "$OS_TYPE" != "Darwin" ]]; then
  cut_opt="--field="
else
  cut_opt="-f "
fi

S
Shuduo Sang 已提交
57
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
G
Ganlin Zhao 已提交
58
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
S
Shuduo Sang 已提交
59
else
G
Ganlin Zhao 已提交
60
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
S
Shuduo Sang 已提交
61
fi
S
slguan 已提交
62

S
Shuduo Sang 已提交
63
BUILD_DIR=$TAOS_DIR/$BIN_DIR/build
64 65

SIM_DIR=$TAOS_DIR/sim
S
slguan 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
NODE_DIR=$SIM_DIR/$NODE_NAME
EXE_DIR=$BUILD_DIR/bin
CFG_DIR=$NODE_DIR/cfg
LOG_DIR=$NODE_DIR/log
DATA_DIR=$NODE_DIR/data

#echo ============ deploy $NODE_NAME
#echo === masterIp : $MASTER_IP
#echo === nodeIp : $NODE_IP
#echo === nodePath : $EXE_DIR
#echo === cfgPath : $CFG_DIR
#echo === logPath : $LOG_DIR
#echo === dataPath : $DATA_DIR

# rm -rf $NODE_DIR

mkdir -p $SIM_DIR
mkdir -p $NODE_DIR
mkdir -p $LOG_DIR
rm -rf $DATA_DIR
mkdir -p $DATA_DIR

#cp -rf $TAOS_DIR/cfg  $NODE_DIR/
rm -rf $CFG_DIR
mkdir -p $CFG_DIR

#allow normal user to read/write log
chmod -R 777 $NODE_DIR

TAOS_CFG=$NODE_DIR/cfg/taos.cfg
touch -f $TAOS_CFG

TAOS_FLAG=$SIM_DIR/tsim/flag
G
Ganlin Zhao 已提交
99
if [ -f "$TAOS_FLAG" ] ; then
S
slguan 已提交
100 101 102 103 104 105 106 107 108
  TAOS_CFG=/etc/taos/taos.cfg
  DATA_DIR=/var/lib/taos
  LOG_DIR=/var/log/taos
  sudo rm -f /etc/taos/*.cfg
  sudo cp -rf $TAOS_DIR/cfg/*.cfg /etc/taos
  sudo rm -rf $DATA_DIR
  sudo rm -rf $LOG_DIR
fi

G
Ganlin Zhao 已提交
109
echo " "                                  >> $TAOS_CFG
S
slguan 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
echo "masterIp            $MASTER_IP"     >> $TAOS_CFG
echo "dataDir             $DATA_DIR"      >> $TAOS_CFG
echo "logDir              $LOG_DIR"       >> $TAOS_CFG
echo "publicIp            $NODE_IP"       >> $TAOS_CFG
echo "internalIp          $NODE_IP"       >> $TAOS_CFG
echo "privateIp           $NODE_IP"       >> $TAOS_CFG
echo "dDebugFlag          135"            >> $TAOS_CFG
echo "mDebugFlag          135"            >> $TAOS_CFG
echo "sdbDebugFlag        135"            >> $TAOS_CFG
echo "rpcDebugFlag        131"            >> $TAOS_CFG
echo "tmrDebugFlag        131"            >> $TAOS_CFG
echo "cDebugFlag          135"            >> $TAOS_CFG
echo "httpDebugFlag       131"            >> $TAOS_CFG
echo "monitorDebugFlag    131"            >> $TAOS_CFG
echo "udebugFlag          131"            >> $TAOS_CFG
echo "jnidebugFlag        131"            >> $TAOS_CFG
echo "monitor             0"              >> $TAOS_CFG
echo "numOfThreadsPerCore 2.0"            >> $TAOS_CFG
echo "defaultPass         taosdata"       >> $TAOS_CFG
echo "numOfLogLines       100000000"      >> $TAOS_CFG
S
Shengliang Guan 已提交
130
echo "mnodeEqualVnodeNum   0"              >> $TAOS_CFG
S
slguan 已提交
131 132 133
echo "clog                0"              >> $TAOS_CFG
echo "statusInterval      1"              >> $TAOS_CFG
echo "asyncLog            0"              >> $TAOS_CFG
134
echo "numOfMnodes         1"              >> $TAOS_CFG
S
slguan 已提交
135 136 137
echo "locale    en_US.UTF-8"              >> $TAOS_CFG