Created
October 28, 2013 11:44
-
-
Save AndiH/7195447 to your computer and use it in GitHub Desktop.
sshvol – Commandline-mounts a remote ssh volume. Got that from some one who got that from some one who…
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 | |
# fast mount of home at remote server by its name or alias in .ssh/config | |
# usage: autosshfs <server-name> (without trailing : or path) | |
SERVER=$1 | |
MOUNT_DIR=/Volumes | |
if [[ -z $SERVER ]]; then | |
echo "usage: sshvol <server-name>[:<server_path>]" | |
exit 1 | |
fi | |
LOCAL_PATH=`echo -n $SERVER | tr -d ':' | tr '/' '-'` | |
if [ `expr $SERVER : '.*:'` == 0 ]; then | |
# short path | |
SERVER_PATH=$SERVER: | |
else | |
# full path | |
SERVER_PATH=$SERVER | |
fi | |
MOUNT_POINT=$MOUNT_DIR/$LOCAL_PATH | |
if [[ -e $MOUNT_POINT ]]; then | |
if [[ ! -d $MOUNT_POINT ]]; then | |
echo "file $MOUNT_POINT exists and is not a directory" | |
exit 1 | |
fi | |
# elif [[ {mount | grep -q $MOUNT_POINT} ]]; then | |
# echo "something is already mounted on $MOUNT_POINT" | |
# exit 1 | |
# fi | |
else | |
mkdir $MOUNT_POINT || (echo "cannot create directory $MOUNT_POINT"; exit 1) | |
fi | |
sshfs $SERVER_PATH $MOUNT_POINT -o volname=$SERVER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment