Added a script to mount SFTP connections if yuo want

This commit is contained in:
Sasha Koshka 2024-02-23 23:19:10 -05:00
parent 1a8a68a631
commit 0af0d8e561

41
glue/src/mount-sftp Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
name=`basename $0`
isInstalled() {
type "$1" > /dev/null
}
mustHaveInstalled() {
if ! isInstalled "$1"; then
echo "$name: $1 is not installed" >&2
exit 1
fi
}
usage() {
echo "Usage: $name" >&2
exit 2
}
[ "$#" -gt 0 ] && usage
sshfsOptions="reconnect,ServerAliveInterval=4,ServerAliveCountMax=10"
mustHaveInstalled sshfs
mustHaveInstalled mountpoint
mustHaveInstalled fusermount
mountsDir="$HOME/Remote"
[ -n "$XMD_SFTP_DIR" ] && mountsDir="$XMD_SFTP_DIR"
for point in "$mountsDir"/*; do
# do not deal with files
[ -d "$point" ] || continue
mountpoint "$point" > /dev/null && fusermount -u "$point"
address=`basename "$point"`
echo "mounting $address on $point" >&2
sshfs "$address:/" "$point" -o $sshfsOptions
done