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.

42 lines
994 B

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. source $(dirname $0)/common.sh
  6. source=$1
  7. if [ -z "$source" ]; then
  8. echo "usage: $0 <path/to/source>"
  9. exit 1
  10. fi
  11. # for jq
  12. PATH=/usr/local/bin:$PATH
  13. payload=$(mktemp $TMPDIR/rclone-resource-request.XXXXXX)
  14. cat > $payload <&0
  15. load_config $payload
  16. load_files $payload
  17. rclone_source_directory=$(jq -r '.params.source // ""' < $payload)
  18. rclone_destination=$(jq -r '.params.destination // ""' < $payload)
  19. rclone_destination_subdir=$(jq -r '.params.subdir // ""' < $payload)
  20. if [ -z "$rclone_source_directory" ]; then
  21. echo "invalid source directory (missing source)"
  22. exit 1
  23. fi
  24. if [ -z "$rclone_destination" ]; then
  25. echo "invalid destination (missing destination)"
  26. exit 1
  27. fi
  28. rclone_source="local:${source}/${rclone_source_directory}"
  29. rclone_target="${rclone_destination}${rclone_destination_subdir}"
  30. rclone copy "${rclone_source}" "${rclone_target}"