Compare commits
5 Commits
v1.7.6.fx1
..
v1.8.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 512f5ce14d | |||
| 9a3215524e | |||
| 84a8c1cb31 | |||
| 4774bd9005 | |||
| 59e7002a59 |
+39
-8
@@ -6,6 +6,7 @@ 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[cvtt-rust]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvtt-rust.git
|
||||
|
||||
dist_root=/home/cvttdist/software/cvtt2
|
||||
dist_user=cvttdist
|
||||
@@ -48,13 +49,29 @@ while getopts ":p:b:i" opt; do
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
function confirm {
|
||||
confirm() {
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "--------------------------------"
|
||||
echo -n "Press <Enter> to continue" && read
|
||||
fi
|
||||
}
|
||||
|
||||
rust_binaries() {
|
||||
res=()
|
||||
for binname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("bin")) | .name'); do
|
||||
res+=("${binname}")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
rust_libraries() {
|
||||
res=()
|
||||
for libname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("lib")) | .name'); do
|
||||
res+=("lib${libname}.rlib")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo -n "Enter project [${prj}]: "
|
||||
read project
|
||||
@@ -149,6 +166,24 @@ cmd_arr+=("${Cmd}")
|
||||
Cmd="rm -rf .git"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
SourceLoc=../${project}
|
||||
if [ "${project}" == "cvtt-rust" ]; then
|
||||
|
||||
cmd_arr+=("cd ${prj_dir}")
|
||||
|
||||
cmd_arr+=("mkdir -p ${prj_dir}/dist/release")
|
||||
cmd_arr+=("cp release_version.txt ./dist/release")
|
||||
|
||||
jq_cmd="jq '.packages[] | select(.targets[].kind[] == \"bin\") | .name'"
|
||||
apps=$(cargo metadata --no-deps --format-version 1 --manifest-path=${prj_dir}/Cargo.toml | eval $jq_cmd | uniq)
|
||||
for app in ${apps[@]}; do
|
||||
app=${app//\"/} # remove quotes
|
||||
cmd_arr+=("cargo install --root ${prj_dir}/dist/release --path ${prj_dir}/apps/${app}")
|
||||
done
|
||||
|
||||
SourceLoc=${prj_dir}/dist/release
|
||||
fi
|
||||
|
||||
dist_path="${dist_root}/${project}/${release_version}"
|
||||
|
||||
for dist_loc in ${dist_locations}; do
|
||||
@@ -156,9 +191,9 @@ for dist_loc in ${dist_locations}; do
|
||||
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="${Cmd} --rsync-path=\"mkdir -p ${dist_path}"
|
||||
Cmd="${Cmd} && rsync\" -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} $SourceLoc ${dist_user}@${dist_host}:${dist_path}/"
|
||||
cmd_arr+=("${Cmd}")
|
||||
done
|
||||
|
||||
@@ -179,8 +214,4 @@ 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}"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.7.6.fx1,host avalability check
|
||||
1.8.1,build for cvtt-rust uses cargo install
|
||||
|
||||
@@ -55,11 +55,9 @@ done
|
||||
for Host in ${Hosts[@]} ; do
|
||||
host=$(echo $Host | cut -d'.' -f1)
|
||||
Domain=$(echo $Host | cut -d'.' -f2-)
|
||||
# echo "Host=$Host host=$host Domain=$Domain"
|
||||
|
||||
# Get SSH port for the host, or use default if not specified
|
||||
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
|
||||
if [ "${ToCheck}" == "No" ]; then
|
||||
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"'')
|
||||
@@ -72,26 +70,3 @@ for Host in ${Hosts[@]} ; do
|
||||
host_alert "Host $Host is not available on port $PortSSH"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# for Domain in $DOMAINS; do
|
||||
# echo "Processing domain: $Domain"
|
||||
|
||||
# for host in $HOSTS; do
|
||||
# # Construct the fully qualified hostname
|
||||
# FQHN="${host}.${Domain}"
|
||||
|
||||
# # Get SSH port for the host, or use default if not specified
|
||||
# SSH_PORT=$(echo "$JSON_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
|
||||
|
||||
# echo "Checking host: $FQHN on port $SSH_PORT"
|
||||
|
||||
# # Use nc to check if the specified port is open
|
||||
# if nc -z -w5 "$FQHN" "$SSH_PORT"; then
|
||||
# echo "Host $FQHN is available on port $SSH_PORT"
|
||||
# else
|
||||
# echo "Host $FQHN is not available on port $SSH_PORT"
|
||||
# fi
|
||||
# echo "----------------------------------------"
|
||||
# done
|
||||
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "Jenkins" {
|
||||
# "to_check": "Yes",
|
||||
# "protocol": "http",
|
||||
# "host": "cvtt-build.cvtt.vpn",
|
||||
# "port": 8080
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
|
||||
AlertChannel=Alerts-CVTT
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_services
|
||||
|
||||
SERVICES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
echo $Sender
|
||||
echo $AlertChannel
|
||||
|
||||
|
||||
function service_alert() {
|
||||
alert="${1}"
|
||||
if [ "${alert}" != "" ]
|
||||
then
|
||||
#it may contain quotes
|
||||
alert=$(echo "${alert}" | sed 's/"/\\"/g')
|
||||
echo -e "### :boom: SERVICE ALERT\n${alert}" | ${Sender} ${AlertChannel}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
|
||||
mapfile -t SvcNames < <(echo ${SERVICES_CONFIG} | jq -r '. | keys[]')
|
||||
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
for SvcName in "${SvcNames[@]}" ; do
|
||||
ToCheck=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].to_check // "Yes"')
|
||||
if [ "${ToCheck^^}" == "NO" ]; then
|
||||
continue
|
||||
fi
|
||||
Host=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].host ')
|
||||
Port=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].port ')
|
||||
echo "Checking \"$SvcName\" (${Host}:${Port})"
|
||||
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w5 "$Host" "$Port"; then
|
||||
msg="Service \"${SvcName}\" (${Host}:${Port}) is not available"
|
||||
echo ${msg}
|
||||
service_alert "${msg}"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user