You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/11/28 14:43:06 UTC

[GitHub] dg4prez closed pull request #3061: [backport] Traffic Router RPM installation

dg4prez closed pull request #3061: [backport] Traffic Router RPM installation
URL: https://github.com/apache/trafficcontrol/pull/3061
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_router/build/pom.xml b/traffic_router/build/pom.xml
index 7c808577c..a3f1a387a 100644
--- a/traffic_router/build/pom.xml
+++ b/traffic_router/build/pom.xml
@@ -194,10 +194,9 @@
 								<mapping>
 									<directory>${env.STARTUP_SCRIPT_DIR}</directory>
 									<directoryIncluded>false</directoryIncluded>
-									<filemode>755</filemode>
+									<filemode>644</filemode>
 									<username>root</username>
 									<groupname>root</groupname>
-									<configuration>noreplace</configuration>
 									<sources>
 										<source>
 											<location>${env.STARTUP_SCRIPT_LOC}</location>
@@ -219,7 +218,7 @@
 								</mapping>
 							</mappings>
 							<requires>
-								<require>jdk &gt;= 1.8</require>
+								<require>java &gt;= 1.8</require>
 								<require>tomcat = ${env.TOMCAT_VERSION}.${env.TOMCAT_RELEASE}-${env.BUILD_LOCK}</require>
 								<require>apr &gt;= 1.4.8</require>
 								<require>tomcat-native &gt;= 1.2.16</require>
@@ -228,9 +227,12 @@
 								<obsolete>traffic_router &lt; 3.0.0</obsolete>
 							</obsoletes>
 
-							<preinstallScriptlet>
-								<scriptFile>../core/src/main/scripts/preinstall.sh</scriptFile>
-							</preinstallScriptlet>
+							<pretransScriptlet>
+								 <scriptFile>../core/src/main/scripts/pretrans.sh</scriptFile>
+							</pretransScriptlet>
+							<preScriptlet>
+								 <scriptFile>../core/src/main/scripts/preinstall.sh</scriptFile>
+							</preScriptlet>
 							<postinstallScriptlet>
 								<scriptFile>../core/src/main/scripts/postinstall.sh</scriptFile>
 							</postinstallScriptlet>
diff --git a/traffic_router/core/src/main/lib/systemd/system/traffic_router.service b/traffic_router/core/src/main/lib/systemd/system/traffic_router.service
index 97252edc2..616112574 100755
--- a/traffic_router/core/src/main/lib/systemd/system/traffic_router.service
+++ b/traffic_router/core/src/main/lib/systemd/system/traffic_router.service
@@ -18,8 +18,7 @@ After=syslog.target network.target
 
 [Service]
 Type=forking
-
-Environment=JAVA_HOME=/usr/java/default
+Environment=JAVA_HOME=/usr/lib/jvm/jre
 Environment=CATALINA_PID=/opt/traffic_router/temp/tomcat.pid
 Environment=CATALINA_HOME=/opt/tomcat
 Environment=CATALINA_BASE=/opt/traffic_router
diff --git a/traffic_router/core/src/main/scripts/preinstall.sh b/traffic_router/core/src/main/scripts/preinstall.sh
index 372353910..89b540dff 100644
--- a/traffic_router/core/src/main/scripts/preinstall.sh
+++ b/traffic_router/core/src/main/scripts/preinstall.sh
@@ -14,17 +14,8 @@
 #
 
 # figure out which version of traffic_router is currently running
-# and then shut it down
+# and then shut it down. Running both test just in case.
 set +e
-chkconfig --list tomcat >/dev/null
-
-if [ $? -eq 0 ]; then
-  /sbin/service tomcat stop
-else
-  /usr/bin/systemctl list-unit-files traffic_router.service > /dev/null
-
-  [ $? -eq 0 ] && /usr/bin/systemctl stop traffic_router
-fi
 
 # delete the expanded war files from the previous version
 if [[ -e /opt/traffic_router/webapps/core ]]; then
diff --git a/traffic_router/core/src/main/scripts/pretrans.sh b/traffic_router/core/src/main/scripts/pretrans.sh
new file mode 100644
index 000000000..7365c087b
--- /dev/null
+++ b/traffic_router/core/src/main/scripts/pretrans.sh
@@ -0,0 +1,30 @@
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# figure out which version of traffic_router is currently running
+# and then shut it down. Running both test just in case.
+set +e
+
+if [[ -e "/etc/init.d/tomcat" ]]; then
+  echo "Stopping tomcat service..."
+  /sbin/service tomcat stop
+  chkconfig tomcat off
+fi
+
+echo "Stopping traffic_router services"
+/usr/bin/systemctl list-unit-files traffic_router.service > /dev/null
+[ $? -eq 0 ] && /usr/bin/systemctl stop traffic_router
+echo "Done stopping traffic_router services"
+
diff --git a/traffic_router/tomcat-rpm/tomcat.service b/traffic_router/tomcat-rpm/tomcat.service
index 29c6f99b4..bc99bd345 100644
--- a/traffic_router/tomcat-rpm/tomcat.service
+++ b/traffic_router/tomcat-rpm/tomcat.service
@@ -21,8 +21,7 @@ After=syslog.target network.target
 
 [Service]
 Type=forking
-
-Environment=JAVA_HOME=/usr/java/default
+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
diff --git a/traffic_router/tomcat-rpm/tomcat.spec b/traffic_router/tomcat-rpm/tomcat.spec
index 63f8e8115..f3cc42602 100644
--- a/traffic_router/tomcat-rpm/tomcat.spec
+++ b/traffic_router/tomcat-rpm/tomcat.spec
@@ -19,9 +19,8 @@ Summary:    Apache Tomcat Servlet/JSP Engine 8.5+, RI for Servlet 3.1/JSP 2.3 AP
 License:    Apache Software License
 URL:        https://github.com/apache/incubator-trafficcontrol/
 Source:     %{_sourcedir}/apache-tomcat-%{version}.tar.gz
-Requires:   jdk >= 1.8
+Requires:   java >= 1.8
 
-%define startup_script %{_sysconfdir}/systemd/system/tomcat.service
 %define tomcat_home /opt/tomcat
 
 %description
@@ -49,17 +48,15 @@ rm -rf ${RPM_BUILD_ROOT}/%{tomcat_home}/webapps/*
 # Remove *.bat
 rm -f ${RPM_BUILD_ROOT}/%{tomcat_home}/bin/*.bat
 
-# install sysd script
-install -d -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system
-install    -m 755 %_sourcedir/tomcat.service ${RPM_BUILD_ROOT}%{startup_script}
-
 %clean
 rm -rf ${RPM_BUILD_ROOT}
 
-%pre
+# This here takes care of stopping and removing tomcat before installing new files
+%pretrans
 if [[ -e "/etc/init.d/tomcat" ]]; then
-  echo "Disabling tomcat service..."
+  echo "Disabling and stopping SysV tomcat service..."
   chkconfig tomcat off
+  service stop tomcat
 fi
 
 if [ -d /opt/apache-tomcat-* ]; then
@@ -68,20 +65,20 @@ if [ -d /opt/apache-tomcat-* ]; then
   rm -rf /opt/tomcat
 fi
 
+%pre
+
 %files
 %defattr(-,root,root)
 %{tomcat_home}
-%{startup_script}
 
 %post
-systemctl daemon-reload
-
-echo "Tomcat for Traffic Router installed successfully."
-echo ""
-echo "Start with 'systemctl start traffic_router'"
 
 %preun
 
 %postun
 
 %changelog
+* Tue Nov 13 2018 Steve Malenfant <sm...@apache.org>
+- Remove old installation of tomcat
+- Removed systemd service for tomcat
+- Requires now leaves java choice to operator


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services