-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-mount
executable file
·45 lines (38 loc) · 1 KB
/
docker-mount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
debug () [[ -v DEBUG ]]
debug && set -x
debug && set -o xtrace
debug && set -v
if [ $# -eq 1 ]
then
mountVolume=$1
mountPath=$(pwd)
elif [ $# -ne 2 ]
then
echo Usage: $(basename "$0") volume [path]
exit 1
else
mountVolume=$1
mountPath=$2
fi
if docker volume list -q | fromdos | grep -q ^"${mountVolume}"$
then
echo Warning: Volume exists: ${mountVolume}, skipped.
exit 1
fi
me=$(whoami)
myIP=$(hostname -I | cut -d ' ' -f1)
docker.ssh.cmd mkdir -p "${mountVolume}"
docker.ssh.cmd /usr/bin/sshfs \
-o reconnect \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o UserKnownHostsFile=/dev/null \
-o allow_other \
-o StrictHostKeyChecking=no \
-o auto_unmount \
-o uid=0 \
-o gid=0 \
-o idmap=user \
"${me}"@${myIP}:"${mountPath}" "${mountVolume}"
dummy=$(docker volume create --name "${mountVolume}" -o type=none -o device="/home/docker/${mountVolume}" -o o=bind --label sshfs=yes --label host="${me}"@${myIP} --label path="${mountPath}" --label script_origin="${script_origin}")