deploy.sh 3.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash

set +e
#set -x

echo "Executing deploy.sh"

UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
NODE_NAME=
NODE=
S
Shengliang Guan 已提交
12 13
MULTIPROCESS=0
while getopts "n:i:m" arg
14 15 16 17 18 19 20 21
do
  case $arg in
    n)
      NODE_NAME=$OPTARG
      ;;
    i)
      NODE=$OPTARG
      ;;
S
Shengliang Guan 已提交
22 23 24
    m)
      MULTIPROCESS=1
      ;;
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    ?)
      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 已提交
44
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
45 46 47 48 49 50 51 52

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

if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
wafwerar's avatar
wafwerar 已提交
53
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
54
else
wafwerar's avatar
wafwerar 已提交
55
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
56 57 58 59 60 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
fi

BUILD_DIR=$TAOS_DIR/$BIN_DIR

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

rm -rf $NODE_DIR

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

#cp -rf $TAOS_DIR/cfg  $NODE_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

HOSTNAME=`hostname -f`

if [ $NODE -eq 1 ]; then
  NODE=7100
elif [ $NODE -eq 2 ]; then
  NODE=7200
elif [ $NODE -eq 3 ]; then
  NODE=7300
elif [ $NODE -eq 4 ]; then
  NODE=7400
elif [ $NODE -eq 5 ]; then
  NODE=7500
elif [ $NODE -eq 6 ]; then
  NODE=7600  
elif [ $NODE -eq 7 ]; then
  NODE=7700  
elif [ $NODE -eq 8 ]; then
  NODE=7800    
elif [ $NODE -eq 9 ]; then
  NODE=7900    
fi

HOSTNAME=localhost

echo " "                                         >> $TAOS_CFG   
echo "firstEp                ${HOSTNAME}:7100"   >> $TAOS_CFG
echo "secondEp               ${HOSTNAME}:7200"   >> $TAOS_CFG
echo "fqdn                   ${HOSTNAME}"        >> $TAOS_CFG
echo "serverPort             ${NODE}"            >> $TAOS_CFG
S
Shengliang Guan 已提交
124
echo "supportVnodes          128"                >> $TAOS_CFG
125 126 127 128 129 130 131 132
echo "dataDir                $DATA_DIR"          >> $TAOS_CFG
echo "logDir                 $LOG_DIR"           >> $TAOS_CFG
echo "debugFlag              0"                  >> $TAOS_CFG
echo "mDebugFlag             143"                >> $TAOS_CFG
echo "dDebugFlag             143"                >> $TAOS_CFG
echo "vDebugFlag             143"                >> $TAOS_CFG
echo "tsdbDebugFlag          143"                >> $TAOS_CFG
echo "cDebugFlag             143"                >> $TAOS_CFG
S
Shengliang Guan 已提交
133 134
echo "jniDebugFlag           143"                >> $TAOS_CFG
echo "qDebugFlag             143"                >> $TAOS_CFG
135 136
echo "rpcDebugFlag           143"                >> $TAOS_CFG
echo "tmrDebugFlag           131"                >> $TAOS_CFG
S
Shengliang Guan 已提交
137
echo "uDebugFlag             143"                >> $TAOS_CFG
138
echo "sDebugFlag             135"                >> $TAOS_CFG
S
Shengliang Guan 已提交
139
echo "wDebugFlag             143"                >> $TAOS_CFG
140 141 142 143 144
echo "numOfLogLines          20000000"           >> $TAOS_CFG
echo "statusInterval         1"                  >> $TAOS_CFG
echo "asyncLog               0"                  >> $TAOS_CFG
echo "locale                 en_US.UTF-8"        >> $TAOS_CFG
echo "telemetryReporting     0"                  >> $TAOS_CFG
S
Shengliang Guan 已提交
145
echo "multiProcess           ${MULTIPROCESS}"    >> $TAOS_CFG
146
echo " "                                         >> $TAOS_CFG