Skip to content

Commit 640db36

Browse files
authored
Merge pull request #2120 from Orviss/tomcat_deploy
Add support for Tomcat webapp context in deploy command
2 parents afe531e + 074511f commit 640db36

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

OpenGrok

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# CDDL HEADER END
1919

2020
#
21-
# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
21+
# Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2222
# Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
#
2424

@@ -133,6 +133,8 @@ Supported Environment Variables for configuring the default setup:
133133
(by default 3 directories from SRC_ROOT)
134134
- OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
135135
(use "none" to avoid sending it to web app)
136+
- OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
137+
(by default /source).
136138
- OPENGROK_WPREFIX Disable wildcard prefix search query support (*)
137139
- OPENGROK_TAG Enable parsing of revision tags into the History
138140
view
@@ -983,8 +985,30 @@ DeployWar()
983985
FatalError "Missing Deployment Directory ${warTarget}"
984986
fi
985987

988+
APP_CONTEXT="source"
989+
FINAL_WAR_NAME="source"
990+
if [ "$applicationServer" = "Tomcat" ]
991+
then
992+
if [ ! -z ${OPENGROK_WEBAPP_CONTEXT+x} ] # OPENGROK_WEBAPP_CONTEXT is set
993+
then
994+
APP_CONTEXT="${OPENGROK_WEBAPP_CONTEXT}"
995+
996+
# strip leading /
997+
case ${APP_CONTEXT} in
998+
/*) APP_CONTEXT=`echo ${APP_CONTEXT} | sed 's|^/||'`
999+
esac
1000+
1001+
FINAL_WAR_NAME=`echo ${APP_CONTEXT} | sed 's|/|#|g'`
1002+
1003+
if [ -z "${FINAL_WAR_NAME}" ]
1004+
then
1005+
FINAL_WAR_NAME="ROOT"
1006+
fi
1007+
fi
1008+
fi
1009+
9861010
Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
987-
${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/"
1011+
${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/${FINAL_WAR_NAME}.war"
9881012
if [ $? != 0 ]
9891013
then
9901014
FatalError "Web Application Installation FAILED"
@@ -1011,7 +1035,7 @@ DeployWar()
10111035
if [ -n "${EXTRACT_COMMAND}" ]
10121036
then
10131037
cd "${warTarget}"
1014-
eval "${EXTRACT_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
1038+
eval "${EXTRACT_COMMAND} ${warTarget}/${FINAL_WAR_NAME}.war WEB-INF/web.xml"
10151039
if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ]
10161040
then
10171041
sed -e 's:/var/opengrok/etc/configuration.xml:'"$XML_CONFIGURATION"':g' \
@@ -1028,7 +1052,7 @@ DeployWar()
10281052
mv "${warTarget}/WEB-INF/web.xml.tmp" \
10291053
"${warTarget}/WEB-INF/web.xml"
10301054
fi
1031-
eval "${COMPRESS_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
1055+
eval "${COMPRESS_COMMAND} ${warTarget}/${FINAL_WAR_NAME}.war WEB-INF/web.xml"
10321056
rm -rf "${warTarget}/WEB-INF"
10331057
fi
10341058
fi
@@ -1039,7 +1063,7 @@ DeployWar()
10391063
Progress "running, or wait until it loads the just installed web " \
10401064
"application."
10411065
Progress
1042-
Progress "OpenGrok should be available on <HOST>:<PORT>/source"
1066+
Progress "OpenGrok should be available on <HOST>:<PORT>/${APP_CONTEXT}"
10431067
Progress " where HOST and PORT are configured in ${applicationServer}."
10441068
Progress
10451069
}

0 commit comments

Comments
 (0)