From f754b669b3a31c9bbb6fda89843eec19662ca608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20B=C3=BChner?= Date: Wed, 6 Oct 2021 15:51:03 +0300 Subject: [PATCH] fix: avoid multiple adding of cors filter --- startup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/startup.sh b/startup.sh index c34bcab..83b916c 100755 --- a/startup.sh +++ b/startup.sh @@ -20,10 +20,12 @@ fi # configure 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 sed -i "\::i\\ \n\ - CorsFilter\n\ + DockerGeoServerCorsFilter\n\ org.apache.catalina.filters.CorsFilter\n\ \n\ cors.allowed.origins\n\ @@ -39,9 +41,10 @@ if [ "${CORS_ENABLED}" = "true" ]; then \n\ \n\ \n\ - CorsFilter\n\ + DockerGeoServerCorsFilter\n\ /*\n\ " "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"; + fi fi # start the tomcat