#!/bin/bash # Copy the probe to a host that has a JVM and werkdock, then run it. # # tools/deploy.sh mih09-werkdock@mih09.hostsharing.net # tools/deploy.sh USER@HOST REMOTE_DIR (default: probe) # # Everything travels in ONE ssh connection: the Hostsharing webspaces # refuse connections that follow each other too quickly. set -euo pipefail target="${1:?usage: tools/deploy.sh USER@HOST [REMOTE_DIR]}" remote_dir="${2:-probe}" cd "$(dirname "$0")/.." echo "== building" ./gradlew -q --console=plain dist staging="build/deploy" rm -rf "$staging" mkdir -p "$staging" cp build/dist/*.jar "$staging/" cp src/main/java/werkprobe/*.java "$staging/" cp tools/run-probe.sh "$staging/" chmod +x "$staging/run-probe.sh" echo "== copying $(du -sh "$staging" | cut -f1) to $target:~/$remote_dir" tar -C "$staging" -czf - . | ssh "$target" " rm -rf ~/$remote_dir.new && mkdir -p ~/$remote_dir.new && tar -C ~/$remote_dir.new -xzf - && rm -rf ~/$remote_dir && mv ~/$remote_dir.new ~/$remote_dir && ls ~/$remote_dir/run-probe.sh" echo "== run it with: ssh $target '~/$remote_dir/run-probe.sh'"