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.

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