-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
84 lines (65 loc) · 2.69 KB
/
setup.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#######################################################################
# To call, use the following syntax
# sudo setup.sh "/path/to/config" "/path/to/sparkler.xml" #
#######################################################################
# Read variable definitions from the config file
SPARKLER_XML=$2; # Path to the sparkler.xml file
CONFIG_PATH=$1; # Path to the config file
source $CONFIG_PATH
#######################################################################
# Step 1: Install Tomcat #
#######################################################################
# Install the java jdk
yum install -y java-1.7.0-openjdk-devel
# Create the local user & group to run as (both named tomcat)
groupadd tomcat
useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
# Download/unpack the tomcat files
mkdir /opt/tomcat
wget -O /opt/tomcat.tar.gz $TOMCAT_DOWNLOAD
tar xvf /opt/tomcat.tar.gz -C /opt/tomcat --strip-components=1
# Update permissions
chgrp -R tomcat /opt/tomcat
chown -R tomcat /opt/tomcat/webapps /opt/tomcat/webapps /opt/tomcat/work /opt/tomcat/temp /opt/tomcat/logs
chmod -R g+r /opt/tomcat/conf
chmod g+x /opt/tomcat/conf
# Use the systemd definition to have tomcat run as a service
echo "# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/tomcat.service
# Restart systemd, to pick up on this new unit
systemctl daemon-reload
#######################################################################
# Step 2: Configure Sparkler Web App #
#######################################################################
# Download/unpack the sparkler files
wget -O /tmp/sparkler.zip $SPARKLER_DOWNLOAD
unzip /tmp/sparkler.zip
unzip /tmp/Sparkler-1.04/Sparkler-1.04.zip
# Copy the war file to the tomcat webapps directory
mv /tmp/Sparkler-1.04/sparkler-1.0.4.war /opt/tomcat/webapps/sparkler.war
# Copy the sparkler.xml config file, to the web app directory
mkdir /opt/tomcat/conf/Catalina
mkdir /opt/tomcat/conf/Catalina/localhost
mv $SPARKLER_XML /opt/tomcat/conf/Catalina/localhost/sparkler.xml
# Restart the tomcat service
systemctl restart tomcat.service