Enable syntax highlight for the script

Mikhail Yenuchenko 2021-09-18 23:09:36 +03:00
parent 925f471eed
commit 65406878e5

@ -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 >/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 >/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: