clamav/rc.clamav

Sun, 01 Nov 2009 15:44:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sun, 01 Nov 2009 15:44:08 +0100
changeset 227
e003f051ba1d
child 232
e3fb635fcb8e
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

michael@227 1 #!@l_prefix@/bin/openpkg rc
michael@227 2 ##
michael@227 3 ## rc.clamav -- Run-Commands
michael@227 4 ##
michael@227 5
michael@227 6 %config
michael@227 7 clamav_enable="$openpkg_rc_def"
michael@227 8 clamav_daemons="clamd clamav-milter"
michael@227 9 clamav_clamd_flags=""
michael@227 10 clamav_clamav_milter_flags=""
michael@227 11 clamav_update="daily"
michael@227 12 clamav_log_prolog="true"
michael@227 13 clamav_log_epilog="true"
michael@227 14 clamav_log_numfiles="10"
michael@227 15 clamav_log_minsize="1M"
michael@227 16 clamav_log_complevel="9"
michael@227 17
michael@227 18 %common
michael@227 19 clamav_cfgfile="@l_prefix@/etc/clamav/clamd.conf"
michael@227 20 clamav_pidfile_clamd="@l_prefix@/var/clamav/clamd.pid"
michael@227 21 clamav_pidfile_clamav_milter="@l_prefix@/var/clamav/clamav-milter.pid"
michael@227 22 clamav_signal () {
michael@227 23 [ -f $clamav_pidfile_clamd ] \
michael@227 24 && kill -$1 `cat $clamav_pidfile_clamd`
michael@227 25 local rc_clamav_clamd=$?
michael@227 26 [ -f $clamav_pidfile_clamav_milter ] \
michael@227 27 && kill -$1 `cat $clamav_pidfile_clamav_milter`
michael@227 28 local rc_clamav_clamav_milter=$?
michael@227 29 [ $rc_clamav_clamd -eq 0 \
michael@227 30 -o $rc_clamav_clamav_milter -eq 0 ]
michael@227 31 }
michael@227 32
michael@227 33 %status -u @l_rusr@ -o
michael@227 34 clamav_usable="unknown"
michael@227 35 clamav_active="no"
michael@227 36 rcService clamav enable yes && \
michael@227 37 clamav_signal 0 && clamav_active="yes"
michael@227 38 echo "clamav_enable=\"$clamav_enable\""
michael@227 39 echo "clamav_usable=\"$clamav_usable\""
michael@227 40 echo "clamav_active=\"$clamav_active\""
michael@227 41
michael@227 42 %start -u @l_rusr@
michael@227 43 rcService clamav enable yes || exit 0
michael@227 44 rcService clamav active yes && exit 0
michael@227 45 for daemon in $clamav_daemons; do
michael@227 46 if [ ".$daemon" = ".clamd" ]; then
michael@227 47 @l_prefix@/sbin/clamd \
michael@227 48 --config-file=$clamav_cfgfile \
michael@227 49 $clamav_clamd_flags
michael@227 50 elif [ ".$daemon" = ".clamav-milter" -a -x @l_prefix@/sbin/clamav-milter ]; then
michael@227 51 ( umask 002
michael@227 52 @l_prefix@/sbin/clamav-milter \
michael@227 53 --config-file=$clamav_cfgfile \
michael@227 54 --max-children=4 --outgoing --local \
michael@227 55 --pidfile=$clamav_pidfile_clamav_milter \
michael@227 56 --sendmail-cf=/dev/null \
michael@227 57 $clamav_clamav_milter_flags \
michael@227 58 local:@l_prefix@/var/milter/socket/clamav-milter
michael@227 59 ) || exit $?
michael@227 60 fi
michael@227 61 done
michael@227 62
michael@227 63 %stop -u @l_rusr@
michael@227 64 rcService clamav enable yes || exit 0
michael@227 65 rcService clamav active no && exit 0
michael@227 66 clamav_signal TERM
michael@227 67 rm -f $clamav_pidfile_clamd 2>/dev/null || true
michael@227 68 rm -f $clamav_pidfile_clamav_milter 2>/dev/null || true
michael@227 69
michael@227 70 %restart -u @l_rusr@
michael@227 71 rcService clamav enable yes || exit 0
michael@227 72 rcService clamav active no && exit 0
michael@227 73 rc clamav stop
michael@227 74 sleep 2
michael@227 75 rc clamav start
michael@227 76
michael@227 77 %quarterly -u @l_rusr@
michael@227 78 rcService clamav enable yes || exit 0
michael@227 79 if [ ".$clamav_update" = .quarterly ]; then
michael@227 80 @l_prefix@/bin/freshclam
michael@227 81 if [ $? -ge 10 ]; then exit $?; fi
michael@227 82 fi
michael@227 83
michael@227 84 %hourly -u @l_rusr@
michael@227 85 rcService clamav enable yes || exit 0
michael@227 86 if [ ".$clamav_update" = .hourly ]; then
michael@227 87 @l_prefix@/bin/freshclam
michael@227 88 if [ $? -ge 10 ]; then exit $?; fi
michael@227 89 fi
michael@227 90
michael@227 91 %daily -u @l_rusr@
michael@227 92 rcService clamav enable yes || exit 0
michael@227 93 if [ ".$clamav_update" = .daily ]; then
michael@227 94 @l_prefix@/bin/freshclam
michael@227 95 if [ $? -ge 10 ]; then exit $?; fi
michael@227 96 fi
michael@227 97 logfiles=""
michael@227 98 for daemon in freshclam $clamav_daemons; do
michael@227 99 logfiles="$logfiles @l_prefix@/var/clamav/$daemon.log"
michael@227 100 done
michael@227 101 shtool rotate -f \
michael@227 102 -n $clamav_log_numfiles -s $clamav_log_minsize -d \
michael@227 103 -z $clamav_log_complevel -o @l_rusr@ -g @l_rgrp@ -m 644 \
michael@227 104 -P "$clamav_log_prolog" \
michael@227 105 -E "$clamav_log_epilog; rc clamav restart" \
michael@227 106 $logfiles
michael@227 107
michael@227 108 %weekly -u @l_rusr@
michael@227 109 rcService clamav enable yes || exit 0
michael@227 110 if [ ".$clamav_update" = .weekly ]; then
michael@227 111 @l_prefix@/bin/freshclam
michael@227 112 if [ $? -ge 10 ]; then exit $?; fi
michael@227 113 fi
michael@227 114

mercurial