Skip to content

Commit

Permalink
Support APP_LOCATION at runtime (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
camuffo authored Dec 12, 2024
1 parent e1d1c35 commit fb6a519
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Each of these variables can be associated to an external volume to persist data
- `CATALINA_OPTS` to customize `CATALINA_OPTS` for the container
- `EXTRA_GEOSERVER_OPTS` to append to `CATALINA_OPTS`
- `JAIEXT_ENABLED` by default is `true`. More info [here](https://docs.geoserver.org/maintain/en/user/configuration/image_processing/index.html#jai-ext).
- `APP_LOCATION` to rename the GeoServer webapp directory to something else than `geoserver`

#### Java heap size tuning env variables:

Expand Down
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ 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
15 changes: 10 additions & 5 deletions geoserver-rest-config.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/usr/bin/env bash
while [ "$(curl -s --retry-connrefused --retry 100 -I http://localhost:8080/geoserver/web/ 2>&1 |grep 200)" == "" ];do
echo "Waiting for GeoServer to be Up and running"
done

if [ -z "${APP_LOCATION}" ]; then
APP_LOCATION="geoserver"
fi

while [ "$(curl -s --retry-connrefused --retry 100 -I http://localhost:8080/"$APP_LOCATION"/web/ 2>&1 |grep 200)" == "" ];do
echo "Waiting for GeoServer to be Up and running"
done
if [ "$ADMIN_PASSWORD" != "" ]; then
echo "GeoServer password is likely to be default, going to change to new admin password."
ADMIN_HEADER=$(echo -n "admin:geoserver" | base64)
curl -H "Authorization: basic $ADMIN_HEADER" -X PUT http://localhost:8080/geoserver/rest/security/self/password -H "accept: application/json" -H "content-type: application/json" -d "{ \"newPassword\": \"$ADMIN_PASSWORD\"}"
fi
curl -H "Authorization: basic $ADMIN_HEADER" -X PUT http://localhost:8080/"$APP_LOCATION"/rest/security/self/password -H "accept: application/json" -H "content-type: application/json" -d "{ \"newPassword\": \"$ADMIN_PASSWORD\"}"
fi
13 changes: 9 additions & 4 deletions geoserver-rest-reload.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/env bash
set -x

if [ -z "${APP_LOCATION}" ]; then
APP_LOCATION="geoserver"
fi

#while [ "$(curl -s --retry-connrefused --retry 100 -I http://localhost:8080/geoserver/web/ 2>&1 |grep 200)" == "" ];do
# echo "Waiting for GeoServer to be Up and running"
#done
#done
if [ "$ADMIN_PASSWORD" != "" ]; then
ADMIN_HEADER=$(echo -n "admin:${ADMIN_PASSWORD}" | base64)
ADMIN_HEADER=$(echo -n "admin:${ADMIN_PASSWORD}" | base64)
else
ADMIN_HEADER=$(echo -n "admin:geoserver"| base64)
fi
fi

curl -H "Authorization: basic ${ADMIN_HEADER}" -X POST http://localhost:8080/geoserver/rest/reload -H "accept: application/json" -H "content-type: application/json"
curl -H "Authorization: basic ${ADMIN_HEADER}" -X POST http://localhost:8080/"$APP_LOCATION"/rest/reload -H "accept: application/json" -H "content-type: application/json"

0 comments on commit fb6a519

Please sign in to comment.