forked from AKSW/ontodia-graph-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-start.sh
executable file
·150 lines (132 loc) · 3.31 KB
/
docker-start.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
set -eu
t=/usr/local/apache2/tpl
d=/usr/local/apache2/htdocs
make_instance() {
local path="$1"
local endpoint="$2"
local lucene="$3"
local creds="$4"
local g="$5"
local i
local fetch_credentials
local title_prefix
path="${path#/}"
if [ "$g" -gt 0 ] && [ "$lucene" = redirect ]; then
if [ -z "$path" ]; then
path=index
fi
echo "<html>
<meta http-equiv='refresh' content='0; url=$endpoint' />
</html>" > "$d/$path.html"
if [ "$path" = index ]; then
path=
fi
echo "
Entry $g:
PATH = /$path
Redirect to : $endpoint
"
return 1
fi
if [ "$lucene" = yes ]; then
i=fuseki-lucene
elif [ "$lucene" = no ]; then
i=fuseki-regexsearch
else
if [ "$g" -eq 0 ]; then
echo "LUCENE_SEARCH is set to \`${lucene}' but must be yes or no"
else
echo "Entry $g (/$path): third option (lucene) is set to \`${lucene}' but must be yes or no"
fi
exit 1
fi
if [ "$creds" = yes ]; then
fetch_credentials=include
elif [ "$creds" = no ]; then
fetch_credentials=same-origin
else
if [ "$g" -eq 0 ]; then
echo "USE_CREDS is set to \`${creds}' but must be yes or no"
else
echo "Entry $g (/$path): fourth option (creds) is set to \`${creds}' but must be yes or no"
fi
exit 1
fi
if [ -z "$endpoint" ]; then
if [ "$g" -eq 0 ]; then
echo "ENDPOINT_URL not set"
else
echo "Entry $g (/$path): second option (endpoint) not set"
fi
exit 1
fi
if [ -z "$path" ]; then
path=index
fi
if [ "$path" = index ]; then
title_prefix=""
else
title_prefix="$path - "
fi
env -i \
ENDPOINT_URL="$endpoint" \
WEB_PATH="$path" \
FETCH_CREDENTIALS="$fetch_credentials" \
LUCENE_SEARCH="$lucene" \
TITLE_PREFIX="$title_prefix" \
perl -p -e 's|@([A-Z_]{3,})@|$ENV{$1}//$&|ge' "$t/$i.bundle.js" > "$d/$path.bundle.js"
env -i \
ENDPOINT_URL="$endpoint" \
WEB_PATH="$path" \
FETCH_CREDENTIALS="$fetch_credentials" \
LUCENE_SEARCH="$lucene" \
TITLE_PREFIX="$title_prefix" \
perl -p -e 's|@([A-Z_]{3,})@|$ENV{$1}//$&|ge;s|'"$i"'|'"$path"'|g' "$t/$i.bundle.js.map" > "$d/$path.bundle.js.map"
env -i \
ENDPOINT_URL="$endpoint" \
WEB_PATH="$path" \
FETCH_CREDENTIALS="$fetch_credentials" \
LUCENE_SEARCH="$lucene" \
TITLE_PREFIX="$title_prefix" \
perl -p -e 's|"explorer\.bundle\.js\??[^"]*"|"'"$path.bundle.js"'?'"$(openssl dgst -binary "$d/$path.bundle.js" | basenc --base64url --wrap=0)"'"|;s|@([A-Z_]{3,})@|$ENV{$1}//$&|ge;' \
"$t/index.html" > "$d/$path.html"
if [ "$path" = index ]; then
path=
fi
if [ "$g" -eq 0 ]; then
echo "
"
else
echo "
Entry $g:"
fi
echo "PATH = /$path
ENDPOINT_URL = $endpoint
USE_CREDS = $creds
LUCENE_SEARCH = $lucene
"
}
has_instance=0
if [ "${ENDPOINT_MAP+x}" = x ]; then
g=0
while IFS='|' read path endpoint lucene creds x; do
let g=g+1
valid=0
if [ -n "$path$endpoint$lucene$creds$x" ]; then
make_instance "$path" "$endpoint" "${lucene:-yes}" "${creds:-yes}" "$g" "$x" || valid=$?
if [ "$valid" -eq 0 ]; then
has_instance=1
fi
fi
done <<<"$ENDPOINT_MAP"
fi
if [ "${ENDPOINT_URL+x}" = x ]; then
make_instance "index" "$ENDPOINT_URL" "${LUCENE_SEARCH-yes}" "${USE_CREDS-yes}" "0" ""
has_instance=1
fi
if [ "$has_instance" -eq 0 ]; then
echo "ENDPOINT_URL not set"
exit 1
fi
exec httpd-foreground