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
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. # TODO: Remove Me - DEBUGGING
  12. echo "Config file:"
  13. cat $rclone_config_file
  14. chmod 500 $rclone_config_file
  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. # TODO: Remove Me - DEBUGGING
  26. echo "Files:"
  27. echo "$files"
  28. if [[ ! -z "${files}" ]]; then
  29. for fileName in $files; do
  30. local jq_path=".source.files.${fileName}"
  31. local content=$(jq -r "${jq_path}" < "$1")
  32. echo "$content" > "/tmp/${fileName}"
  33. # TODO: Remove Me - DEBUGGING
  34. echo "File /tmp/${fileName}"
  35. cat "/tmp/${fileName}"
  36. done
  37. fi
  38. }