Files
lnx-arch/dots/bin/rcloneHelper.sh
committer@tuxwarrior 7d18992cac out with gitRepos.sh and in with the more generic rcloneHelper.sh
for (un)mounting of rclone remotes
2026-04-05 20:06:15 -05:00

54 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# klevstul :: 26.04
rcloneHelper() {
operation=$1
remote=$2
if [[ ${operation} == "list" ]] ; then
rclone listremotes --long
elif [[ -n ${operation} ]] && [[ -n ${remote} ]] ; then
# check if given remote exist
if ! rclone listremotes | grep -xq ${remote}:; then
echo "'${remote}' is an unknown rclone remote."
exit 1
fi
mnt_dir=/mnt/rclone/${remote}
if ! [[ -d ${mnt_dir} ]]; then
echo "creating non-existing mount dir '${mnt_dir}'."
sudo mkdir -p ${mnt_dir}
sudo chown ${USER}:${USER} ${mnt_dir}
elif [[ ! -d ${mnt_dir} ]] ; then
echo "'${mnt_dir}' exist, but is not a directory" 1>&2
fi
if [[ ${operation} == "umount" ]] || [[ ${operation} == "unmount" ]] ; then
echo "umount ${mnt_dir}"
sudo umount -l ${mnt_dir}
elif [[ ${operation} == "mount" ]] ; then
echo "mount ${mnt_dir}"
rclone mount --vfs-cache-mode full --vfs-cache-max-size 100G --vfs-read-chunk-size 128M --transfers 32 --checkers 16 --tpslimit 12 pcloud: ${mnt_dir} &
else
echo "unknown command...'"
fi
else
echo "sry, bud! try: 'gitRepos {mount,umount} {remote}'"
fi
}
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "error: operation {mount|umount|list} {remote?} is missing."
echo "usage: '$this_file_name {input_1} {input_2}'"
exit 1
fi
rcloneHelper $1 $2