clamav/rc.clamav

Mon, 02 Nov 2009 22:29:58 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 02 Nov 2009 22:29:58 +0100
changeset 233
f5f6e93f3dc6
parent 232
e3fb635fcb8e
child 234
b0dde56e4a08
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

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

mercurial