cleaning
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
#!/bin/bash
|
||||
Script="${0} ${*}"
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} --inst_set=<setting #> [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
for arg in "${@}"
|
||||
do
|
||||
case ${arg} in
|
||||
--restart)
|
||||
Restart=Y
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
Stop="Y"
|
||||
shift
|
||||
;;
|
||||
--once)
|
||||
Once="Y"
|
||||
shift
|
||||
;;
|
||||
--inst_set=*)
|
||||
InstrSet="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--sleep_sec=*)
|
||||
SleepSec="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
declare -A InstrSetInstrs
|
||||
InstrSetInstrs[1]=PAIR-BTC-USDT,PAIR-ETH-USDT,PAIR-LTC-USDT,PAIR-XRP-USDT,PAIR-USDT-USD
|
||||
|
||||
|
||||
if [ "${InstrSet}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "${SleepSec}" == "" ]
|
||||
then
|
||||
SleepSec=3
|
||||
fi
|
||||
|
||||
Instruments=${InstrSetInstrs[${InstrSet}]}
|
||||
if [ "${Instruments}" == "" ]
|
||||
then
|
||||
echo "Unrecognized instrument settings: ${InstrSet}"
|
||||
usage
|
||||
fi
|
||||
|
||||
# -------------------- S e t t i n g s
|
||||
RootDir=/home/cvtt/prod
|
||||
# ConfigFile="${RootDir}/config/md_recorder.cfg"
|
||||
ConfigFile="http://cloud11.cvtt.vpn:6789/apps/md_recorder"
|
||||
|
||||
AdminPort="721${InstrSet}"
|
||||
Exchange=BNBSPOT
|
||||
DbCredKey=TSDB_COINBS_1
|
||||
Name=MD_RECORDER_BNBSPOT
|
||||
# -------------------- S e t t i n g s
|
||||
|
||||
LogFile="${RootDir}/logs/$(date '+%Y%m%d_%H%M%S').${Name}_${InstrSet}.log"
|
||||
|
||||
source ${HOME}/.pyenv/python3.10-venv/bin/activate
|
||||
export PYTHONPATH=${RootDir}
|
||||
|
||||
Cmd="nohup"
|
||||
Cmd="${Cmd} python3"
|
||||
Cmd="${Cmd} ${RootDir}/cvttpy/apps/md/md_recorder.py"
|
||||
Cmd="${Cmd} --config=${ConfigFile}"
|
||||
Cmd="${Cmd} --active_exchanges=${Exchange}"
|
||||
Cmd="${Cmd} --instruments=${Instruments}"
|
||||
Cmd="${Cmd} --admin_port=${AdminPort}"
|
||||
Cmd="${Cmd} --log_level=INFO"
|
||||
Cmd="${Cmd} --log_file=${LogFile}"
|
||||
Cmd="${Cmd} --db_credentials_key=${DbCredKey}"
|
||||
Cmd="${Cmd} &"
|
||||
|
||||
function start_it {
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} &
|
||||
sleep 10
|
||||
}
|
||||
|
||||
|
||||
function check_it {
|
||||
|
||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
then
|
||||
echo "${Script} doesn't respond. restarting..."
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
start_it
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_it {
|
||||
pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
echo "Killing ${pids} ..."
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
while (timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
do
|
||||
echo "Shutting down localhost:${AdminPort}/shutdown ..."
|
||||
timeout 5 curl -s localhost:${AdminPort}/shutdown
|
||||
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${Stop}" == "Y" ] ; then
|
||||
kill_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${Once}" == "Y" ] ; then
|
||||
start_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ "${Restart}" == "Y" ]
|
||||
then
|
||||
kill_it
|
||||
fi
|
||||
|
||||
start_it
|
||||
while true
|
||||
do
|
||||
check_it
|
||||
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
|
||||
sleep ${SleepSec}
|
||||
done
|
||||
@@ -1,161 +0,0 @@
|
||||
#!/bin/bash
|
||||
Script="${0} ${*}"
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} --inst_set=<setting #> [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
for arg in "${@}"
|
||||
do
|
||||
case ${arg} in
|
||||
--restart)
|
||||
Restart=Y
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
Stop="Y"
|
||||
shift
|
||||
;;
|
||||
--once)
|
||||
Once="Y"
|
||||
shift
|
||||
;;
|
||||
--inst_set=*)
|
||||
InstrSet="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--sleep_sec=*)
|
||||
SleepSec="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
declare -A InstrSetInstrs
|
||||
InstrSetInstrs[1]=PAIR-BTC-USD,PAIR-ETH-USD,PAIR-LTC-USD,PAIR-XRP-USD
|
||||
InstrSetInstrs[2]=PAIR-USDT-USD,PAIR-MATIC-USD
|
||||
InstrSetInstrs[3]=PAIR-DOGE-USD,PAIR-AVAX-USD,
|
||||
InstrSetInstrs[4]=PAIR-BCH-USD,PAIR-UNI-USD,PAIR-AAVE-USD,PAIR-LINK-USD,PAIR-SOL-USD
|
||||
|
||||
|
||||
if [ "${InstrSet}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "${SleepSec}" == "" ]
|
||||
then
|
||||
SleepSec=3
|
||||
fi
|
||||
|
||||
Instruments=${InstrSetInstrs[${InstrSet}]}
|
||||
if [ "${Instruments}" == "" ]
|
||||
then
|
||||
echo "Unrecognized instrument settings: ${InstrSet}"
|
||||
usage
|
||||
fi
|
||||
|
||||
# -------------------- S e t t i n g s
|
||||
RootDir=/home/cvtt/prod
|
||||
# ConfigFile="${RootDir}/config/md_recorder.cfg"
|
||||
ConfigFile="http://cloud11.cvtt.vpn:6789/apps/md_recorder"
|
||||
|
||||
AdminPort="720${InstrSet}"
|
||||
Exchange=COINBASE_AT
|
||||
DbCredKey=TSDB_COINBS_1
|
||||
Name=MD_RECORDER_COINBASE
|
||||
# -------------------- S e t t i n g s
|
||||
|
||||
LogFile="${RootDir}/logs/$(date '+%Y%m%d_%H%M%S').${Name}_${InstrSet}.log"
|
||||
|
||||
source ${HOME}/.pyenv/python3.10-venv/bin/activate
|
||||
export PYTHONPATH=${RootDir}
|
||||
|
||||
Cmd="nohup"
|
||||
Cmd="${Cmd} python3"
|
||||
Cmd="${Cmd} ${RootDir}/cvttpy/apps/md/md_recorder.py"
|
||||
Cmd="${Cmd} --config=${ConfigFile}"
|
||||
Cmd="${Cmd} --active_exchanges=${Exchange}"
|
||||
Cmd="${Cmd} --instruments=${Instruments}"
|
||||
Cmd="${Cmd} --admin_port=${AdminPort}"
|
||||
Cmd="${Cmd} --log_level=INFO"
|
||||
Cmd="${Cmd} --log_file=${LogFile}"
|
||||
Cmd="${Cmd} --db_credentials_key=${DbCredKey}"
|
||||
Cmd="${Cmd} &"
|
||||
|
||||
function start_it {
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} &
|
||||
sleep 10
|
||||
}
|
||||
|
||||
|
||||
function check_it {
|
||||
|
||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
then
|
||||
echo "${Script} doesn't respond. restarting..."
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
start_it
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_it {
|
||||
pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
echo "Killing ${pids} ..."
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
while (timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
do
|
||||
echo "Shutting down localhost:${AdminPort}/shutdown ..."
|
||||
timeout 5 curl -s localhost:${AdminPort}/shutdown
|
||||
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${Stop}" == "Y" ] ; then
|
||||
kill_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${Once}" == "Y" ] ; then
|
||||
start_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ "${Restart}" == "Y" ]
|
||||
then
|
||||
kill_it
|
||||
fi
|
||||
|
||||
start_it
|
||||
while true
|
||||
do
|
||||
check_it
|
||||
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
|
||||
sleep ${SleepSec}
|
||||
done
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
#!/bin/bash
|
||||
Script="${0} ${*}"
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
for arg in "${@}"
|
||||
do
|
||||
case ${arg} in
|
||||
--restart)
|
||||
Restart=Y
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
Stop="Y"
|
||||
shift
|
||||
;;
|
||||
--once)
|
||||
Once="Y"
|
||||
shift
|
||||
;;
|
||||
--sleep_sec=*)
|
||||
SleepSec="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${SleepSec}" == "" ]
|
||||
then
|
||||
SleepSec=5
|
||||
fi
|
||||
|
||||
RootDir=/home/cvtt/prod
|
||||
CfgSvcDir=${RootDir}/config_service
|
||||
|
||||
export PYTHONPATH="${RootDir}:${PYTHONPATH}"
|
||||
|
||||
Name=config_server
|
||||
ServerPy="${RootDir}/cvttpy/apps/utils/config_server.py"
|
||||
ServicePort=6789
|
||||
ServiceDir=${CfgSvcDir}/data
|
||||
LogDir=${RootDir}/logs
|
||||
|
||||
source ${HOME}/.pyenv/python3.10-venv/bin/activate
|
||||
export PYTHONPATH="${RootDir}:${PYTHONPATH}"
|
||||
|
||||
Cmd="nohup"
|
||||
Cmd="${Cmd} python3"
|
||||
Cmd="${Cmd} ${ServerPy}"
|
||||
Cmd="${Cmd} --port=${ServicePort}"
|
||||
Cmd="${Cmd} --root=${ServiceDir}"
|
||||
Cmd="${Cmd} --log_file=${LogDir}/%T.config_service.log"
|
||||
|
||||
function start_it {
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} &
|
||||
sleep 10
|
||||
}
|
||||
|
||||
function check_it {
|
||||
if !(timeout 3 curl -s localhost:${ServicePort}/ping > /dev/null)
|
||||
then
|
||||
echo "${Script} doesn't respond. restarting..."
|
||||
pids=$(ps -ef | grep "port=${ServicePort}" | grep "root=${ServiceDir}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
start_it
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_it {
|
||||
pids=$(ps -ef |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
echo "Killing ${pids} ..."
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
while (timeout 3 curl -s localhost:${ServicePort}/ping > /dev/null)
|
||||
do
|
||||
echo "Shutting down localhost:${ServicePort}/__shutdown__ ..."
|
||||
timeout 5 curl -s localhost:${ServicePort}/__shutdown__
|
||||
|
||||
pids=$(ps -ef | grep "port=${ServicePort}" | grep "root=${ServiceDir}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${Stop}" == "Y" ] ; then
|
||||
kill_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${Once}" == "Y" ] ; then
|
||||
start_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ "${Restart}" == "Y" ]
|
||||
then
|
||||
kill_it
|
||||
fi
|
||||
|
||||
start_it
|
||||
while true
|
||||
do
|
||||
check_it
|
||||
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
|
||||
sleep ${SleepSec}
|
||||
done
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
#!/bin/bash
|
||||
Script="${0} ${*}"
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
for arg in "${@}"
|
||||
do
|
||||
case ${arg} in
|
||||
--restart)
|
||||
Restart=Y
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
Stop="Y"
|
||||
shift
|
||||
;;
|
||||
--once)
|
||||
Once="Y"
|
||||
shift
|
||||
;;
|
||||
--inst_set=*)
|
||||
InstrSet="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--sleep_sec=*)
|
||||
SleepSec="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ "${SleepSec}" == "" ]
|
||||
then
|
||||
SleepSec=3
|
||||
fi
|
||||
|
||||
|
||||
# -------------------- S e t t i n g s
|
||||
ConfigServiceHost=cloud11.cvtt.vpn
|
||||
ConfigServicePort=6789
|
||||
|
||||
RootDir=/home/cvtt/prod
|
||||
|
||||
ConfigFile="http://${ConfigServiceHost}:${ConfigServicePort}/apps/executor_app"
|
||||
|
||||
AdminPort="7210"
|
||||
Exchange=COINBASE_AT
|
||||
Name=EXECUTOR_APP
|
||||
# -------------------- S e t t i n g s
|
||||
|
||||
LogFile="${RootDir}/logs/$(date '+%Y%m%d_%H%M%S').${Name}.log"
|
||||
|
||||
source ${HOME}/.pyenv/python3.10-venv/bin/activate
|
||||
export PYTHONPATH=${RootDir}
|
||||
|
||||
Cmd="nohup"
|
||||
Cmd="${Cmd} python3"
|
||||
Cmd="${Cmd} ${RootDir}/cvttpy/apps/executor_app.py"
|
||||
Cmd="${Cmd} --config=${ConfigFile}"
|
||||
Cmd="${Cmd} --active_exchanges=${Exchange}"
|
||||
Cmd="${Cmd} --admin_port=${AdminPort}"
|
||||
Cmd="${Cmd} --log_level=INFO"
|
||||
Cmd="${Cmd} --log_file=${LogFile}"
|
||||
Cmd="${Cmd} &"
|
||||
|
||||
function start_it {
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} &
|
||||
sleep 10
|
||||
}
|
||||
|
||||
|
||||
function check_it {
|
||||
|
||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
then
|
||||
echo "${Script} doesn't respond. restarting..."
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
start_it
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_it {
|
||||
pids=$(ps -ef |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
echo "Killing ${pids} ..."
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
while (timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
do
|
||||
echo "Shutting down localhost:${AdminPort}/shutdown ..."
|
||||
timeout 5 curl -s localhost:${AdminPort}/shutdown
|
||||
sleep 3
|
||||
|
||||
pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
|
||||
echo pids=${pids}
|
||||
if [ "${pids}" != "" ]
|
||||
then
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${Stop}" == "Y" ] ; then
|
||||
kill_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${Once}" == "Y" ] ; then
|
||||
start_it
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ "${Restart}" == "Y" ]
|
||||
then
|
||||
kill_it
|
||||
fi
|
||||
|
||||
start_it
|
||||
while true
|
||||
do
|
||||
check_it
|
||||
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
|
||||
sleep ${SleepSec}
|
||||
done
|
||||
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ---------------- Settings
|
||||
declare -A git_repo_arr
|
||||
|
||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvttpy.git
|
||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/ops.git
|
||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/research.git
|
||||
|
||||
dist_root=/home/cvttdist/software/cvtt2
|
||||
dist_user=cvttdist
|
||||
dist_host="cloud21.cvtt.vpn"
|
||||
dist_ssh_port="22"
|
||||
|
||||
dist_locations="cloud21.cvtt.vpn:22 homestore.cvtt.vpn:22"
|
||||
# ---------------- Settings
|
||||
|
||||
# ---------------- cmdline
|
||||
prj=
|
||||
brnch=master
|
||||
interactive=N
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -p <project> [-b <branch (master)> -i (interactive)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts ":p:b:i" opt; do
|
||||
case ${opt} in
|
||||
p )
|
||||
prj=$OPTARG
|
||||
;;
|
||||
b )
|
||||
brnch=$OPTARG
|
||||
;;
|
||||
i )
|
||||
interactive=Y
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
function confirm {
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "--------------------------------"
|
||||
echo -n "Press <Enter> to continue" && read
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo -n "Enter project [${prj}]: "
|
||||
read project
|
||||
if [ "${project}" == "" ]
|
||||
then
|
||||
project=${prj}
|
||||
fi
|
||||
else
|
||||
project=${prj}
|
||||
fi
|
||||
|
||||
repo=${git_repo_arr[${project}]}
|
||||
if [ -z ${repo} ]; then
|
||||
echo "ERROR: Project repository for ${project} not found"
|
||||
exit -1
|
||||
fi
|
||||
echo "Project repo: ${repo}"
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo -n "Enter branch to build release from [${brnch}]: "
|
||||
read branch
|
||||
if [ "${branch}" == "" ]
|
||||
then
|
||||
branch=${brnch}
|
||||
fi
|
||||
else
|
||||
branch=${brnch}
|
||||
fi
|
||||
|
||||
tmp_dir=$(mktemp -d)
|
||||
function cleanup {
|
||||
cd ${HOME}
|
||||
rm -rf ${tmp_dir}
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
|
||||
prj_dir="${tmp_dir}/${prj}"
|
||||
|
||||
cmd_arr=()
|
||||
Cmd="git clone ${repo} ${prj_dir}"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
Cmd="cd ${prj_dir}"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "------------------------------------"
|
||||
echo "The following commands will execute:"
|
||||
echo "------------------------------------"
|
||||
for cmd in "${cmd_arr[@]}"
|
||||
do
|
||||
echo ${cmd}
|
||||
done
|
||||
fi
|
||||
|
||||
confirm
|
||||
|
||||
for cmd in "${cmd_arr[@]}"
|
||||
do
|
||||
echo ${cmd} && eval ${cmd}
|
||||
done
|
||||
|
||||
Cmd="git checkout ${branch}"
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
if [ "${?}" != "0" ]; then
|
||||
echo "ERROR: Branch ${branch} is not found"
|
||||
cd ${HOME} && rm -rf ${tmp_dir}
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
release_version=$(cat release_version.txt | awk -F',' '{print $1}')
|
||||
whats_new=$(cat release_version.txt | awk -F',' '{print $2}')
|
||||
|
||||
|
||||
echo "--------------------------------"
|
||||
echo "Release version: ${release_version}"
|
||||
|
||||
confirm
|
||||
|
||||
version_tag="v${release_version}"
|
||||
version_comment="'${version_tag} ${project} ${branch} $(date +%Y-%m-%d)\n${whats_new}'"
|
||||
|
||||
cmd_arr=()
|
||||
Cmd="git tag -a ${version_tag} -m ${version_comment}"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
Cmd="git push origin --tags"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
Cmd="rm -rf .git"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
dist_path="${dist_root}/${project}/${release_version}"
|
||||
|
||||
for dist_loc in ${dist_locations}; do
|
||||
dhp=(${dist_loc//:/ })
|
||||
dist_host=${dhp[0]}
|
||||
dist_port=${dhp[1]}
|
||||
Cmd="rsync -avzh"
|
||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path} && rsync\""
|
||||
Cmd="${Cmd} -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} ../${project} ${dist_user}@${dist_host}:${dist_path}/"
|
||||
cmd_arr+=("${Cmd}")
|
||||
done
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "------------------------------------"
|
||||
echo "The following commands will execute:"
|
||||
echo "------------------------------------"
|
||||
for cmd in "${cmd_arr[@]}"
|
||||
do
|
||||
echo ${cmd}
|
||||
done
|
||||
fi
|
||||
|
||||
confirm
|
||||
|
||||
for cmd in "${cmd_arr[@]}"
|
||||
do
|
||||
pwd && echo ${cmd} && eval ${cmd}
|
||||
done
|
||||
|
||||
echo "PROJECT ${project} **** P U L L N E W T A G S F R O M o r i g i n ****"
|
||||
echo "----"
|
||||
echo "(cd ${project}; git pull --tags; git pushall)"
|
||||
echo "----"
|
||||
echo "$0 Done ${project} ${release_version}"
|
||||
Reference in New Issue
Block a user