-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
34 lines (29 loc) · 1.36 KB
/
entrypoint.sh
File metadata and controls
34 lines (29 loc) · 1.36 KB
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
#!/bin/sh
# replace config default values with those provided via environment variables
for env in `printenv`
do
if [ "$env" != "${env#DIGILIB_}" ]
then
# split the env variable at the "=" character and
# save the tokes in $f1 and $f2
IFS='=' read -r f1 f2 <<EOF
$env
EOF
# turn the key into lower-case and replace underscore with hyphen
KEY=$(echo ${f1} | cut -c9- | tr '[:upper:]' '[:lower:]' | tr '_' '-')
VALUE=${f2}
# replace existing default values in digilib-config.xml
sed -i -e "/name=\"$KEY\"/ s#value=\"[^\"]*\"#value=\"$VALUE\"#" ${JETTY_WEBAPPS}/ROOT/WEB-INF/digilib-config.xml
# add new entries to digilib-config.xml
if ! grep $KEY -q ${JETTY_WEBAPPS}/ROOT/WEB-INF/digilib-config.xml
then
sed -i -e "/<\/digilib-config>/i \ \ <parameter name=\"$KEY\" value=\"$VALUE\"/>" ${JETTY_WEBAPPS}/ROOT/WEB-INF/digilib-config.xml
fi
fi
done
# Jetty has introduced a URI Compliance configuration (since 10.0.3+) which, for example,
# forbids having encoded ! characters (encoded as %2F) in URL paths.
# However Digilib uses these and thus we need to set Jetty into LEGACY mode.
echo "jetty.httpConfig.uriCompliance=LEGACY" >> ${JETTY_BASE}/start.d/server.ini
# run the command given in the Dockerfile at CMD
exec /docker-entrypoint.sh "${@}"