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.

24 lines
660 B

5 years ago
  1. export TMPDIR=${TMPDIR:-/tmp}
  2. load_config() {
  3. local config_path=$TMPDIR/rclone_config
  4. (jq -r '.source.config // empty' < $1) > $config_path
  5. if [ -s $config_path ]; then
  6. mkdir -p /opt/rclone/config
  7. mv $config_path > /opt/rclone/config/.rclone.conf
  8. chmod 500 /opt/rclone/config/.rclone.conf
  9. else
  10. echo "No config provided"
  11. exit 1
  12. fi
  13. }
  14. load_files() {
  15. local files=$(jq -r '.source.files | keys | join(" ")' < $1)
  16. for fileName in files; do
  17. local jq_path=".source.files.${fileName}"
  18. local content=$(jq -r "${jq_path}" < $1)
  19. echo "$content" > "/tmp/${fileName}"
  20. done
  21. }