-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
68 lines (53 loc) · 1.75 KB
/
entrypoint.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
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
if [ "$1" == "start" ]; then
shift
if [ ! -f "/data/config.json" ]; then
echo "You must map the folder with your config.json to /data"
exit 1
fi
if [ ! -f "/data/survey.tsv" ]; then
echo "You must map the folder with your survey.tsv to /data"
exit 1
fi
# Output folder should contain survey.tsv and config.json
python3 /code/survey.py -o /data --folder /data "$@"
ret=$?
if [ ${ret} -eq 0 ]; then
echo "index.html"
folders=( "js" "css")
# Move static files
for i in "${folders[@]}"
do
echo $i
if [ ! -e "/data/${i}" ]; then
cp -R "/code/${i}" /data
fi
done
if [ -e "/data/LICENSE" ]; then
echo "Found LICENSE in output destination, will not overwrite"
else
cp /code/LICENSE /data
echo "LICENSE"
fi
# Move GitHub workflow if does not exist
mkdir -p /data/.github/workflows
if [ -e "/data/.github/workflows/build-deploy.yaml" ]; then
echo "Found .github/workflows/build-deploy.yaml in output destination, will not overwrite"
else
cp /code/.github/workflows/build-deploy.yaml /data/.github/workflows
fi
if [ -e "/data/README.md" ]; then
echo "Found README.md in output destination, will not overwrite"
else
if [ -e "/code/README.md" ]; then
cp /code/README.md /data
echo "README.md"
fi
fi
chmod -R 0755 /data/*
fi
else
echo "Usage
docker run -v my-survey:/data expfactory/survey-generator start [options]"
python3 /code/survey.py --help
fi