clear.sh 3.4 KB
Newer Older
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 47 48
#!/bin/bash

echo "Executing clear.sh"

if [ $# != 6 ]; then
  echo "argument list need input : "
  echo "  -n nodeName"
  echo "  -i nodeIp"
  echo "  -m masterIp"
  exit 1
fi

UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
NODE_NAME=
NODE_IP=
MSATER_IP=
while getopts "n:i:m:" arg
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`
echo "SCRIPT_DIR: $SCRIPT_DIR"

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

TAOS_DIR=`pwd`
wafwerar's avatar
wafwerar 已提交
49
TAOSD_DIR=`find . -name "taosd"|grep debug|head -n1`
50 51 52 53 54 55 56 57

if [[ "$OS_TYPE" != "Darwin" ]]; then
  cut_opt="--field="
else
  cut_opt="-f "
fi

if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
wafwerar's avatar
wafwerar 已提交
58
  BIN_DIR=`find . -name "taosd"|grep debug|head -n1|cut -d '/' ${cut_opt}2,3`
59
else
wafwerar's avatar
wafwerar 已提交
60
  BIN_DIR=`find . -name "taosd"|grep debug|head -n1|cut -d '/' ${cut_opt}2`
61 62 63 64 65 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
fi

BUILD_DIR=$TAOS_DIR/$BIN_DIR/build

SIM_DIR=$TAOS_DIR/sim
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
if [ -f "$TAOS_FLAG" ] ; then
  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

echo " "                                  >> $TAOS_CFG
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
echo "mnodeEqualVnodeNum   0"              >> $TAOS_CFG
echo "clog                0"              >> $TAOS_CFG
echo "statusInterval      1"              >> $TAOS_CFG
echo "asyncLog            0"              >> $TAOS_CFG
echo "numOfMnodes         1"              >> $TAOS_CFG
echo "locale    en_US.UTF-8"              >> $TAOS_CFG