-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-tomcat.sh
executable file
·64 lines (51 loc) · 2.06 KB
/
new-tomcat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Source the configuration file
source config.sh
# Check if the specified version of Tomcat already exists
if [ -d "$TOMCAT_DIR" ]; then
echo "Tomcat directory $TOMCAT_DIR already exists. Removing it..."
rm -rf "$TOMCAT_DIR"
fi
# Check if unzip is installed
if ! command -v unzip &> /dev/null; then
echo "unzip not found, installing..."
sudo apt-get install unzip -y
fi
echo "Downloading Tomcat from $TOMCAT_URL..."
wget $TOMCAT_URL -O tomcat.zip
echo "Extracting Tomcat..."
unzip tomcat.zip -d $(dirname $TOMCAT_DIR)
rm tomcat.zip # Remove the zip file after extraction
# Create setenv.sh in Tomcat bin directory
echo "Creating setenv.sh..."
cat << EOF > $TOMCAT_DIR/bin/setenv.sh
#!/bin/bash
export JAVA_OPTS="-server -Xmx4g -XX:MaxMetaspaceSize=1g -Djava.awt.headless=true -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -Djava.util.Arrays.useLegacyMergeSort=true"
JAVA_OPTS="\$JAVA_OPTS -Dhttp.agent=Sakai"
JAVA_OPTS="\$JAVA_OPTS -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false"
JAVA_OPTS="\$JAVA_OPTS -Dsakai.security=$SAKAI_HOME"
JAVA_OPTS="\$JAVA_OPTS -Dsakai.home=$SAKAI_HOME"
JAVA_OPTS="\$JAVA_OPTS -Dsakai.cookieName=SAKAI2SESSIONID"
JAVA_OPTS="\$JAVA_OPTS -Dsakai.demo=true"
JAVA_OPTS="\$JAVA_OPTS -Duser.timezone=US/Eastern"
JAVA_OPTS="\$JAVA_OPTS -Duser.language=en -Duser.region=ES"
EOF
# Make setenv.sh executable
chmod +x $TOMCAT_DIR/bin/setenv.sh
# Clearing the webapps directory
echo "Clearing webapps directory..."
rm -rf $TOMCAT_DIR/webapps/*
# Adding JarScanFilter to context.xml using awk
echo "Modifying context.xml with JarScanner block..."
awk '/<\/Context>/ {
print " <JarScanner>"
print " <!-- This is to speed up startup so that Tomcat doesn'\''t scan as much -->"
print " <JarScanFilter defaultPluggabilityScan=\"false\" />"
print " </JarScanner>"
}
{
print
}' $TOMCAT_DIR/conf/context.xml > temp_file && mv temp_file $TOMCAT_DIR/conf/context.xml
# Make tomcat/bin/*.sh executable
chmod +x $TOMCAT_DIR/bin/*.sh
echo "Tomcat setup for Sakai complete."