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.

39 lines
990 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
  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. # TODO: Remove Me - DEBUGGING
  23. echo "Files:"
  24. echo "$files"
  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" > "/tmp/${fileName}"
  32. done
  33. fi
  34. }