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
1.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. export TMPDIR=${TMPDIR:-/tmp}
  2. load_config() {
  3. local config_path=$TMPDIR/rclone_config
  4. local rclone_config_path=/opt/rclone/config
  5. local rclone_config_file=$rclone_config_path/.rclone.conf
  6. (jq -r '.source.config // empty' < $1) > $config_path
  7. if [ -s $config_path ]; then
  8. mkdir -p $rclone_config_path
  9. mv $config_path $rclone_config_file
  10. # TODO: Remove Me - DEBUGGING
  11. echo "Config file:"
  12. cat $rclone_config_file
  13. chmod 500 $rclone_config_file
  14. else
  15. echo "No config provided"
  16. exit 1
  17. fi
  18. }
  19. load_files() {
  20. set +e
  21. local files=$(jq -r '.source.files? | keys? | join(" ") // ""' < $1)
  22. set -e
  23. # TODO: Remove Me - DEBUGGING
  24. echo "Files:"
  25. echo $files
  26. if [[ ! -z "${files}" ]]; then
  27. for fileName in $files; do
  28. local jq_path=".source.files.${fileName}"
  29. local content=$(jq -r "${jq_path}" < $1)
  30. echo "$content" > "/tmp/${fileName}"
  31. # TODO: Remove Me - DEBUGGING
  32. echo "File /tmp/${fileName}"
  33. cat /tmp/${fileName}
  34. done
  35. fi
  36. }