Changes between Initial Version and Version 1 of SshfsMnt


Ignore:
Timestamp:
Jul 23, 2015, 1:56:35 PM (3 years ago)
Author:
chris
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SshfsMnt

    v1 v1  
     1= SSHFS Mount Script =
     2
     3This is a script to mount fules systens via SFTP using Fuse.
     4
     5{{{
     6#!/bin/bash
     7
     8# http://fuse.sourceforge.net/sshfs.html
     9
     10# the place file systems are to be mounted
     11MOUNT_POINT="/media"
     12if [[ ! -d "$MOUNT_POINT" ]]; then
     13  echo "It looks like $MOUNT_POINT doesn't exist?"
     14  exit
     15fi
     16
     17# check for server to mount on standard input
     18if [[ $1 ]]; then
     19  SERVER=$1
     20elif [[ ! $1 ]]; then
     21  echo "Type the server you want to mount and then [ENTER]:"
     22  read server
     23  SERVER=$server
     24fi
     25
     26# check the server is setup in ~/.ssh/config
     27SSH_CONFIG=$(grep "Host $SERVER" ~/.ssh/config)
     28if [[ ! $SSH_CONFIG ]]; then
     29  echo "It looks like you need to edit yur ~/.ssh/config"
     30  echo "to add entries like this for each server:"
     31  echo
     32  echo "Host example"
     33  echo "   User root"
     34  echo "   Hostname example.org"
     35  echo
     36  exit
     37fi
     38
     39# check if the mount point exists and if not create it
     40if [[ ! -d "$MOUNT_POINT/$SERVER"]]; then
     41  echo "Creating $MOUNT_POINT/$SERVER"
     42  mkdir "$MOUNT_POINT/$SERVER"
     43fi
     44
     45# check is the file system appears to already be mounted
     46DF=$(df | awk -F' ' '{ print $6 }' | grep "$MOUNT_POINT/$SERVER")
     47if [[ $DF ]]; then
     48  echo "It appears that $SERVER is already mounted at $DF?"
     49  exit
     50fi
     51
     52# Mount the file system
     53sshfs $SERVER:/ $MOUNT_POINT/$SERVER/
     54}}}