From 65406878e5ff362f38b64f001433d5872d909036 Mon Sep 17 00:00:00 2001 From: Mikhail Yenuchenko <76039929+mixeme@users.noreply.github.com> Date: Sat, 18 Sep 2021 23:09:36 +0300 Subject: [PATCH] Enable syntax highlight for the script --- rclone-mount-helper-script.md | 80 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/rclone-mount-helper-script.md b/rclone-mount-helper-script.md index 9922f6d..3c93010 100644 --- a/rclone-mount-helper-script.md +++ b/rclone-mount-helper-script.md @@ -2,49 +2,49 @@ To enable mounting a rclone volume using system mount tool, the following helper script must be named `rclonefs` and placed in `$PATH`: - #!/bin/bash - remote=$1 - mountpoint=$2 - shift 2 +```bash +#!/bin/bash +remote=$1 +mountpoint=$2 +shift 2 - # Process -o parameters - while getopts :o: opts; do - case $opts in - o) - params=${OPTARG//,/ } - for param in $params; do - if [ "$param" == "rw" ]; then continue; fi - if [ "$param" == "ro" ]; then continue; fi - if [ "$param" == "dev" ]; then continue; fi - if [ "$param" == "suid" ]; then continue; fi - if [ "$param" == "exec" ]; then continue; fi - if [ "$param" == "auto" ]; then continue; fi - if [ "$param" == "nodev" ]; then continue; fi - if [ "$param" == "nosuid" ]; then continue; fi - if [ "$param" == "noexec" ]; then continue; fi - if [ "$param" == "noauto" ]; then continue; fi - if [[ $param == x-systemd.* ]]; then continue; fi - trans="$trans --$param" - done - ;; - \?) - echo "Invalid option: -$OPTARG" - ;; - esac - done - - # exec rclone - trans="$trans $remote $mountpoint" - # NOTE: do not try "mount --daemon" here, it does not play well with systemd automount, use '&'! - # NOTE: mount is suid and ignores pre-set PATHs -> specify explicitely - PATH=$PATH rclone mount $trans /dev/null 2>/dev/null & - - # wait until mounting is complete - until grep -q " ${mountpoint// /\\\\040} fuse.rclone " /proc/mounts; do - sleep 0.5 - done +# Process -o parameters +while getopts :o: opts; do + case $opts in + o) + params=${OPTARG//,/ } + for param in $params; do + if [ "$param" == "rw" ]; then continue; fi + if [ "$param" == "ro" ]; then continue; fi + if [ "$param" == "dev" ]; then continue; fi + if [ "$param" == "suid" ]; then continue; fi + if [ "$param" == "exec" ]; then continue; fi + if [ "$param" == "auto" ]; then continue; fi + if [ "$param" == "nodev" ]; then continue; fi + if [ "$param" == "nosuid" ]; then continue; fi + if [ "$param" == "noexec" ]; then continue; fi + if [ "$param" == "noauto" ]; then continue; fi + if [[ $param == x-systemd.* ]]; then continue; fi + trans="$trans --$param" + done + ;; + \?) + echo "Invalid option: -$OPTARG" + ;; + esac +done +# exec rclone +trans="$trans $remote $mountpoint" +# NOTE: do not try "mount --daemon" here, it does not play well with systemd automount, use '&'! +# NOTE: mount is suid and ignores pre-set PATHs -> specify explicitely +PATH=$PATH rclone mount $trans /dev/null 2>/dev/null & +# wait until mounting is complete +until grep -q " ${mountpoint// /\\\\040} fuse.rclone " /proc/mounts; do + sleep 0.5 +done +``` ## fstab In `/etc/fstab` you can add something like: