Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to tomcat9 #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Freeciv-Web consists of these components:
This application is a Java web application which make up the application
viewed in each user's web browser. The Metaserver is also a part of this module.
Implemented in Javascript, Java, JSP, HTML and CSS. Built with maven and runs
on Tomcat 8 and nginx.
on Tomcat 9 and nginx.

* [Freeciv](freeciv) - the Freeciv C server, which is checked out from the official
Git repository, and patched to work with a WebSocket/JSON protocol. Implemented in C.
Expand Down Expand Up @@ -123,7 +123,7 @@ and 3 Gb of harddisk space.

Install this software if you are not running Freeciv-web with Vagrant:

- Tomcat 8 - https://tomcat.apache.org/
- Tomcat 9 - https://tomcat.apache.org/

- Java 8 JDK - http://www.oracle.com/technetwork/java/javase/downloads/

Expand Down
4 changes: 2 additions & 2 deletions config/pbem.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mysql_user = #DB_USER#
mysql_database = #DB_NAME#
mysql_password = #DB_PASSWORD#

savegame_directory = /var/lib/tomcat8/webapps/data/savegames/pbem/
ranklog_directory = /var/lib/tomcat8/webapps/data/ranklogs/
savegame_directory = /var/lib/tomcat9/webapps/data/savegames/pbem/
ranklog_directory = /var/lib/tomcat9/webapps/data/ranklogs/

host = #FCW_HOST#
2 changes: 1 addition & 1 deletion config/web.properties.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LOCATION:freeciv-web/src/main/webapp/WEB-INF/config.properties
captcha_secret=#CAPTCHA_SECRET#
captcha_public=#CAPTCHA_PUBLIC#
savegame_dir=/var/lib/tomcat8/webapps/data/savegames/
savegame_dir=/var/lib/tomcat9/webapps/data/savegames/
email_username=#SMTP_LOGIN#
email_password=#SMTP_PASSWORD#
email_host=#SMTP_HOST#
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
container_name: fcw.org
command: ["sleep", "infinity"]
volumes:
- "data:/var/lib/tomcat8/webapps/data"
- "data:/var/lib/tomcat9/webapps/data"
ports:
- "80:80"
- "4002"
Expand Down
6 changes: 3 additions & 3 deletions docs/README-AWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ sudo mkdir -p /freeciv-data
sudo mount /dev/xvdf /freeciv-data

if [ -d /freeciv-data/data ]; then
sudo mkdir -p /var/lib/tomcat8/webapps
sudo ln -s /freeciv-data/data /var/lib/tomcat8/webapps/
sudo mkdir -p /var/lib/tomcat9/webapps
sudo ln -s /freeciv-data/data /var/lib/tomcat9/webapps/
fi

# Fetch and build FreeCiv Web
Expand Down Expand Up @@ -142,7 +142,7 @@ cd freeciv-web
## Important Locations

* Longterm games are configured in `~/freeciv-web/publite2/pubscript_longturn_*.serv`
* Saved games, scorelogs, ranklogs are in `/var/lib/tomcat8/webapps/data`
* Saved games, scorelogs, ranklogs are in `/var/lib/tomcat9/webapps/data`
* Logfiles for proxies and games are in `~/freeciv-web/logs/`

## Stooopid Google
Expand Down
4 changes: 2 additions & 2 deletions freeciv-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Scripts to generate these files are in `$freeciv-web/scripts` and they
are generated to `$freeciv-web/freeciv-web/src/derived`. See the
README.md in those directories for more info.

Tomcat 8 + nginx setup
Tomcat 9 + nginx setup
================================
Freeciv-web supports the Tomcat 8 application server for hosting the Java web application.
Freeciv-web supports the Tomcat 9 application server for hosting the Java web application.

The build scripts are updated to build Freeciv-web for Tomcat by default,
so setting up Freeciv-web with Vagrant will configure this automatically.
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/build-js.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# builds javascript files Freeciv-web and copies the resulting file to tomcat.

FCW_DEST=/var/lib/tomcat8/webapps/freeciv-web
FCW_DEST=/var/lib/tomcat9/webapps/freeciv-web

mvn compile && \
echo "Copying target/javascript/webclient.* to ${FCW_DEST}/javascript" && \
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ done

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"

TOMCATDIR="/var/lib/tomcat8"
TOMCATDIR="/var/lib/tomcat9"
WEBAPP_DIR="${DIR}/target/freeciv-web"

# Creating build.txt info file
Expand Down
4 changes: 2 additions & 2 deletions freeciv-web/clean-rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ printf "\nOverwriting auto-generated manual with release-version: MP2-Dragoon"
cp ~/freeciv-web/freeciv-web/src/derived/webapp/man/mp2-dragoon7.bak.html ~/freeciv-web/freeciv-web/src/derived/webapp/man/mp2-dragoon7.html

printf "\nDirectly copying rules to Tomcat webapp\n"
cp ~/freeciv-web/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat8/webapps/freeciv-web/man/
cp ~/freeciv-web/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat9/webapps/freeciv-web/man/

printf "\n*** REMINDER: run ./build.sh to refresh and activate new manual.\n"
printf "\n*** REMINDER: run ./build.sh to refresh and activate new manual.\n"
6 changes: 3 additions & 3 deletions freeciv-web/scenario-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# scenario_name.sav files are located in:
#########################################
# /home/freeciv/freeciv-web/freeciv/freeciv/data/scenarios
# /var/lib/tomcat8/webapps/data/savegames
# /var/lib/tomcat9/webapps/data/savegames

# scenario_name.sav.gz files are located in:
############################################
Expand All @@ -28,8 +28,8 @@ printf "\nUpdating scenarios...\n"
printf "***********************\n"
for r in ${SCENARIOS[@]}; do
echo "$r"
echo " copying to /var/lib/tomcat8/webapps/data/savegames"
cp /home/freeciv/freeciv-web/freeciv/freeciv/data/scenarios/$r /var/lib/tomcat8/webapps/data/savegames
echo " copying to /var/lib/tomcat9/webapps/data/savegames"
cp /home/freeciv/freeciv-web/freeciv/freeciv/data/scenarios/$r /var/lib/tomcat9/webapps/data/savegames
echo " copying to /home/freeciv/freeciv-web/freeciv/build/data/scenarios"
cp /home/freeciv/freeciv-web/freeciv/freeciv/data/scenarios/$r /home/freeciv/freeciv-web/freeciv/build/data/scenarios
printf "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class HallOfFamePost extends HttpServlet {

private Pattern p = Pattern.compile(PATTERN_VALIDATE_ALPHA_NUMERIC);

private static final String mapSrcImgPaths = "/var/lib/tomcat8/webapps/data/savegames/";
private static final String mapSrcImgPaths = "/var/lib/tomcat9/webapps/data/savegames/";

private static final String mapDstImgPaths = "/var/lib/tomcat8/webapps/data/mapimgs/";
private static final String mapDstImgPaths = "/var/lib/tomcat9/webapps/data/mapimgs/";

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/vbuild-all-rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ printf "\nRe-generating manuals\n"

# Vagrant install needs to copy these files into the tomcat webapp
printf "\nCopying to Tomcat webapp\n"
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat8/webapps/freeciv-web/man/
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat9/webapps/freeciv-web/man/

printf "\n\n****** REMINDER: ************************************************************\n"
printf "(1) ./vclean-rules.sh is required to fix custom .html files that were overwritten.\n"
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/vbuild-rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ printf "\nRe-generating manuals\n"
done

# Vagrant install needs to copy these files into the tomcat webapp
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat8/webapps/freeciv-web/man/
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat9/webapps/freeciv-web/man/

printf "\n\n****** REMINDER: ************************************************************\n"
printf "(1) ./vclean-rules.sh is required to fix custom .html files that were overwritten.\n"
Expand Down
4 changes: 2 additions & 2 deletions freeciv-web/vclean-rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ printf "\nOverwriting auto-generated manual with release-version: MP2-Dragoon"
cp /vagrant/freeciv-web/src/derived/webapp/man/mp2-dragoon7.bak.html /vagrant/freeciv-web/src/derived/webapp/man/mp2-dragoon7.html

printf "\nDirectly copying rules to Tomcat webapp\n"
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat8/webapps/freeciv-web/man/
cp /vagrant/freeciv-web/src/derived/webapp/man/*.* /var/lib/tomcat9/webapps/freeciv-web/man/

printf "\n*** REMINDER: run ./build.sh to refresh and activate new manual.\n"
printf "\n*** REMINDER: run ./build.sh to refresh and activate new manual.\n"
6 changes: 3 additions & 3 deletions freeciv-web/vscenario-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# scenario_name.sav files are located in:
#########################################
# /vagrant/freeciv/freeciv/data/scenarios
# /var/lib/tomcat8/webapps/data/savegames
# /var/lib/tomcat9/webapps/data/savegames

# scenario_name.sav.gz files are located in:
############################################
Expand All @@ -28,8 +28,8 @@ printf "\nUpdating scenarios...\n"
printf "***********************\n"
for r in ${SCENARIOS[@]}; do
echo "$r"
echo " copying to /var/lib/tomcat8/webapps/data/savegames"
cp /vagrant/freeciv/freeciv/data/scenarios/$r /var/lib/tomcat8/webapps/data/savegames
echo " copying to /var/lib/tomcat9/webapps/data/savegames"
cp /vagrant/freeciv/freeciv/data/scenarios/$r /var/lib/tomcat9/webapps/data/savegames
echo " copying to /vagrant/freeciv/build/data/scenarios"
cp /vagrant/freeciv/freeciv/data/scenarios/$r /vagrant/freeciv/build/data/scenarios
printf "\n"
Expand Down
2 changes: 1 addition & 1 deletion freeciv/freeciv/server/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ void log_civ_score_init(void)
}

fc_snprintf(game.server.scorefile, 100,
"/var/lib/tomcat8/webapps/data/scorelogs/score-%d.log",
"/var/lib/tomcat9/webapps/data/scorelogs/score-%d.log",
srvarg.port);

score_log = fc_calloc(1, sizeof(*score_log));
Expand Down
2 changes: 1 addition & 1 deletion freeciv/patches/scorelog_filenames.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ diff -Nurd freeciv/server/report.c freeciv/server/report.c
}

+ fc_snprintf(game.server.scorefile, 100,
+ "/var/lib/tomcat8/webapps/data/scorelogs/score-%d.log",
+ "/var/lib/tomcat9/webapps/data/scorelogs/score-%d.log",
+ srvarg.port);
+
score_log = fc_calloc(1, sizeof(*score_log));
Expand Down
4 changes: 2 additions & 2 deletions publite2/init-freeciv-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi
addArgs --log "../logs/freeciv-web-log-${2}.log"

if [ "$5" = "pbem" ]; then
addArgs --Ranklog "/var/lib/tomcat8/webapps/data/ranklogs/rank_${2}.log"
addArgs --Ranklog "/var/lib/tomcat9/webapps/data/ranklogs/rank_${2}.log"
fi

savesdir=${1}
Expand All @@ -57,7 +57,7 @@ fi
addArgs --saves "${savesdir}"

export FREECIV_SAVE_PATH=${savesdir};
rm -f "/var/lib/tomcat8/webapps/data/scorelogs/score-${2}.log"
rm -f "/var/lib/tomcat9/webapps/data/scorelogs/score-${2}.log"

# Start Freeciv-proxy in background
../freeciv-proxy/start-freeciv-proxy.sh "${3}" >> "../logs/freeciv-proxy-loop.log" 2>&1 &
Expand Down
2 changes: 1 addition & 1 deletion publite2/publite2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self):
self.server_limit = int(settings.get("Resource usage", "server_limit",
fallback = 250))
self.savesdir = settings.get("Config", "save_directory",
fallback = "/var/lib/tomcat8/webapps/data/savegames/")
fallback = "/var/lib/tomcat9/webapps/data/savegames/")

self.check_count = 0;
self.total = 0;
Expand Down
2 changes: 1 addition & 1 deletion publite2/settings.ini.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Config]
#Freeciv savegames are stored in this directory
save_directory = /var/lib/tomcat8/webapps/data/savegames/
save_directory = /var/lib/tomcat9/webapps/data/savegames/

[Resource usage]
server_capacity_single = 2
Expand Down
6 changes: 3 additions & 3 deletions scripts/install/deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ if ! apt-cache -qq show openjdk-11-jdk-headless > /dev/null; then
sudo ${APT_GET} update
fi

if [ "$DEB_NO_TOMCAT" != "Y" ] && apt-cache -qq show tomcat8 > /dev/null; then
dependencies="${dependencies} tomcat8 tomcat8-admin"
if [ "$DEB_NO_TOMCAT" != "Y" ] && apt-cache -qq show tomcat9 > /dev/null; then
dependencies="${dependencies} tomcat9 tomcat9-admin"
INSTALLED_TOMCAT=Y
else
INSTALLED_TOMCAT=N
Expand Down Expand Up @@ -104,7 +104,7 @@ for n in java javac; do
done

if [ "${INSTALLED_TOMCAT}" = N ]; then
ext_install_tomcat8
ext_install_tomcat9
fi

TMPINSTDIR=$(mktemp -d)
Expand Down
6 changes: 3 additions & 3 deletions scripts/install/dependency-services-default-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


export JAVA_OPTS="-Djava.security.egd=file:/dev/urandom"
export CATALINA_HOME=/var/lib/tomcat8
export CATALINA_HOME=/var/lib/tomcat9

# 0. mysql
pidof mysqld > /dev/null || sudo service mariadb start ||
Expand All @@ -29,8 +29,8 @@ fi

# 2. Tomcat
echo "Starting up Tomcat" && \
if service --status-all | grep -Fq 'tomcat8'; then
sudo /usr/sbin/service tomcat8 start || echo "unable to start tomcat8 service"
if service --status-all | grep -Fq 'tomcat9'; then
sudo /usr/sbin/service tomcat9 start || echo "unable to start tomcat9 service"
else
# It's a suid script, so will run as tomcat user
sudo $CATALINA_HOME/bin/catalina.sh start
Expand Down
6 changes: 3 additions & 3 deletions scripts/install/dependency-services-default-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ fi

# 2. Tomcat
if [ "${TOMCATMANAGER}" != "Y" ]; then
if service --status-all | grep -Fq 'tomcat8'; then
sudo service tomcat8 stop || echo "unable to stop tomcat8 service"
if service --status-all | grep -Fq 'tomcat9'; then
sudo service tomcat9 stop || echo "unable to stop tomcat9 service"
else
sudo -u tomcat8 /var/lib/tomcat8/bin/catalina.sh stop
sudo -u tomcat /var/lib/tomcat9/bin/catalina.sh stop
fi
fi
2 changes: 1 addition & 1 deletion scripts/install/dependency-services-systemd-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
fi

${ACCESS_MANAGER} systemctl reload nginx.service || ${ACCESS_MANAGER} systemctl start nginx.service
for unit in mysql tomcat8; do
for unit in mysql tomcat9; do
systemctl is-active --quiet ${unit}.service || ${ACCESS_MANAGER} systemctl start ${unit}.service
done

2 changes: 1 addition & 1 deletion scripts/install/dependency-services-systemd-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ fi

systemctl is-active --quiet nginx.service && ${ACCESS_MANAGER} systemctl reload nginx.service
if [ "${TOMCATMANAGER}" != "Y" ]; then
systemctl is-active --quiet tomcat8.service && ${ACCESS_MANAGER} systemctl stop tomcat8.service
systemctl is-active --quiet tomcat9.service && ${ACCESS_MANAGER} systemctl stop tomcat9.service
fi
40 changes: 19 additions & 21 deletions scripts/install/ext-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,42 @@

declare -a ext_installed

ext_install_tomcat8 () {
ext_install_tomcat9 () {
local TOMCAT_URL
local TMPFILE

echo "==== Installing tomcat8 ===="
echo "==== Installing tomcat9 ===="

TOMCAT_URL=$(curl -LsS 'https://tomcat.apache.org/download-80.cgi' | sed -n 's/^.*href="\([^"]*bin\/apache-tomcat-[0-9.]*tar\.gz\)".*/\1/p' | head -n 1)
TOMCAT_URL=$(curl -LsS 'https://tomcat.apache.org/download-90.cgi' | sed -n 's/^.*href="\([^"]*bin\/apache-tomcat-[0-9.]*tar\.gz\)".*/\1/p' | head -n 1)
if [ -z "${TOMCAT_URL}" ]; then
echo >&2 "Couldn't fetch download URL"
exit 1
fi

echo "Downloading tomcat8 from ${TOMCAT_URL}"
TMPFILE=$(mktemp -t tomcat8.XXXX.tar.gz)
echo "Downloading tomcat9 from ${TOMCAT_URL}"
TMPFILE=$(mktemp -t tomcat9.XXXX.tar.gz)
curl -LsS -o "${TMPFILE}" "${TOMCAT_URL}"

cd /var/lib
sudo tar -xzf "${TMPFILE}"
sudo mv apache-tomcat-8.* tomcat8
sudo mv apache-tomcat-9.* tomcat9
rm "${TMPFILE}"

if ! getent group tomcat8 > /dev/null 2>&1 ; then
sudo groupadd --system tomcat8
if ! getent group tomcat > /dev/null 2>&1 ; then
sudo groupadd --system tomcat
fi
if ! id tomcat8 > /dev/null 2>&1 ; then
sudo useradd --system --home /var/lib/tomcat8 -g tomcat8 --shell /bin/false tomcat8
if ! id tomcat > /dev/null 2>&1 ; then
sudo useradd --system --home /var/lib/tomcat9 -g tomcat --shell /bin/false tomcat
fi

sudo chgrp -R tomcat8 /var/lib/tomcat8
sudo chmod -R g+r /var/lib/tomcat8/conf
sudo chmod g+x /var/lib/tomcat8/conf
sudo chown -R tomcat8 /var/lib/tomcat8/{webapps,work,temp,logs}
sudo chown tomcat8 /var/lib/tomcat8/bin/catalina.sh
sudo chmod u+s /var/lib/tomcat8/bin/catalina.sh
sudo setfacl -m d:g:tomcat8:rwX /var/lib/tomcat8/webapps
sudo chgrp -R tomcat /var/lib/tomcat9
sudo chmod -R g+r /var/lib/tomcat9/conf
sudo chmod g+x /var/lib/tomcat9/conf
sudo chown -R tomcat /var/lib/tomcat9/{webapps,work,temp,logs}
sudo chown tomcat /var/lib/tomcat9/bin/catalina.sh
sudo chmod u+s /var/lib/tomcat9/bin/catalina.sh
sudo setfacl -m d:g:tomcat:rwX /var/lib/tomcat9/webapps

echo "export CATALINA_HOME=\"/var/lib/tomcat8\"" >> ~/.bashrc
ext_installed[${#ext_installed[@]}]="tomcat8"
echo "export CATALINA_HOME=\"/var/lib/tomcat9\"" >> ~/.bashrc
ext_installed[${#ext_installed[@]}]="tomcat9"
}


4 changes: 2 additions & 2 deletions scripts/install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ FCW_INSTALL_REL=
SHOW_LIST=0
basedir=

TOMCAT_HOME=/var/lib/tomcat8
TOMCAT_HOME=/var/lib/tomcat9

show_help () {
cat << EOF
Expand Down Expand Up @@ -274,7 +274,7 @@ echo "==== Preparing Tomcat ===="
cd "${TOMCAT_HOME}"
sudo setfacl -m d:u:$(id -u):rwX,u:$(id -u):rwx webapps
mkdir -p webapps/data/{savegames/pbem,scorelogs,ranklogs}
setfacl -Rm d:u:tomcat8:rwX webapps/data
setfacl -Rm d:u:tomcat:rwX webapps/data

echo "==== Building freeciv ===="
echo "Please be patient"
Expand Down
Loading