-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-generate.sh
executable file
·55 lines (34 loc) · 1.02 KB
/
docker-generate.sh
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
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
#
#
set -e
IMAGE_NAME='chop-chop'
setup_path="$1" ; shift
settings_path="$1" ; shift
output_path="$1" ; shift
mkdir "${output_path}"
tmpdir="$(mktemp -d --suffix='.d' "${0##*/}.XXXXXX")"
trap "rm -rf '${tmpdir}'" 'EXIT'
cp "${setup_path}" "${tmpdir}/setup.txt"
cp "${settings_path}" "${tmpdir}/settings.sh"
cat > "${tmpdir}/generate.sh" <<EOF
#!/bin/bash
./tools/control-generate './mnt/setup.txt' './mnt/settings.sh' \\
'./mnt/passepartout.db' \\
'./mnt/membership.db' \\
'./mnt/directory.db' \\
'./mnt/flows'
EOF
chmod 755 "${tmpdir}/generate.sh"
sudo docker run \
-it \
--rm \
--mount type=bind,source="${PWD}/${tmpdir}",target='/home/ubuntu/mnt' \
--mount type=bind,source="${PWD}/script",target='/home/ubuntu/tools' \
--entrypoint='/home/ubuntu/mnt/generate.sh' \
"${IMAGE_NAME}"
mv "${tmpdir}/passepartout.db" "${output_path}"
mv "${tmpdir}/membership.db" "${output_path}"
mv "${tmpdir}/directory.db" "${output_path}"
mv "${tmpdir}/flows" "${output_path}"