2022-04-03 14:48:52 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2020-present Fewtarius
|
|
|
|
|
|
|
|
CONFIGPATH="/storage/.config"
|
|
|
|
|
|
|
|
if [ -z "$2" ]
|
|
|
|
then
|
2022-04-03 16:38:59 +00:00
|
|
|
if [ -e "${CONFIGPATH}/rsync.conf" ]
|
|
|
|
then
|
|
|
|
source ${CONFIGPATH}/rsync.conf
|
|
|
|
else
|
|
|
|
MOUNTPATH="/storage/cloud"
|
|
|
|
SYNCPATH="GAMES"
|
|
|
|
fi
|
2022-04-03 14:48:52 +00:00
|
|
|
else
|
|
|
|
MOUNTPATH=${2}
|
|
|
|
fi
|
|
|
|
|
2022-04-03 17:15:49 +00:00
|
|
|
for CONFIG in rsync.conf rsync-rules.conf
|
|
|
|
do
|
2022-05-25 16:33:44 +00:00
|
|
|
if [ ! -e "${CONFIGPATH}/${CONFIG}" ]
|
2022-04-03 17:15:49 +00:00
|
|
|
then
|
|
|
|
cp -rf /usr/config/${CONFIG} ${CONFIGPATH}/${CONFIG}
|
|
|
|
fi
|
|
|
|
done
|
2022-04-03 14:48:52 +00:00
|
|
|
|
|
|
|
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 <<EOF
|
|
|
|
rclonectl is a simple rclone wrapper for mounting and unmounting cloud volumes using fuse.
|
|
|
|
|
|
|
|
Usage: rclonectl {mount,unmount} {path}
|
|
|
|
|
|
|
|
If no path is provided the tool will default to ${MOUNTPATH}.
|
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|