clamav-notify-servers: rewrote script to be init-neutral
it just sends a 'zRELOAD' command to autodetected and/or configurable sockets, NOTE: new scripts requires the 'timeout' utility from recent 'coreutils'. It is *not* shipped by RHEL5 and before.
This commit is contained in:
parent
754437bfae
commit
adba5caebf
|
@ -1,10 +1,10 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||
# Copyright (C) 2004,2012 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
# the Free Software Foundation; version 2 and/or 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
@ -18,21 +18,73 @@
|
|||
# Usage: clamav-notify-servers
|
||||
|
||||
CFGFILE=/etc/sysconfig/clamav-servers
|
||||
BASE=/var/lock/subsys/clamd.
|
||||
INITRDDIR=/etc/init.d
|
||||
OP=nc
|
||||
NC=nc
|
||||
TIMEOUT_TERM=30
|
||||
TIMEOUT_KILL=60
|
||||
|
||||
ok=1
|
||||
get_sockets() {
|
||||
(
|
||||
cd /etc/clamd.d
|
||||
for i in *.conf; do
|
||||
test -f "$i" || continue
|
||||
test -r "$i" || continue
|
||||
|
||||
f=/usr/sbin/clamav-notify-servers.local
|
||||
base=${i%%.conf}
|
||||
S=/var/run/clamd.$base/clamd.sock
|
||||
test -S "$S" || continue
|
||||
test -w "$S" || continue
|
||||
|
||||
echo "$S"
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
op_nc() {
|
||||
cd /var/run
|
||||
for i in ${CLAMD_SOCKETS}; do
|
||||
case $i in
|
||||
(/*)
|
||||
test -S "$i" || {
|
||||
echo "socket '$i' does not exist" >&2
|
||||
continue
|
||||
}
|
||||
CMD=( $NC -U $i )
|
||||
;;
|
||||
|
||||
(ip4:*)
|
||||
addr=${i##ip4:}
|
||||
CMD=( $NC -4 ${addr%%:*} ${addr##*:} )
|
||||
;;
|
||||
|
||||
(ip6:*)
|
||||
addr=${i##ip6:}
|
||||
CMD=( $NC -6 ${addr%%:*} ${addr##*:} )
|
||||
;;
|
||||
(*)
|
||||
echo "unsupported socket name '$i'" >&2
|
||||
continue
|
||||
esac
|
||||
|
||||
resp=`printf 'zRELOAD\0' | timeout -k $TIMEOUT_KILL $TIMEOUT_TERM "${CMD[@]}"`
|
||||
case $resp in
|
||||
(RELOADING)
|
||||
;;
|
||||
(*)
|
||||
echo "clamd server '$i' gave '$resp' response" >&2
|
||||
let ++fail
|
||||
;;
|
||||
esac
|
||||
done
|
||||
cd - &>/dev/null
|
||||
}
|
||||
|
||||
|
||||
CLAMD_SOCKETS=`get_sockets`
|
||||
f=$CFGFILE
|
||||
test ! -e "$f" || . "$f"
|
||||
|
||||
for i in ${BASE}*; do
|
||||
test -e "$i" || continue
|
||||
fail=0
|
||||
op_$OP "$@"
|
||||
|
||||
srv=${INITRDDIR}/clamd.${i##${BASE}}
|
||||
test -e "$srv" || continue
|
||||
|
||||
"$srv" reload || ok=
|
||||
done >/dev/null
|
||||
|
||||
test "$ok"
|
||||
exit $fail
|
||||
|
|
|
@ -150,6 +150,7 @@ Group: System Environment/Daemons
|
|||
Requires: data(clamav)
|
||||
Requires: clamav-filesystem = %version-%release
|
||||
Requires: clamav-lib = %version-%release
|
||||
Requires: nc coreutils
|
||||
|
||||
%package server-sysvinit
|
||||
Summary: SysV initscripts for clamav server
|
||||
|
@ -851,6 +852,9 @@ test "$1" != "0" || /sbin/initctl -q stop clamav-milter || :
|
|||
|
||||
|
||||
%changelog
|
||||
* Sat Jan 21 2012 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||
- rewrote clamav-notify-servers to be init system neutral
|
||||
|
||||
* Sun Jan 8 2012 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.97.3-1702
|
||||
- set correct SELinux context for logfiles generated in %%post (#754555)
|
||||
- create systemd tmpfiles in %%post
|
||||
|
|
Loading…
Reference in New Issue