#!/bin/bash

LOG_LEVEL=INFO

ARG1="$1"
[ -v "$ARG1" ] && SUBDIR="" || SUBDIR="$ARG1"
#RESYNC="--resync"
#RESYNC=""

#rclone sync --config /opt/rclone/rclone.conf onedrive:/Inbox /mnt/inbox --log-file /opt/logs/rclone/rclone_inbox_sync.log --log-level=INFO


/usr/bin/rclone move "onedrive:/Inbox/$SUBDIR" "/mnt/inbox/$SUBDIR" --config /opt/rclone/rclone.conf --log-file "/opt/logs/rclone/rclone_inbox_$SUBDIR_sync.log" --log-level $LOG_LEVEL

chown dbi:rclone -R /mnt/inbox
chmod 770 -R /mnt/inbox
