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.

38 lines
1001 B

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