#!/bin/bash

result=$(ps aux | grep "[r]clone move")
[[ -n "$result" ]] && exit 0

RCLONE_SRC=vmx-load:series
RCLONE_DST=/mnt/union/series
[[ -n $1 ]] && RCLONE_SRC="$1"
[[ -n $2 ]] && RCLONE_DST="$2"
HOSTNAME=$(hostname)
RCLONE_ADDRESS="$HOSTNAME.swallow-grue.ts.net:44444"
RCLONE_CRED="rcd"
RCLONE_SCRIPT_FILE=$(basename "$0") 
RCLONE_LOG_FILE=/var/log/rclone/"$RCLONE_SCRIPT_FILE".log
[[ ! -f "$RCLONE_LOG_FILE" ]] && touch "$RCLONE_LOG_FILE"




rclone rc sync/move srcFs="$RCLONE_SRC" dstFs="$RCLONE_DST" \
--exclude "*check" \
--exclude ".zzz*" \
--exclude "*chk" \
--rc-addr="$RCLONE_ADDRESS" \
--rc-user="$RCLONE_CRED" \
--rc-pass="$RCLONE_CRED" \
_async=true \
--fast-list \
--log-file "$RCLONE_LOG_FILE"