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
1.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/usr/bin/bash
  2. export TMPDIR=${TMPDIR:-/tmp/rclone}
  3. mkdir -p "${TMPDIR}"
  4. load_config() {
  5. RCLONE_CONFIG=$TMPDIR/.config/rclone_config
  6. export RCLONE_CONFIG
  7. (jq -r '.source.config // empty' < "$1") > "$RCLONE_CONFIG"
  8. config_pass=$(jq -r '.source.password // ""' < "$1")
  9. if [[ -n "${config_pass}" ]]; then
  10. RCLONE_CONFIG_PASS="${config_pass}"
  11. export RCLONE_CONFIG_PASS
  12. fi
  13. if [ -s "${RCLONE_CONFIG}" ]; then
  14. chmod 500 "${RCLONE_CONFIG}"
  15. else
  16. echo "No config provided"
  17. exit 1
  18. fi
  19. }
  20. load_files() {
  21. set +e
  22. local files
  23. files=$(jq -r '.source.files? | keys? | join(" ") // ""' < "$1")
  24. set -e
  25. if [[ -n "${files}" ]]; then
  26. for fileName in $files; do
  27. local jq_path
  28. local content
  29. jq_path=".source.files.${fileName}"
  30. content=$(jq -r "${jq_path}" < "$1")
  31. echo "$content" > "${TMPDIR}/${fileName}"
  32. echo "Wrote: ${TMPDIR}/${fileName}"
  33. done
  34. ls -alh "${TMPDIR}"
  35. fi
  36. }