From: Francois Fleuret Date: Mon, 10 May 2010 16:49:32 +0000 (+0200) Subject: *** empty log message *** X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=64b41be2a78d2dc2d500f140491ed69a890d82ad;p=scripts.git *** empty log message *** --- diff --git a/sshmount.sh b/sshmount.sh index ea0b0cc..3cd7f51 100755 --- a/sshmount.sh +++ b/sshmount.sh @@ -1,26 +1,54 @@ #!/bin/bash -################################################################## -# START_IP_HEADER # -# # -# Written by Francois Fleuret # -# Contact for comments & bug reports # -# # -# END_IP_HEADER # -################################################################## +######################################################################### +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the version 3 of the GNU General Public License # +# as published by the Free Software Foundation. # +# # +# This program is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # +# General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# Written by and Copyright (C) Francois Fleuret # +# Contact for comments & bug reports # +######################################################################### set -e hostname=$1 remotepath=$2 +localpath=/mnt/sshfs/${hostname}/${remotepath} -localpath=/tmp/sshfs/${hostname}/${remotepath} +if [[ $1 == "--help" ]] || [[ $1 == "-h" ]]; then + cat < []] -if [[ $(mount | grep ${hostname}:${remotepath}) ]]; then - fusermount -u ${localpath} - echo "${localpath} is unmounted." +Mount the remote path on /mnt/sshfs// if it is +not already mounted. Umount it otherwise. + +If no argument is provided, tries to umount all the mounted sshfs +volumes. +EOF + + exit 0 +fi + +if [[ $1 ]]; then + if [[ $(mount | grep ${hostname}:${remotepath}) ]]; then + fusermount -u ${localpath} + echo "sshfs umounted from ${localpath}." + else + mkdir -p ${localpath} + sshfs -o idmap=user -C ${hostname}:${remotepath} ${localpath} + echo "Remote ${hostname}:${remotepath} mounted on ${localpath}." + fi else - mkdir -p ${localpath} - sshfs -o idmap=user -C ${hostname}:${remotepath} ${localpath} - echo "${localpath} is mounted." + for v in $(mount | grep fuse.sshfs | cut -f 3 -d' '); do + fusermount -u ${v} + echo "sshfs umounted from ${v}" + done fi