Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Paste
P284
~/bin/mount-user-fs
Active
Public
Actions
Authored by
dereckson
on Oct 6 2018, 00:03.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F654870: ~/bin/mount-user-fs
Oct 6 2018, 00:03
2018-10-06 00:03:14 (UTC+0)
Subscribers
None
#!/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
2018-10-06 00:03:14 (UTC+0)
Log In to Comment