Innovenergy_trunk/python/deploy-debug.sh

47 lines
1001 B
Bash
Raw Permalink Normal View History

2023-02-16 12:57:06 +00:00
#!/usr/bin/env bash
# script path: path to this file
# script options: <remote-ip> <path-to-script.py-relative-to-working-dir> <script args>
# working dir: <root folder to sync>
clear
panic() {
echo "$1"
exit 1
}
[ -n "$1" ] || panic "no remote address given (arg 1)"
[ -n "$2" ] || panic "no python script given (arg 2)"
local_dir=$(pwd)
set +x
set +v
remote_address="$1"
script_path_relative_to_local_dir="$2"
remote_dir=/var/volatile/remote_debug
remote="$remote_address:$remote_dir"
echo deploying "$local_dir" to "$remote"
rsync --copy-links \
--recursive \
--delete \
--exclude=".git" \
--exclude=".hg" \
--exclude=".idea" \
--exclude="venv" \
--exclude="deploy-debug.sh" \
"$local_dir"/* \
"root@$remote"
#--verbose \
#--dry-run \
echo "done"
remote_script="$remote_dir/$script_path_relative_to_local_dir"
ssh "root@$remote_address" mkdir -p "$remote_dir"
ssh -t "root@$remote_address" /usr/bin/python -u "$remote_script $3"