michael@227: #!@l_prefix@/bin/openpkg rc michael@227: ## michael@227: ## rc.clamav -- Run-Commands michael@227: ## michael@227: michael@227: %config michael@227: clamav_enable="$openpkg_rc_def" michael@227: clamav_daemons="clamd clamav-milter" michael@227: clamav_clamd_flags="" michael@227: clamav_clamav_milter_flags="" michael@227: clamav_update="daily" michael@227: clamav_log_prolog="true" michael@227: clamav_log_epilog="true" michael@227: clamav_log_numfiles="10" michael@227: clamav_log_minsize="1M" michael@227: clamav_log_complevel="9" michael@227: michael@227: %common michael@227: clamav_cfgfile="@l_prefix@/etc/clamav/clamd.conf" michael@234: clamav_milter_cfgfile="@l_prefix@/etc/clamav/clamav-milter.conf" michael@227: clamav_pidfile_clamd="@l_prefix@/var/clamav/clamd.pid" michael@227: clamav_pidfile_clamav_milter="@l_prefix@/var/clamav/clamav-milter.pid" michael@227: clamav_signal () { michael@227: [ -f $clamav_pidfile_clamd ] \ michael@227: && kill -$1 `cat $clamav_pidfile_clamd` michael@227: local rc_clamav_clamd=$? michael@227: [ -f $clamav_pidfile_clamav_milter ] \ michael@227: && kill -$1 `cat $clamav_pidfile_clamav_milter` michael@227: local rc_clamav_clamav_milter=$? michael@227: [ $rc_clamav_clamd -eq 0 \ michael@227: -o $rc_clamav_clamav_milter -eq 0 ] michael@227: } michael@227: michael@227: %status -u @l_rusr@ -o michael@227: clamav_usable="unknown" michael@227: clamav_active="no" michael@227: rcService clamav enable yes && \ michael@227: clamav_signal 0 && clamav_active="yes" michael@227: echo "clamav_enable=\"$clamav_enable\"" michael@227: echo "clamav_usable=\"$clamav_usable\"" michael@227: echo "clamav_active=\"$clamav_active\"" michael@227: michael@227: %start -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: rcService clamav active yes && exit 0 michael@227: for daemon in $clamav_daemons; do michael@227: if [ ".$daemon" = ".clamd" ]; then michael@227: @l_prefix@/sbin/clamd \ michael@227: --config-file=$clamav_cfgfile \ michael@227: $clamav_clamd_flags michael@227: elif [ ".$daemon" = ".clamav-milter" -a -x @l_prefix@/sbin/clamav-milter ]; then michael@227: ( umask 002 michael@227: @l_prefix@/sbin/clamav-milter \ michael@234: --config-file=$clamav_milter_cfgfile \ michael@234: $clamav_clamav_milter_flags michael@227: ) || exit $? michael@227: fi michael@227: done michael@227: michael@227: %stop -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: rcService clamav active no && exit 0 michael@227: clamav_signal TERM michael@227: rm -f $clamav_pidfile_clamd 2>/dev/null || true michael@227: rm -f $clamav_pidfile_clamav_milter 2>/dev/null || true michael@227: michael@227: %restart -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: rcService clamav active no && exit 0 michael@227: rc clamav stop michael@227: sleep 2 michael@227: rc clamav start michael@227: michael@227: %quarterly -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: if [ ".$clamav_update" = .quarterly ]; then michael@227: @l_prefix@/bin/freshclam michael@227: if [ $? -ge 10 ]; then exit $?; fi michael@227: fi michael@227: michael@227: %hourly -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: if [ ".$clamav_update" = .hourly ]; then michael@227: @l_prefix@/bin/freshclam michael@227: if [ $? -ge 10 ]; then exit $?; fi michael@227: fi michael@227: michael@227: %daily -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: if [ ".$clamav_update" = .daily ]; then michael@227: @l_prefix@/bin/freshclam michael@227: if [ $? -ge 10 ]; then exit $?; fi michael@227: fi michael@227: logfiles="" michael@227: for daemon in freshclam $clamav_daemons; do michael@227: logfiles="$logfiles @l_prefix@/var/clamav/$daemon.log" michael@227: done michael@227: shtool rotate -f \ michael@227: -n $clamav_log_numfiles -s $clamav_log_minsize -d \ michael@227: -z $clamav_log_complevel -o @l_rusr@ -g @l_rgrp@ -m 644 \ michael@227: -P "$clamav_log_prolog" \ michael@227: -E "$clamav_log_epilog; rc clamav restart" \ michael@227: $logfiles michael@227: michael@227: %weekly -u @l_rusr@ michael@227: rcService clamav enable yes || exit 0 michael@227: if [ ".$clamav_update" = .weekly ]; then michael@227: @l_prefix@/bin/freshclam michael@227: if [ $? -ge 10 ]; then exit $?; fi michael@227: fi michael@227: