Bash script to control (start, stop, status) rclone mouting Microsoft OneDrive as a daemon.
#!/bin/sh
# -------------------------------------------------------------------------------
# General Settings. It is safe enough to be changed as needed.
# -------------------------------------------------------------------------------
# RClone remote name.
remote=onedrive
# Absolute path to the folder to be used as mounting point.
mount_point=/mnt/workspace/onedrive
# Absolute path to the RClone config file to be used.
config_path=/home/andresilva/.config/rclone/rclone.conf
# -------------------------------------------------------------------------------
# End of the General Settings section.
# Stop here if you don't know what you are doing.
# -------------------------------------------------------------------------------
rclone_pid=$(pidof rclone)
case $1 in
status)
if test -z "$rclone_pid"
then
echo "Stopped."
else
echo "Started."
fi
;;
start)
if test -z "$rclone_pid"
then
echo "Mounting $remote."
rclone mount $remote: $mount_point --daemon --vfs-cache-mode full --allow-non-empty --syslog --config=$config_path
else
echo "$remote already mounted."
fi
;;
stop)
if test -z "$rclone_pid"
then
echo "$remote is not mounted."
else
echo "Unmounting $remote."
kill -1 $(pidof rclone)
kill -13 $(pidof rclone)
fi
;;
*)
echo "Unknown option."
;;
esac