forked from kmashwin/tomcat-config-ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-tomcat.sh
27 lines (27 loc) · 1.48 KB
/
install-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
#!/bin/bash
ver=`curl --silent http://mirror.vorboss.net/apache/tomcat/tomcat-9/ | grep v9 | awk '{split($5,c,">v") ; split(c[2],d,"/") ; print d[1]}'`
echo $ver
version=`echo $ver | cut -d " " -f2`
echo $version
sudo apt update
sudo apt install -y default-jdk wget git
cd /home/$USER/
sudo mkdir tomcat${version}
cd /home/$USER/tomcat${version}
sudo wget https://downloads.apache.org/tomcat/tomcat-9/v${version}/bin/apache-tomcat-${version}.tar.gz
sudo tar -xvzf apache-tomcat-9.*
sudo rm -rf apache*.gz
sudo chmod -R 755 /home/$USER/tomcat${version}/apache-tomcat-9.*
sudo rm -rfv /home/$USER/tomcat${version}/apache-tomcat-9.*/webapps/manager/META-INF/context.xml
sudo rm -rfv /home/$USER/tomcat${version}/apache-tomcat-9.*/webapps/host-manager/META-INF/context.xml
sudo rm -rfv /home/$USER/tomcat${version}/apache-tomcat-9.*/conf/tomcat-users.xml
sudo cp -v /home/$USER/tomcat-config-ubuntu/context.xml /home/$USER/tomcat${version}/apache-tomcat-9.*/webapps/manager/META-INF/
sudo cp -v /home/$USER/tomcat-config-ubuntu/context.xml /home/$USER/tomcat${version}/apache-tomcat-9.*/webapps/host-manager/META-INF/
sudo cp -v /home/$USER/tomcat-config-ubuntu/tomcat-users.xml /home/$USER/tomcat${version}/apache-tomcat-9.*/conf/
sudo rm -rf /home/$USER/tomcat-config-ubuntu
cd /home/$USER/tomcat${version}/apache-tomcat-9.*
sudo sh bin/startup.sh
echo "username: admin"
echo "password: admin"
sudo chown $USER:ubuntu /home/$USER/tomcat${version}
sudo chown $USER:ubuntu /home/$USER/tomcat${version}/apache-tomcat-9.*