#!/bin/sh # # Helper to mount rclone-fuse from /etc/fstab. To use, add an entry # like: # # # DEVICE PATH TYPE OPTIONS # rclonemount#robert#local:/data/Media2 /home/robert/test fuse _netdev,defaults 0 0 # rclonemount#robert#local:/data/Media2 /home/robert/test fuse read-only,config=/home/robert/.rclone.conf 0 0 # # where the device field is a pound-separated list of options to pass on # the command line. The examples above, for example, specify that # rclone will authenticate as robert and attempt to mount remote local:/data/Media2 # The second example also sets the read-only and 'config' option to # '/home/robert/.rclone.conf' via the rclone command line. Any valid # rclone can be passed in this way. # _net_dev can be used to tell automount to NOT mount at boot as your network # device may not be ready yet. If you use this option, you'd need something else # to issue the mount command itself. Alternatively, a sleep can be added to the rclonemount # helper to wait before mount. set -e # id is mandatory. Specifiy 'root' if you want it run as root. id=`echo $1 | cut -d '#' -f 1` # path is mandatory. path=`echo $1 | cut -d '#' -f 2` shift mountpoint=$1; shift while [ "$1" = "-o" ] do shift done opts=$1 # strip out 'dev' option; rclone doesn't like it opts=`echo $opts | sed 's/,dev//' | sed 's/dev,//'` # strip out 'rw' option; rclone doesn't like it and its the default anyway opts=`echo $opts | sed 's/,rw//' | sed 's/rw,//'` # strip out 'suid option; rclone doesn't like it opts=`echo $opts | sed 's/,suid//' | sed 's/suid,//' | sed 's/suid//'` # convert device string to options opts='--'`echo $opts | sed 's/,/ --/g'` # go su - $id -c "rclone mount $path $mountpoint $opts" & # echo $id #echo $opts #echo $path #echo $mountpoint