diff --git a/tomcat4/rc.tomcat4 b/tomcat4/rc.tomcat4 index 65a0fb3d1e..e92a31e045 100644 --- a/tomcat4/rc.tomcat4 +++ b/tomcat4/rc.tomcat4 @@ -6,25 +6,60 @@ %config tomcat4_enable="$openpkg_rc_def" tomcat4_home="@l_prefix@/libexec/tomcat" + tomcat4_log_prolog="true" + tomcat4_log_epilog="true" + tomcat4_log_numfiles="10" + tomcat4_log_minsize="1M" + tomcat4_log_complevel="9" + +%common + tomcat4_pidfile="@l_prefix@/var/tomcat/log/tomcat.pid" + tomcat4_signal () { + [ -f $tomcat4_pidfile ] && kill -$1 `cat $tomcat4_pidfile` + } + +%status -u @l_rusr@ -o + tomcat4_usable="unknown" + tomcat4_active="no" + rcService tomcat4 enable yes && \ + tomcat4_signal 0 && tomcat4_active="yes" + echo "tomcat4_enable=\"$tomcat4_enable\"" + echo "tomcat4_usable=\"$tomcat4_usable\"" + echo "tomcat4_active=\"$tomcat4_active\"" %start -u @l_rusr@ rcService tomcat4 enable yes || exit 0 + rcService tomcat4 active yes && exit 0 JAVA_HOME="$JDK_home"; export JAVA_HOME CATALINA_HOME="$tomcat4_home"; export CATALINA_HOME + CATALINA_PID="$tomcat4_pidfile"; export CATALINA_PID $CATALINA_HOME/bin/startup.sh %stop -u @l_rusr@ rcService tomcat4 enable yes || exit 0 + rcService tomcat4 active no && exit 0 JAVA_HOME="$JDK_home"; export JAVA_HOME CATALINA_HOME="$tomcat4_home"; export CATALINA_HOME + CATALINA_PID="$tomcat4_pidfile"; export CATALINA_PID $CATALINA_HOME/bin/shutdown.sh + rm -f $tomcat4_pidfile 2>/dev/null || true %restart -u @l_rusr@ rcService tomcat4 enable yes || exit 0 - JAVA_HOME="$JDK_home"; export JAVA_HOME - CATALINA_HOME="$tomcat4_home"; export CATALINA_HOME - $CATALINA_HOME/bin/shutdown.sh - $CATALINA_HOME/bin/startup.sh + rcService tomcat4 active no && exit 0 + rc tomcat4 stop + rc tomcat4 start + +%daily -u @l_rusr@ + rcService tomcat4 enable yes || exit 0 + + # rotate logfile + shtool rotate -f \ + -n ${tomcat4_log_numfiles} -s ${tomcat4_log_minsize} -d \ + -z ${tomcat4_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \ + -P "${tomcat4_log_prolog}" \ + -E "${tomcat4_log_epilog} && rc tomcat4 restart" \ + @l_prefix@/var/tomcat/log/catalina.out %env rcService tomcat4 enable yes || exit 0 diff --git a/tomcat4/tomcat4.spec b/tomcat4/tomcat4.spec index 93b2d47cd5..839759b673 100644 --- a/tomcat4/tomcat4.spec +++ b/tomcat4/tomcat4.spec @@ -33,7 +33,7 @@ Distribution: OpenPKG [EVAL] Group: Web License: Apache Software License 1.1 Version: 4.1.27 -Release: 20030924 +Release: 20031208 # list of sources Source0: http://www.apache.org/dist/jakarta/tomcat-4/tomcat-%{version}.tar.gz @@ -134,12 +134,22 @@ Conflicts: tomcat %clean rm -rf $RPM_BUILD_ROOT +%post + # after upgrade, restart service + if [ $1 -eq 2 ]; then + eval `%{l_rc} tomcat4 status 2>/dev/null` + [ ".$tomcat_active" = .yes ] && %{l_rc} tomcat4 restart + fi + exit 0 + %preun if [ $1 -eq 0 ]; then - # remove log files + # before erase, stop service and remove log files + %{l_rc} tomcat4 stop 2>/dev/null rm -f $RPM_INSTALL_PREFIX/var/tomcat/log/* rm -rf $RPM_INSTALL_PREFIX/var/tomcat/temp/* rm -rf $RPM_INSTALL_PREFIX/var/tomcat/work/* rm -f $RPM_INSTALL_PREFIX/var/tomcat/conf/jk2.properties.save fi + exit 0