Skip to content

Commit 055a54a

Browse files
timschumiVladimir Kotal
authored andcommitted
docker: Support sub-subdirectories as WEBAPP_CONTEXT
1 parent f81299c commit 055a54a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docker/start.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ if [ -z "$REINDEX" ]; then
55
REINDEX=10
66
fi
77

8-
if [[ -z "${OPENGROK_WEBAPP_CONTEXT}" || "${OPENGROK_WEBAPP_CONTEXT}" = *" "* ]]; then
9-
date +"%F %T Deployment path is empty or contains spaces. Deploying to root..."
8+
if [[ "${OPENGROK_WEBAPP_CONTEXT}" = *" "* ]]; then
9+
date +"%F %T Deployment path contains spaces. Deploying to root..."
1010
export OPENGROK_WEBAPP_CONTEXT="/"
1111
fi
1212

13-
if [ "${OPENGROK_WEBAPP_CONTEXT}" = "/" ]; then
13+
# Remove leading and trailing slashes
14+
OPENGROK_WEBAPP_CONTEXT="${OPENGROK_WEBAPP_CONTEXT#/}"
15+
OPENGROK_WEBAPP_CONTEXT="${OPENGROK_WEBAPP_CONTEXT%/}"
16+
17+
if [ "${OPENGROK_WEBAPP_CONTEXT}" = "" ]; then
1418
WAR_NAME="ROOT.war"
1519
else
16-
WAR_NAME="${OPENGROK_WEBAPP_CONTEXT#/}.war"
20+
WAR_NAME="${OPENGROK_WEBAPP_CONTEXT//\//#}.war"
1721
fi
1822

1923
if [ ! -f "/usr/local/tomcat/webapps/${WAR_NAME}" ]; then
@@ -26,7 +30,7 @@ if [ ! -f "/usr/local/tomcat/webapps/${WAR_NAME}" ]; then
2630

2731
# Set up redirect from /source
2832
mkdir "/usr/local/tomcat/webapps/source"
29-
echo "<% response.sendRedirect(\"${OPENGROK_WEBAPP_CONTEXT}\"); %>" > "/usr/local/tomcat/webapps/source/index.jsp"
33+
echo "<% response.sendRedirect(\"/${OPENGROK_WEBAPP_CONTEXT}\"); %>" > "/usr/local/tomcat/webapps/source/index.jsp"
3034
fi
3135

3236
indexer(){

0 commit comments

Comments
 (0)