forked from Abhilash-HJ/tomcat-installation-redhat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-tomcat-redhat.sh
53 lines (48 loc) · 2.29 KB
/
install-tomcat-redhat.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
#!/bin/bash
echo -e "\n################################################################"
echo -e "# #"
echo -e "# ***Artisan Tek*** #"
echo -e "# Tomcat Installation #"
echo -e "# #"
echo -e "################################################################"
# Installing necessary packages
echo -e "\n\n*****Installing Necessary Packages"
sudo yum update -y 1>/dev/null
sudo yum install -y java-11-openjdk wget 1>/dev/null
echo " -> Done"
# Downloading Apache Tomcat 9.0.68 version to OPT folder
echo "*****Downloading Apache Tomcat 9.0.68 version"
cd /opt
sudo systemctl stop tomcat 2>/dev/null
sudo rm -rf apache* tomcat*
sudo mkdir -p /opt/tomcat
sudo wget -q https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.68/bin/apache-tomcat-9.0.68.tar.gz 1>/dev/null
sudo tar xf apache-tomcat-9.0.68.tar.gz -C /opt/tomcat 1>/dev/null
sudo rm -rf apache-tomcat-9.0.68.tar.gz
echo " -> Done"
# Configuring Tomcat server for manager, host-manager and Credential
echo "*****Configuring Tomcat server for manager, host-manager and Credentials"
cd - 1>/dev/null
sudo cp context.xml /opt/tomcat/apache-tomcat-9.0.68/webapps/manager/META-INF/context.xml
sudo cp context.xml /opt/tomcat/apache-tomcat-9.0.68/webapps/host-manager/META-INF/context.xml
sudo cp tomcat-users.xml /opt/tomcat/apache-tomcat-9.0.68/conf/tomcat-users.xml
echo " -> Done"
# Configuring Tomcat as a Service
echo "*****Configuring Tomcat as a Service"
sudo useradd -r -M -U -d /opt/tomcat -s /bin/false tomcat 2>/dev/null
sudo chown -R tomcat: /opt/tomcat/*
sudo cp tomcat.service /etc/systemd/system/tomcat.service
sudo rm -rf tomcat-redhat
sudo systemctl daemon-reload 1>/dev/null
sudo systemctl start tomcat 1>/dev/null
echo " -> Done"
# Check if tomcat is working
sudo systemctl is-active --quiet tomcat
echo -e "\n################################################################ \n"
if [ $? -eq 0 ]; then
echo "Tomcat installed Successfully"
echo "Access Tomcat using $(curl -s ifconfig.me):8080"
else
echo "Tomcat installation failed"
fi
echo -e "\n################################################################ \n"