-
Notifications
You must be signed in to change notification settings - Fork 1
/
tomcat80.sh
88 lines (78 loc) · 2.57 KB
/
tomcat80.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
85
86
87
88
#!/bin/bash
# http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos
if [ -d "/usr/share/tomcat" ]
then
echo "Tomcat is already installed, nothing done!"
else
SETUP="/vagrant/vagrant-setup"
source $SETUP/include.sh
if [ -d "$JAVA_HOME" ]
then
if getent passwd tomcat > /dev/null 2>&1; then
echo "tomcat user already exists"
else
# Create a user for running Tomcat
groupadd tomcat
useradd -d /usr/share/tomcat/ -K MAIL_DIR=/dev/null -g tomcat tomcat
echo -e "catpassw8\ncatpassw8\n" | passwd tomcat
fi
cp $SETUP/tomcat/init.d/tomcat /etc/init.d/tomcat
chmod 755 /etc/init.d/tomcat
# Disallow Tomcat user to login via SSH but allow SFTP
# http://en.wikibooks.org/wiki/OpenSSH/Cookbook/SFTP
if grep -q -e "^Subsystem\s*sftp" /etc/ssh/sshd_config
then
perl -pi -e 's/Subsystem/#Subsystem/g' /etc/ssh/sshd_config
fi
cat ./tomcat/etc/ssh/sshd_config >> /etc/ssh/sshd_config
service sshd restart
cd /usr/share
TOMCAT_FILE="apache-tomcat-8.0.9"
wget_and_untar http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.9/bin/ $TOMCAT_FILE.tar.gz tomcat.tar.gz
if [ ! -d "/usr/share/tomcat" ]
then
mkdir tomcat
fi
cd $TOMCAT_FILE
mv * ../tomcat
cd ..
rmdir $TOMCAT_FILE
cd tomcat
chmod 766 logs
mkdir shared
cd shared
mkdir classes
mkdir lib
cd ../webapps
rm -r -f examples
cd ../bin
# Compile APR native libraries
tar -xzf tomcat-native.tar.gz
rm tomcat-native.tar.gz
cd tomcat-native-1.1.30-src/jni/native
./configure --with-apr=/usr --with-java-home=$JAVA_HOME && make && make install
cd ../../../..
# Copy conf files
cp --remove-destination /vagrant/vagrant-setup/tomcat/conf/tomcat-users.xml ./conf
cp --remove-destination /vagrant/vagrant-setup/tomcat/conf/catalina.properties ./conf
cp --remove-destination /vagrant/vagrant-setup/tomcat/conf/log4j2.xml ./conf
chown -Rf tomcat.tomcat .
# Use dcevm for dynamic class reloading on development if available
if [ -d "$SETUP/tomcat/dcevm" ]
then
mkdir -p $JAVA_HOME/jre/lib/amd64/dcevm
cp $SETUP/tomcat/dcevm/*.* $JAVA_HOME/jre/lib/amd64/dcevm
cp $SETUP/tomcat/hotswap/hotswap-agent-1.1.0.jar /usr/share/tomcat/lib
fi
# Start Tomcat at boot time
chkconfig --add tomcat
chkconfig --level 234 tomcat on
# Start Tomcat and check that everything was fine
service tomcat start
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
service iptables save
systemctl restart iptables.service
else
echo "Tomcat 8.0 requires Java 8.0. Please install it with java80.sh"
fi
fi