8 if [ ! -d "$mountpoint_basedir" ]
10 echo "$0: supposed basedir is not a directory: $mountpoint_basedir" >&2
15 connection_params
=${connection_params##*/}
17 # connection_params is in form of:
19 # relevant ssh config option: ControlPath /home/.../somewhere/%r@%n(%h):%p
20 # see man ssh_config(5) for details.
23 # /home/.../somewhere IN_CREATE autosshfs-mount mnt/ssh $#
25 if [[ $connection_params =~ ^
([^@
]+)@
([^\
(]+)\
(([^\
)]+)\
):([0-9]+) ]]
27 user
=${BASH_REMATCH[1]}
28 host=${BASH_REMATCH[2]}
29 hostname
=${BASH_REMATCH[3]}
30 port
=${BASH_REMATCH[4]}
32 hash=`echo -n "$user$host$hostname$port" | md5sum | cut -c 1-32`
33 exec {lockfd
}>> /tmp
/autosshfs-mount-
$hash.lock
35 if flock
--no-fork --exclusive --timeout 10 $lockfd
37 mountname
="$user@$host($hostname,$port)"
38 mountpoint
="$mountpoint_basedir/$mountname"
39 mkdir
-p "$mountpoint"
40 ln -snfT "$mountname" "$mountpoint_basedir/$host"
41 if ! mountpoint
"$mountpoint"
43 sshfs
-o allow_root
,auto_unmount
,Port
=$port,ControlMaster
=no
,transform_symlinks
,reconnect
,Hostname
="$hostname" "$user@$host:/" "$mountpoint" {lockfd
}>&-
47 echo "$0: sshfs error $err" >&2
51 echo "$0: can not acquire lock" >&2
55 echo "$0: can not parse connection params: $connection_params" >&2