Skip to content

Instantly share code, notes, and snippets.

@joltcan
Created October 27, 2017 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joltcan/1544592c4cc767836d57ba480013f3b6 to your computer and use it in GitHub Desktop.
Save joltcan/1544592c4cc767836d57ba480013f3b6 to your computer and use it in GitHub Desktop.
#!/bin/bash
MOUNTPATH=/Volumes/<somepath>
USERNAME=<user>
SERVER=<server>
KEYFILE=/home/<user>/.ssh/<keyfile>
if [ ! -d "$MOUNTPATH ]; then mkdir -p "$MOUNTPATH" ; fi
function mountdisk {
# first we unmount since we don't trust sshfsmounts really
sudo fusermount -uzq "$MOUNTPATH" > /dev/null 2>&1
sudo umount -fl "$MOUNTPATH" > /dev/null 2>&1
sudo sshfs $USER@$SERVER:/ftp/ftp "$MOUNTPATH" -o follow_symlinks,allow_other,port=22 -o IdentityFile="$KEYFILE" -o kernel_cache -o Ciphers=aes128-ctr -o auto_cache -o cache_timeout=600 -o attr_timeout=115200 -o entry_timeout=300 -o max_readahead=90000 -o no_remote_lock -o big_writes
}
dev=`df -P "$MOUNTPATH" 2>&1 | awk 'BEGIN {e=1} $NF ~ /^\/.+/ { e=0 ; print $1 ; exit } END { exit e }'` && {
exit 0
} || {
# here we call our function from above
mountdisk
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment