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.

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