-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathentrypoint.sh
executable file
·59 lines (53 loc) · 2.42 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
#!/usr/bin/env bash
geoserver-plugin-download.sh ${CATALINA_BASE}/webapps/${APP_LOCATION}/WEB-INF/lib $PLUGIN_DYNAMIC_URLS
set -m
export CATALINA_OPTS="$CATALINA_OPTS $EXTRA_GEOSERVER_OPTS"
# Enable CORS (inspired by https://github.com/oscarfonts/docker-geoserver)
# if enabled, this will add the filter definitions
# to the end of the web.xml
# (this will only happen if our filter has not yet been added before)
if [ "${CORS_ENABLED}" = "true" ]; then
if ! grep -q DockerGeoServerCorsFilter "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"; then
echo "Enable CORS for $CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"
# Add support for access-control-allow-credentials when the origin is not a wildcard when specified via env var
if [ "${CORS_ALLOWED_ORIGINS}" != "*" ] && [ "${CORS_ALLOW_CREDENTIALS}" = "true" ]; then
CORS_ALLOW_CREDENTIALS="true"
else
CORS_ALLOW_CREDENTIALS="false"
fi
sed -i "\:</web-app>:i\\
<filter>\n\
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>\n\
<init-param>\n\
<param-name>cors.allowed.origins</param-name>\n\
<param-value>${CORS_ALLOWED_ORIGINS}</param-value>\n\
</init-param>\n\
<init-param>\n\
<param-name>cors.allowed.methods</param-name>\n\
<param-value>${CORS_ALLOWED_METHODS}</param-value>\n\
</init-param>\n\
<init-param>\n\
<param-name>cors.allowed.headers</param-name>\n\
<param-value>${CORS_ALLOWED_HEADERS}</param-value>\n\
</init-param>\n\
<init-param>\n\
<param-name>cors.support.credentials</param-name>\n\
<param-value>${CORS_ALLOW_CREDENTIALS}</param-value>\n\
</init-param>\n\
</filter>\n\
<filter-mapping>\n\
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
<url-pattern>/*</url-pattern>\n\
</filter-mapping>" "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml";
fi
fi
# Disable tomcat version disclosure
sed -i '/<\/Host>/i\ \ \ \ \ \ \ \ <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false"/>' "$CATALINA_HOME/conf/server.xml";
# Custom webapp location
if [ -n "${APP_LOCATION}" ] && [ "${APP_LOCATION}" != "geoserver" ]; then
mv "${CATALINA_BASE}"/webapps/geoserver "${CATALINA_BASE}"/webapps/"${APP_LOCATION}"
fi
catalina.sh run &
/usr/local/bin/geoserver-rest-config.sh
fg %1