Changes between Version 8 and Version 9 of SshfsMnt
- Timestamp:
- Oct 14, 2015, 12:22:30 PM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SshfsMnt
v8 v9 16 16 if [[ ! -d "$MOUNT_POINT" ]]; then 17 17 echo "It looks like $MOUNT_POINT doesn't exist?" 18 exit 18 exit 1 19 19 fi 20 20 … … 38 38 echo " Hostname example.org" 39 39 echo 40 exit 40 exit 1 41 41 fi 42 42 … … 44 44 if [[ ! -d "$MOUNT_POINT/$SERVER" ]]; then 45 45 echo "Creating $MOUNT_POINT/$SERVER" 46 mkdir "$MOUNT_POINT/$SERVER" 46 mkdir "$MOUNT_POINT/$SERVER" || { echo "Failed to create $MOUNT_POINT/$SERVER" ; exit 1 ; } 47 47 fi 48 48 49 # check i fthe file system appears to already be mounted49 # check is the file system appears to already be mounted 50 50 DF=$(df | awk -F' ' '{ print $6 }' | grep "$MOUNT_POINT/$SERVER") 51 51 if [[ $DF ]]; then 52 52 echo "It appears that $SERVER is already mounted at $DF?" 53 exit 53 exit 1 54 54 fi 55 55 56 56 # Mount the file system 57 sshfs $SERVER:/ $MOUNT_POINT/$SERVER/ 57 sshfs $SERVER:/ $MOUNT_POINT/$SERVER/ && \ 58 # if this succeeded 59 { echo "Mounted $SERVER:/ on $MOUNT_POINT/$SERVER/" ; exit 0 ; } || \ 60 # if this failed 61 { echo "Problem mounting $SERVER:/ $MOUNT_POINT/$SERVER/" ; exit 1 ; } 58 62 }}} 59 63 … … 69 73 if [[ ! -d "$MOUNT_POINT" ]]; then 70 74 echo "It looks like $MOUNT_POINT doesn't exist?" 71 exit 75 exit 1 72 76 fi 73 77 … … 80 84 SERVER=$server 81 85 fi 86 87 # check if the mount point exists 88 if [[ ! -d "$MOUNT_POINT/$SERVER" ]]; then 89 echo "It looks like "$MOUNT_POINT/$SERVER" doesn't exist?" 90 exit 1 91 fi 82 92 83 93 # check if the file system appears to already be mounted 84 DF=$(df | awk -F' ' '{ print $6 }' | grep "$MOUNT_POINT/$SERVER")94 DF=$(df | awk -F' ' '{ print $6 }' | grep -w "$MOUNT_POINT/$SERVER") 85 95 if [[ $DF ]]; then 86 echo "Umounting $SERVER at $DF?" 87 fusermount -u $MOUNT_POINT/$SERVER 88 exit 96 # unmount the filesystem 97 fusermount -u $MOUNT_POINT/$SERVER && \ 98 # if success 99 { echo "Umounted $SERVER at $DF" ; exit 0 ; } || \ 100 # if mounting failed 101 { echo "Problem unmounting $MOUNT_POINT/$SERVER" ; exit 1 ; } 89 102 else 90 echo "It appears that $SERVER is not mounted" 103 echo "It appears that $SERVER is not mounted at $MOUNT_POINT/$SERVER" 104 exit 1 91 105 fi 92 106 }}}