concourse-ssh-resource/out
2022-05-06 03:10:47 +02:00

37 lines
789 B
Bash
Executable file

#!/usr/bin/env sh
set -e
set -o pipefail
. ./common
cd "$1"
files="$(find . | sed -e '/^\.$/d' -e 's|^./||')"
tarfile="$(mktemp -tp /tmp)"
remote_tarfile="$(mktemp -u)"
tar -cf "$tarfile" ./*
scp -F "$CONFIG_PATH" "$tarfile" "$HOSTNAME:$remote_tarfile"
ssh -F "$CONFIG_PATH" "$HOSTNAME" sh -s << EOF
set -e
cd "$(get_directory)"
tar xf "$remote_tarfile"
rm "$remote_tarfile"
if [ "$(get_command)" = "null" ]; then
exit 0
fi
cd "$(get_workdir)"
$(get_command | jq .[] | tr '\n"' " '") >&2
# echo "\$command_log" >&2
EOF
get_files_for_new_version() {
echo "$files" | xargs printf "$(get_directory)/%s\n"
}
version="$(compute_version "$(fetch_file_infos get_files_for_new_version)")"
jq -r tostring << EOF
{
"version": $version
}
EOF