#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2020-present Fewtarius CONFIGPATH="/storage/.config" if [ -z "$2" ] then if [ -e "${CONFIGPATH}/rsync.conf" ] then source ${CONFIGPATH}/rsync.conf else MOUNTPATH="/storage/cloud" SYNCPATH="GAMES" fi else MOUNTPATH=${2} fi if [ ! -d "${CONFIGPATH}/cloud-sync-rules.conf" ] then cp -rf /usr/config/cloud-sync-rules.conf ${CONFIGPATH}/cloud-sync-rules.conf fi function checkconfig() { if [ ! -e "${CONFIGPATH}/rclone/rclone.conf" ] then echo "You must configure rclone before using this tool. Run \`rclone config\` to get started." exit 1 fi if [ ! -d "${MOUNTPATH}" ] then mkdir -p ${MOUNTPATH} fi } function mount() { TARGET=$(rclone listremotes | awk '{printf $1; exit}') rclone mount ${TARGET}/ ${1} \ --vfs-cache-mode writes \ --vfs-cache-max-size 100M \ --vfs-read-chunk-size-limit 128M \ --vfs-read-chunk-size-limit off \ --allow-non-empty \ --dir-cache-time 48h \ --log-file /var/log/rclone.log \ --daemon } function unmount() { fusermount -u ${1} } case "${1}" in "mount") checkconfig mount ${MOUNTPATH} ;; "unmount") checkconfig unmount ${MOUNTPATH} ;; "$*") cat <