Compare commits
7 Commits
v1.8.4.fx2
...
v1.8.8.F2
| Author | SHA1 | Date | |
|---|---|---|---|
| f4365d32e5 | |||
| 1fe5edcd74 | |||
| 8510226599 | |||
| 10105ad639 | |||
| 9b2bda6257 | |||
| 80a6ffeb18 | |||
| e7c02587c2 |
@@ -3,11 +3,11 @@
|
||||
# ---------------- 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
|
||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvttpy.git
|
||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops.git
|
||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/research.git
|
||||
git_repo_arr[cvtt-rust]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvtt-rust.git
|
||||
git_repo_arr[docker_dev]=git@cloud21.cvtt.vpn:/opt/store/git/docker_dev.git
|
||||
git_repo_arr[docker_dev]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/docker_dev.git
|
||||
|
||||
dist_root=/home/cvttdist/software/cvtt2
|
||||
dist_user=cvttdist
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
usage() {
|
||||
echo -n "Usage: ${0} <RootDir>"
|
||||
echo
|
||||
@@ -49,7 +48,7 @@ build_docker_image() {
|
||||
image_version=$(get_latest_dist_version ${project})
|
||||
if [ -z "${image_version}" ]; then
|
||||
echo "No latest version found for ${project}"
|
||||
exit 1
|
||||
return
|
||||
fi
|
||||
echo "Latest version is ${image_version}"
|
||||
|
||||
@@ -103,11 +102,12 @@ build_docker_image() {
|
||||
Cmd="rm -rf ${RootDir}/${project}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
print_all_reg_images ${project}
|
||||
}
|
||||
|
||||
convert_symlink_to_dir() {
|
||||
project=${1}
|
||||
echo "***** DEBUG 1 $(ls -l ${RootDir}/${project})"
|
||||
if [ -L ${RootDir}/${project} ]; then
|
||||
echo "Converting symlink ${RootDir}/${project} to directory"
|
||||
|
||||
@@ -124,7 +124,6 @@ convert_symlink_to_dir() {
|
||||
fi
|
||||
Cmd="rm ${RootDir}/${project}.symlink"
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
echo "***** DEBUG 2 $(ls -l ${RootDir}/${project})"
|
||||
}
|
||||
|
||||
image_exists() {
|
||||
@@ -141,10 +140,8 @@ image_exists() {
|
||||
print_all_reg_images() {
|
||||
project=${1}
|
||||
|
||||
# Fetch all repositories (images) from the registry
|
||||
repositories=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/_catalog" | jq -r '.repositories[]')
|
||||
|
||||
# Iterate over each repository to get its tags
|
||||
for repo in $repositories; do
|
||||
# Fetch all tags for the repository
|
||||
tags=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/$repo/tags/list" | jq -r '.tags[]')
|
||||
@@ -178,19 +175,21 @@ eval ${Cmd}
|
||||
|
||||
convert_symlink_to_dir docker_dev
|
||||
|
||||
echo "${DIMAGES_CONFIG}" | jq -c 'to_entries[]' | while IFS= read -r item; do
|
||||
Jobs=()
|
||||
while IFS= read -r item; do
|
||||
Jobs+=("$item")
|
||||
done < <(echo "${DIMAGES_CONFIG}" | jq -c 'to_entries[]')
|
||||
|
||||
for item in "${Jobs[@]}"; do
|
||||
# Extract key (name) and values
|
||||
title=$(echo "$item" | jq -r '.key')
|
||||
image_name=$(echo "$item" | jq -r '.value.image_name')
|
||||
docker_dev_path=$(echo "$item" | jq -r '.value.docker_dev_path')
|
||||
project=$(echo "$item" | jq -r '.value.based_on_project')
|
||||
|
||||
build_docker_image "$title" "$image_name" "$docker_dev_path" "$project"
|
||||
done
|
||||
|
||||
Cmd="docker images"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rm -rf ${RootDir}/docker_dev"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo -n "Usage: ${0} <grep_filter>"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
# --- Settings
|
||||
RegistryService=cloud21.cvtt.vpn:5500
|
||||
RegistryProtocol=http
|
||||
|
||||
print_all_reg_images() {
|
||||
project=${1}
|
||||
|
||||
repositories=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/_catalog" | jq -r '.repositories[]')
|
||||
|
||||
for repo in $repositories; do
|
||||
# Fetch all tags for the repository
|
||||
tags=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/$repo/tags/list" | jq -r '.tags[]')
|
||||
|
||||
# List each tag
|
||||
echo "REPO: $repo"
|
||||
for tag in $tags; do
|
||||
if [ "${project}" == "" ];then
|
||||
echo "$repo:$tag"
|
||||
else
|
||||
echo "$repo:$tag" | grep ${project}
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
print_all_reg_images ${1}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
Cmd="docker run"
|
||||
Cmd+=" -d"
|
||||
Cmd+=" --rm"
|
||||
Cmd+=" --pull=always"
|
||||
Cmd+=" --network=host"
|
||||
Cmd+=" --name=crypto_exch_stats"
|
||||
Cmd+=" --volume=${HOME}/prod/data:/app/data"
|
||||
Cmd+=" --volume=${HOME}/prod/logs:/logs"
|
||||
Cmd+=" cloud21.cvtt.vpn:5500/crypto_exch_stats:latest"
|
||||
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
# Cmd+=" cloud21.cvtt.vpn:5500/relative_liquidity:latest"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.8.4.fx2,initial version of docker_image_builder.sh
|
||||
1.8.8.F2,no boolean for jq, it considers "false" as missing (null)
|
||||
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -S <symbols> -d <YYYYMMDD Date> [-O <output dir (./) >]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --------------------- Settings
|
||||
SourceHost=cloud21.cvtt.vpn
|
||||
SourceRootDir=/opt/store/cvtt/md_archive/equity/alpaca_md
|
||||
# --------------------- Settings
|
||||
|
||||
|
||||
is_business_day() {
|
||||
dt=${1}
|
||||
date=$(date -d "${dt}" +"%Y-%m-%d")
|
||||
|
||||
CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
|
||||
URL="${CalendarURL}&start=${date}&end=${date}"
|
||||
open_time=$(curl -s "${URL}" | jq '.[] | .open_time')
|
||||
if [ -n "${open_time}" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
export -f is_business_day
|
||||
|
||||
|
||||
while getopts ":d:S:O:" opt; do
|
||||
case ${opt} in
|
||||
d )
|
||||
Date=$OPTARG
|
||||
;;
|
||||
S )
|
||||
SymList=$OPTARG
|
||||
;;
|
||||
O )
|
||||
OutputDir=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z ${SymList} ] ; then
|
||||
echo "symbols are not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${Date} ] ; then
|
||||
echo "date is not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${OutputDir} ] ; then
|
||||
OutputDir=.
|
||||
fi
|
||||
mkdir -p ${OutputDir}
|
||||
|
||||
if ! is_business_day ${Date}; then
|
||||
echo "${Date} is not business day"
|
||||
usage
|
||||
fi
|
||||
|
||||
OLD_IFS=${IFS}
|
||||
IFS=","
|
||||
read -ra Symbols <<< "${SymList}"
|
||||
IFS=${OLD_IFS}
|
||||
|
||||
echo "Date=${Date} Symbols=${Symbols[@]} OutputDir=${OutputDir}"
|
||||
echo Getting data from ${DataHost} ...
|
||||
|
||||
year=$(date -d ${Date} +"%Y")
|
||||
for sym in ${Symbols[@]}; do
|
||||
inst_id="STOCK-${sym}"
|
||||
capital=${sym:0:1}
|
||||
SourceDir="${SourceRootDir}/${year}/${capital}/${sym}"
|
||||
SourceHbarFile="${SourceDir}/${Date}.${sym}.alpaca_1m_bars.db.gz"
|
||||
SourceQatFile="${SourceDir}/${Date}.${sym}.alpaca_qat.db.gz"
|
||||
|
||||
for src_file in ${SourceHbarFile} ${SourceQatFile}; do
|
||||
Cmd="rsync -ahv"
|
||||
Cmd+=" ${SourceHost}:${src_file}"
|
||||
Cmd+=" $OutputDir/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
Cmd="(cd ${OutputDir} && gunzip *.db.gz)"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
ResultDbFile="${OutputDir}/${Date}.alpaca_sim_md.db"
|
||||
echo "Creating Result Database File ${ResultDbFile}"
|
||||
sym=${Symbols[0]}
|
||||
for db_file in ${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db ${OutputDir}/${Date}.${sym}.alpaca_qat.db ; do
|
||||
Cmd="sqlite3"
|
||||
Cmd+=" ${db_file} .schema"
|
||||
Cmd+=" | sqlite3 ${ResultDbFile}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
|
||||
set -f # not to expand *
|
||||
|
||||
for sym in ${Symbols[@]}; do
|
||||
src_hbar_db=${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db
|
||||
src_qat_db=${OutputDir}/${Date}.${sym}.alpaca_qat.db
|
||||
for srcdb in ${src_hbar_db} ${src_qat_db} ; do
|
||||
|
||||
tables=$(sqlite3 ${srcdb} .tables)
|
||||
for table in $(sqlite3 ${srcdb} .tables) ; do
|
||||
echo "Loading from ${srcdb}.${table} ..."
|
||||
sqlite3 ${ResultDbFile} <<EOF
|
||||
ATTACH '${srcdb}' AS source_db;
|
||||
BEGIN;
|
||||
INSERT INTO ${table} SELECT * FROM source_db.${table};
|
||||
COMMIT;
|
||||
DETACH source_db;
|
||||
EOF
|
||||
done
|
||||
Cmd="rm ${srcdb}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
echo Done $0 ${*}
|
||||
@@ -5,7 +5,8 @@
|
||||
# "users": ["oleg"],
|
||||
# "type": "cloud",
|
||||
# "ssh_port": 7822,
|
||||
# # "to_check": "No"
|
||||
# # "to_check": "false"
|
||||
# "timeout_sec": 5
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
@@ -46,6 +47,8 @@ function host_alert() {
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_SSH_PORT=22
|
||||
DEFAULT_TIMEOUT=5
|
||||
DEFAULT_TO_CHECK="true"
|
||||
Domains=("${Domains[@]}" "$(get_domains)")
|
||||
|
||||
for Domain in ${Domains[@]} ; do
|
||||
@@ -56,16 +59,20 @@ for Host in ${Hosts[@]} ; do
|
||||
host=$(echo $Host | cut -d'.' -f1)
|
||||
Domain=$(echo $Host | cut -d'.' -f2-)
|
||||
|
||||
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
|
||||
if [ "${ToCheck^^}" == "NO" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
|
||||
|
||||
Timeout=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].timeout_sec // '"$DEFAULT_TIMEOUT"'')
|
||||
|
||||
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // '"$DEFAULT_TO_CHECK"'')
|
||||
to_check="${ToCheck}^^"
|
||||
if [ "${to_check}" != "TRUE" && "${to_check}" != "YES" && "${to_check}" != "Y" && "${to_check}" != "T" ]; then
|
||||
continue
|
||||
fi
|
||||
echo "Checking host: $Host on port $PortSSH"
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w5 "$Host" "$PortSSH"; then
|
||||
if ! nc -z -w ${Timeout} "$Host" "$PortSSH"; then
|
||||
echo "Host $Host is not available on port $PortSSH"
|
||||
host_alert "Host $Host is not available on port $PortSSH"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user