Page MenuHomeDevCentral

~/bin/mount-user-fs

Authored By
dereckson
Oct 6 2018, 00:03
Size
700 B
Referenced Files
None
Subscribers
None

~/bin/mount-user-fs

#!/bin/sh
# Mount if needed
mount_sshfs()
{
COMMAND=$1
SERVER=$2
SOURCE=$3
TARGET=$4
if [ "$COMMAND" = "mount" ]; then
grep -qs $TARGET /proc/mounts || sshfs $SERVER:$SOURCE $TARGET
elif [ "$COMMAND" = "umount" ]; then
grep -qs $TARGET /proc/mounts && sudo umount $FORCE $TARGET
fi
}
# Command
COMMAND=mount
if [ "$1" = "umount" ] || [ "$1" = "unmount" ]; then
COMMAND="umount"
FORCE=""
test "$2" = "-f" && FORCE="--force"
test "$2" = "--force" && FORCE="--force"
fi
# Remount all points
mount_sshfs $COMMAND server1.domain.tld /some/remote/path /some/local/path
mount_sshfs $COMMAND server2.domain.tld /some/remote/path /another/local/path

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
198416
Default Alt Text
~/bin/mount-user-fs (700 B)

Event Timeline