Page MenuHomeDevCentral
Paste P284

~/bin/mount-user-fs
ActivePublic

Authored by dereckson on Oct 6 2018, 00:03.
#!/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

Event Timeline

dereckson created this paste.Oct 6 2018, 00:03