2016-10-21 07:18:31 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
set -f
|
|
|
|
|
|
|
|
privatekey=$AZ_BATCH_NODE_STARTUP_DIR/certs/key.pem
|
|
|
|
|
|
|
|
for spec in "$@"; do
|
2017-01-31 02:05:03 +03:00
|
|
|
IFS=',' read -ra parts <<< "$spec"
|
|
|
|
# encrypt,creds,jobid,taskid,include,exclude,dst
|
2016-10-21 07:18:31 +03:00
|
|
|
encrypt=${parts[0],,}
|
2018-03-29 22:47:37 +03:00
|
|
|
if [ "$encrypt" == "true" ]; then
|
|
|
|
SHIPYARD_BATCH_ENV=$(echo "${parts[1]}" | base64 -d | openssl rsautl -decrypt -inkey "$privatekey")
|
2016-10-21 07:18:31 +03:00
|
|
|
else
|
|
|
|
SHIPYARD_BATCH_ENV=${parts[1]}
|
|
|
|
fi
|
|
|
|
unset encrypt
|
|
|
|
jobid=${parts[2]}
|
|
|
|
taskid=${parts[3]}
|
|
|
|
incl=${parts[4]}
|
|
|
|
excl=${parts[5]}
|
|
|
|
dst=${parts[6]}
|
|
|
|
|
|
|
|
include=
|
2018-09-18 00:47:53 +03:00
|
|
|
if [ -n "$incl" ]; then
|
2016-10-21 07:18:31 +03:00
|
|
|
include="--include $incl"
|
|
|
|
fi
|
|
|
|
exclude=
|
2018-09-18 00:47:53 +03:00
|
|
|
if [ -n "$excl" ]; then
|
2016-10-21 07:18:31 +03:00
|
|
|
exclude="--exclude $excl"
|
|
|
|
fi
|
|
|
|
# create destination directory
|
|
|
|
dest=
|
2018-09-18 00:47:53 +03:00
|
|
|
if [ -n "$dst" ]; then
|
2016-10-21 07:18:31 +03:00
|
|
|
dest="--dst $dst"
|
2018-03-29 22:47:37 +03:00
|
|
|
mkdir -p "$dst"
|
2016-10-21 07:18:31 +03:00
|
|
|
fi
|
|
|
|
# ingress data from batch task
|
|
|
|
export SHIPYARD_BATCH_ENV=$SHIPYARD_BATCH_ENV
|
2018-05-02 20:00:15 +03:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
python3 /opt/batch-shipyard/task_file_mover.py "$jobid" "$taskid" ${include} ${exclude} ${dest}
|
2016-10-21 07:18:31 +03:00
|
|
|
done
|