#!/data/data/com.termux/files/usr/bin/sh

# org storage locations
export LOCAL="/data/data/com.termux/files/home/storage/shared"
export NC="nc-personal:"

# rclone common flags/switches
export RC_COMMON="--delete-after --fast-list --human-readable -P --transfers=10"

# get a wake lock so we dont get background killed
/data/data/com.termux/files/usr/bin/termux-wake-lock

# sync org data to local device (pull down outstanding changes, if any)
echo "syncing devdocs.el data from nextcloud -> local storage"
/data/data/com.termux/files/usr/bin/rclone sync \
    $RC_COMMON \
    ${NC}/devdocs.el/ ${LOCAL}/devdocs.el

echo "syncing devdocs-browser data from nextcloud -> local storage"
/data/data/com.termux/files/usr/bin/rclone sync \
    $RC_COMMON \
    ${NC}/devdocs-browser/ ${LOCAL}/devdocs-broswer/

# pause to review rclone output
echo "press enter to continue"
read junkvar

# release wake lock
/data/data/com.termux/files/usr/bin/termux-wake-unlock