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.

57 lines
1.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/bin/bash
  2. set -e
  3. exec 3>&1 # make stdout available as fd 3 for the result
  4. exec 1>&2 # redirect all output to stderr for logging
  5. echo $BUILD_ID
  6. echo $BUILD_NAME
  7. echo $BUILD_JOB_NAME
  8. echo $BUILD_PIPELINE_NAME
  9. source $(dirname $0)/common.sh
  10. source=$1
  11. if [ -z "$source" ]; then
  12. echo "usage: $0 <path/to/source>"
  13. exit 1
  14. fi
  15. # for jq
  16. PATH=/usr/local/bin:$PATH
  17. payload=$(mktemp $TMPDIR/rclone-resource-request.XXXXXX)
  18. cat > $payload <&0
  19. load_config $payload
  20. load_files $payload
  21. rclone_source_directory=$(jq -r '.params.source // ""' < $payload)
  22. rclone_destination=$(jq -r '.params.destination // ""' < $payload)
  23. rclone_destination_subdir_file=$(jq -r '.params.subdir // ""' < $payload)
  24. if [ -z "$rclone_source_directory" ]; then
  25. echo "invalid source directory (missing source)"
  26. exit 1
  27. fi
  28. if [ -z "$rclone_destination" ]; then
  29. echo "invalid destination (missing destination)"
  30. exit 1
  31. fi
  32. rclone_destination_subdir=""
  33. if [ ! -z "$rclone_destination_subdir_file" ]; then
  34. rclone_destination_subdir=$(cat "${source}${rclone_destination_subdir}")
  35. fi
  36. rclone_source="local:${source}/${rclone_source_directory}"
  37. rclone_target="${rclone_destination}${rclone_destination_subdir}"
  38. echo "Source: ${rclone_source}"
  39. echo "Target: ${rclone_target}"
  40. rclone copy "${rclone_source}" "${rclone_target}" --config /opt/rclone/config/.rclone.conf
  41. md5sum "${BUILD_PIPELINE_NAME}-${BUILD_ID}" >&3