Browse Source

Complete changes to comply with #202 features

Michael Schloh von Bennewitz 22 years ago
parent
commit
6f841650f2
2 changed files with 41 additions and 1 deletions
  1. 23 1
      clamav/clamav.spec
  2. 18 0
      clamav/rc.clamav

+ 23 - 1
clamav/clamav.spec

@@ -33,7 +33,7 @@ Distribution: OpenPKG [PLUS]
 Group:        Filesystem
 Group:        Filesystem
 License:      GPL
 License:      GPL
 Version:      0.60
 Version:      0.60
-Release:      20030810
+Release:      20030813
 
 
 #   list of sources
 #   list of sources
 Source0:      http://osdn.dl.sourceforge.net/clamav/clamav-%{version}.tar.gz
 Source0:      http://osdn.dl.sourceforge.net/clamav/clamav-%{version}.tar.gz
@@ -130,3 +130,25 @@ AutoReqProv:  no
 %clean
 %clean
     rm -rf $RPM_BUILD_ROOT
     rm -rf $RPM_BUILD_ROOT
 
 
+%pre
+    #   before upgrade, save status and stop service
+    [ $1 -eq 2 ] || exit 0
+    eval `%{l_rc} clamav status 2>/dev/null | tee %{l_tmpfile}`
+    %{l_rc} clamav stop 2>/dev/null
+    exit 0
+
+%post
+    if [ $1 -eq 2 ]; then
+        #   after upgrade, restore status
+        eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
+        [ ".$clamav_active" = .yes ] && %{l_rc} clamav start
+    fi
+    exit 0
+
+%preun
+    #   before erase, stop service and remove log files
+    [ $1 -eq 0 ] || exit 0
+    %{l_rc} clamav stop 2>/dev/null
+    rm -f $RPM_INSTALL_PREFIX/var/clamav/*.log* >/dev/null 2>&1 || true
+    exit 0
+

+ 18 - 0
clamav/rc.clamav

@@ -5,6 +5,11 @@
 
 
 %config
 %config
     clamav_enable="$openpkg_rc_def"
     clamav_enable="$openpkg_rc_def"
+    clamav_log_prolog="true"
+    clamav_log_epilog="true"
+    clamav_log_numfiles="10"
+    clamav_log_minsize="1M"
+    clamav_log_complevel="9"
 
 
 %common
 %common
     clamav_cfgfile="@l_prefix@/etc/clamav/clamav.conf"
     clamav_cfgfile="@l_prefix@/etc/clamav/clamav.conf"
@@ -24,20 +29,33 @@
 
 
 %start -u @l_rusr@
 %start -u @l_rusr@
     rcService clamav enable yes || exit 0
     rcService clamav enable yes || exit 0
+    rcService clamav active yes && exit 0
     @l_prefix@/sbin/clamd --config-file=$clamav_cfgfile
     @l_prefix@/sbin/clamd --config-file=$clamav_cfgfile
 
 
 %stop -u @l_rusr@
 %stop -u @l_rusr@
     rcService clamav enable yes || exit 0
     rcService clamav enable yes || exit 0
+    rcService clamav active no && exit 0
     clamav_signal TERM
     clamav_signal TERM
     rm -f $clamav_pidfile 2>/dev/null || true
     rm -f $clamav_pidfile 2>/dev/null || true
 
 
 %restart -u @l_rusr@
 %restart -u @l_rusr@
     rcService clamav enable yes || exit 0
     rcService clamav enable yes || exit 0
+    rcService clamav active no && exit 0
     rc clamav stop
     rc clamav stop
     sleep 2
     sleep 2
     rc clamav start
     rc clamav start
 
 
 %daily -u @l_rusr@
 %daily -u @l_rusr@
     rcService clamav enable yes || exit 0
     rcService clamav enable yes || exit 0
+
+    #   update virus database
     @l_prefix@/bin/freshclam
     @l_prefix@/bin/freshclam
 
 
+    #   rotate logfiles
+    shtool rotate -f \
+        -n ${clamav_log_numfiles} -s ${clamav_log_minsize} -d \
+        -z ${clamav_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
+        -P "${clamav_log_prolog}" \
+        -E "${clamav_log_epilog} && rc clamav restart" \
+        @l_prefix@/var/clamav/clamd.log
+