concourse-ssh-resource/out

38 lines
789 B
Text
Raw Normal View History

2022-05-05 23:23:10 +02:00
#!/usr/bin/env sh
2022-05-06 03:10:47 +02:00
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