You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
1.2 KiB

#!/bin/bash
set -e
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
source $(dirname $0)/common.sh
source=$1
if [ -z "$source" ]; then
echo "usage: $0 <path/to/source>"
exit 1
fi
cd $source
payload=$(mktemp $TMPDIR/concoure-curl-resource-request.XXXXXX)
cat > $payload <&0
cat $payload
url=$(jq -r '.source.url // ""' < $payload)
filename=$(jq -r '.source.filename // ""' < $payload)
skip_ssl_verification=$(jq -r '.source.skip_ssl_verification // ""' < $payload)
if [ -z "$url" ]; then
echo "invalid payload (missing url)"
exit 1
fi
if [ -z "$filename" ]; then
filename="file"
fi
# Building CURL request
args_url="$url"
args_security=
# [ -n "$username" ] && args_security="-u $username";
# [ -n "$password" ] && args_security="$args_security:$password";
trueValue="true"
[ -n "$skip_ssl_verification" ] && [ "${skip_ssl_verification,,}" = "${trueValue,,}" ] && args_security="$args_security -k";
final_url=$(echo "$args_security" " $args_url")
echo $final_url
version=$(check_version "$final_url")
if [ -z "$version" ]; then
echo "Version could not be retrieved"
exit 1
fi
curl $args_security "$args_url" "-o" "$filename"
echo "{'version': {'version': '$version'}}" >&3