#! /bin/bash

scriptdir="$(dirname "${BASH_SOURCE[0]}")"

prefix="/folder"
alias="local-minio"
key="abc123"

function push() {
   to_dir="$(realpath "${1}")"
   realdir="$(dirname "$to_dir")"
   if [ -f "$to_dir" ]; then
      to_dir="$realdir"
   fi
   mnt="/mnt/${realdir#/}"
   cat enc_conf | \
   KEY=abc123 ./cloudly-min -cmd decode > /tmp/conf && \
   rclone --fast-list --config /tmp/conf \
   copy "$(realpath "${1}")" "${alias%:}:${prefix%/}$to_dir"
   echo rclone --fast-list --config /tmp/conf \
   copy "$(realpath "${1}")" "${alias%:}:${prefix%/}$to_dir"
}

for i in "$@"; do
        push "$(realpath "${i}")"
done
