#!/bin/sh # Requirement spec: http://172.17.35.168/hybrid-backup/hbs3-backend/issues/22 # --> get the dir of this script SOURCE="${BASH_SOURCE[0]}" # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it # relative to the path where the symlink file was located done SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" # --> set python3 env . $SCRIPT_DIR/set_py3_env.sh > /dev/null 2>&1 # . $SCRIPT_DIR/set_py3_env.sh # --> decide if print debug DEBUG=0 for arg in $* do if [ $arg == "--debug" ]; then DEBUG=1 echo "*** DEBUG MODE" echo "*** SCRIPT_DIR=$SCRIPT_DIR" break fi done if [ $DEBUG -eq 1 ]; then set -x fi # --> decide PY or PYC if [ -e "$HBS_INST_PATH/rr2/bin/pipe_rr2_daemon_setting.py" ]; then PY_ENTRY="$HBS_INST_PATH/rr2/bin/rr2_daemon_setting.py" else PY_ENTRY="$HBS_INST_PATH/rr2/bin/rr2_daemon_setting.pyc" fi # python3 $PY_ENTRY < /dev/stdin python3 $PY_ENTRY "$@" # --> set crontab for hbs insight, as '-upgrade' for arg in $* do if [ $arg == "-upgrade" ]; then # --> add insight.sh into crontab # echo "$HBS_INST_PATH/rr2/scripts/insight/setcron.sh \"*\" 1 10" # $HBS_INST_PATH/rr2/scripts/insight/setcron.sh "*" 1 10 $HBS_INST_PATH/rr2/scripts/insight/insight.sh -del_crontab $HBS_INST_PATH/rr2/scripts/insight/insight.sh -set_crontab break fi if [ $arg == "-downgrade" ]; then # --> remove insight.sh from crontab $HBS_INST_PATH/rr2/scripts/insight/insight.sh -del_crontab break fi done if [ $DEBUG -eq 1 ]; then set +x fi exit 0