sshfs mounting script a.k.a. sshfs MoM
Disclaimer: There may be a better way of doing this, I am not a scripting master, just checked out this guide and whipped this together quickly.
I usually edit a sshfs mounting script file every time I want to mount a different server. I have decided to make a more elaborate bash script that can do this more on the fly like so
SSHFS mount-o-matic
Which mount do you want to do?
1) rimu 3) eproot 5) epvarwww 7) quit
2) mirror 4) eprets 6) rb
#? 6
rb MT mounted
#? 2
Mirror mounted
#? 4
eprets mounted
#? 1
Here is the script file, should be self explanatory what goes where, replace the options array with the names of your servers, replace the if-case tests with the respective new names, adjust the sshfs commands to meet your needs. Not I use simple host names in my code, this can be achieved by configuring your ~/.ssh/hosts file.
#!/bin/bash
echo SSHFS mount-o-matic
echo Which mount do you want to do?
OPTIONS="rimu mirror eproot eprets epvarwww rb quit"
select opt in $OPTIONS; do
if [ "$opt" = "rimu" ]; then
sshfs rimu:/ /home/stk/mounts/rimu
echo rimu mounted.
exit
elif [ "$opt" = "mirror" ]; then
sshfs mirror:/mirror /home/stk/mounts/mirror
echo Mirror mounted
elif [ "$opt" = "eproot" ]; then
sshfs ep:/root /home/stk/mounts/eproot
echo eproot mounted
elif [ "$opt" = "eprets" ]; then
sshfs ep:/rets /home/stk/mounts/eprets
echo eprets mounted
elif [ "$opt" = "epvarwww" ]; then
sshfs ep:/var/www /home/stk/mounts/epvarwww
echo ep /var/www/ mounted
elif [ "$opt" = "rb" ]; then
sshfs rb:domains/rbdomain/html/ /home/stk/mounts/rb -o workaround=rename
echo rb MT mounted
elif [ "$opt" = "7" ]; then
exit
else
clear
echo Did not understand your entry, hint, it should be a number between 1 & 7.
fi
done