github.com/maenmax/kairep@v0.0.0-20210218001208-55bf3df36788/libexec/start_rep.sh (about)

     1  #!/bin/sh
     2  
     3  # Finding out the current script directory and name out of how we have been called
     4  SCRIPT_DIR=`dirname $0`
     5  SCRIPT_NAME=`basename $0`
     6  BIN_DIR=${SCRIPT_DIR}/../bin
     7  LOG_DIR=${SCRIPT_DIR}/../log
     8  RUN_DIR=${SCRIPT_DIR}/../run
     9  
    10  if [ ! -d "$LOG_DIR" ]; then
    11      mkdir -p "$LOG_DIR" || { echo "Failed to create 'log' directory. Aborting ..."; exit 1; }
    12  fi
    13  
    14  if [ ! -d "$RUN_DIR" ]; then
    15      mkdir -p "$RUN_DIR" || { echo "Failed to create 'run' directory. Aborting ..."; exit 1; }
    16  fi
    17  
    18  if [ "x${CRYPTO_KEY}" = "x" ]; then
    19      echo "No CRYPTO_KEY defined!"
    20      exit 2
    21  fi
    22  
    23  if [ "x${CASS_USERNAME}" = "x" ]; then
    24      echo "No CASS_USERNAME defined!"
    25      exit 3
    26  fi
    27  
    28  if [ "x${CASS_PASSWORD}" = "x" ]; then
    29      echo "No CASS_PASSWORD defined!"
    30      exit 4
    31  fi
    32  
    33  if [ "x${REDIS_PASSWORD}" = "x" ]; then
    34      echo "No REDIS_PASSWORD defined!"
    35      exit 4
    36  fi
    37  
    38  nohup >${LOG_DIR}/autoendpoint.log 2>&1 sh -c "CASS_USERNAME=${CASS_USERNAME} CASS_PASSWORD=${CASS_PASSWORD} REDIS_PASSWORD=${REDIS_PASSWORD} CRYPTO_KEY=${CRYPTO_KEY} ${BIN_DIR}/autoendpoint" &
    39  
    40  pid=$!
    41  echo "autoendpoint  OK ($pid)"
    42  echo $pid >${RUN_DIR}/autoendpoint.pid
    43