cfg.sh 1.1 KB
Newer Older
1
#!/bin/bash
S
slguan 已提交
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

if [ $# != 6 ]; then 
  echo "argument list need input : "
  echo "  -n nodeName"
  echo "  -c configName"
  echo "  -v configValue"
  exit 1
fi

NODE_NAME=
CONFIG_NAME=
CONFIG_VALUE=
while getopts "n:v:c:" arg 
do
  case $arg in
    n)
      NODE_NAME=$OPTARG
      ;;
    c)
      CONFIG_NAME=$OPTARG
      ;;
    v)
      CONFIG_VALUE=$OPTARG
      ;;
    ?)
      echo "unkonw argument"
      ;;
  esac
done

SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`

36 37
IN_TDINTERNAL="community"
if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then
38 39 40 41 42
  cd ../../..
else
  cd ../../
fi

S
slguan 已提交
43
TAOS_DIR=`pwd`
S
Shuduo Sang 已提交
44
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
S
slguan 已提交
45

S
Shuduo Sang 已提交
46 47 48 49 50
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' --fields=2,3`
else
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' --fields=2`
fi
51

S
Shuduo Sang 已提交
52
BUILD_DIR=$TAOS_DIR/$BIN_DIR/build
53

S
slguan 已提交
54 55 56 57 58 59 60 61 62 63
SIM_DIR=$TAOS_DIR/sim

NODE_DIR=$SIM_DIR/$NODE_NAME
TAOS_CFG=$NODE_DIR/cfg/taos.cfg
TAOS_FLAG=$SIM_DIR/tsim/flag
if [ -f "$TAOS_FLAG" ] ; then 
  TAOS_CFG=/etc/taos/taos.cfg
fi

echo "$CONFIG_NAME  $CONFIG_VALUE"        >> $TAOS_CFG