Last active
July 11, 2020 08:21
-
-
Save glukicov/d843dec124de27c9c158b1b1aec5e723 to your computer and use it in GitHub Desktop.
mount.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#----------------------------------------------------------- | |
remotedir="USERNAME@HOST:/PATH/TO/MOUNT" # TODO Add directory on the remote machine | |
mountdir="/Users/user/Mount/Directory" # TODO Add local directory | |
echo "Mounting (${mountdir})..." | |
if [ -d "${mountdir}" ]; then | |
#Unmount if it's already mounted | |
if mount | grep "on $mountdir" > /dev/null; then | |
umount ${mountdir} | |
fi | |
else | |
mkdir ${mountdir} | |
fi | |
#Now mount the remote file system | |
# (The -o workaround=rename -o noexec are used so kwrite can save files.) | |
sshfs -o ssh_command='ssh -AKXY' -o workaround=rename -o noexec -o idmap=user -o uid=$(id -u) -o gid=$(id -g) ${remotedir} ${mountdir} | |
#Sleep 1 second to give it time to register, then check that it is now mounted | |
sleep 1 | |
if mount | grep "on $mountdir" > /dev/null; then | |
echo "Success" | |
cd ${mountdir} | |
else | |
echo "Failure!" | |
fi | |
# exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment