ea0b0cc7990f9f68270762675a3beae01d9c2ee8
[scripts.git] / sshmount.sh
1 #!/bin/bash
2
3 ##################################################################
4 # START_IP_HEADER                                                #
5 #                                                                #
6 # Written by Francois Fleuret                                    #
7 # Contact <francois.fleuret@idiap.ch> for comments & bug reports #
8 #                                                                #
9 # END_IP_HEADER                                                  #
10 ##################################################################
11
12 set -e
13
14 hostname=$1
15 remotepath=$2
16
17 localpath=/tmp/sshfs/${hostname}/${remotepath}
18
19 if [[ $(mount | grep ${hostname}:${remotepath}) ]]; then
20     fusermount -u ${localpath}
21     echo "${localpath} is unmounted."
22 else
23     mkdir -p ${localpath}
24     sshfs -o idmap=user -C ${hostname}:${remotepath} ${localpath}
25     echo "${localpath} is mounted."
26 fi