]> Frank Brehm's Git Trees - config/uhu1/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorfrank <frank@uhu1.uhu-banane.de>
Tue, 14 Aug 2012 10:15:34 +0000 (12:15 +0200)
committerroot <root@uhu1.uhu-banane.de>
Tue, 14 Aug 2012 10:15:34 +0000 (12:15 +0200)
.etckeeper
init.d/clamd
logrotate.d/._cfg0000_clamav [new file with mode: 0644]

index 76a984742bfce39b9940efffc16467e02f85a8ee..177426307ee0bbce8c076399c41892c13ed1ab50 100755 (executable)
@@ -961,6 +961,7 @@ maybe chmod 0644 './localtime'
 maybe chmod 0644 './login.defs'
 maybe chmod 0644 './logrotate.conf'
 maybe chmod 0755 './logrotate.d'
+maybe chmod 0644 './logrotate.d/._cfg0000_clamav'
 maybe chmod 0644 './logrotate.d/.keep_app-admin_logrotate-0'
 maybe chmod 0644 './logrotate.d/apache2'
 maybe chmod 0644 './logrotate.d/clamav'
index a1a55c243ad5e1b82ba7dbfb6fd28c6eeab42e63..40ccd00bd6be15e2861eacaf24ed1444de70e09f 100755 (executable)
@@ -1,7 +1,11 @@
 #!/sbin/runscript
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-antivirus/clamav/files/clamd.rc,v 1.18 2011/12/04 11:51:46 swegener Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-antivirus/clamav/files/clamd.initd,v 1.2 2012/08/11 13:12:35 eras Exp $
+
+daemon_clamd="/usr/sbin/clamd"
+daemon_freshclam="/usr/bin/freshclam"
+daemon_milter="/usr/sbin/clamav-milter"
 
 extra_commands="logfix"
 
@@ -10,19 +14,36 @@ depend() {
        provide antivirus
 }
 
-start() {
-       local clamd_socket=`awk '$1 == "LocalSocket" { print $2 }' /etc/clamd.conf`
+get_config() {
+       clamconf | sed 's/["=]//g' | \
+       awk "{
+       if(\$0==\"Config file: $1.conf\") S=1
+       if(S==1&&\$0==\"\") {
+               print \"$3\"
+               exit
+       }
+       if(S==1&&\$1~\"^$2\$\") {
+               print \$2!=\"disabled\"?\$2:\"$3\"
+               exit
+       }
+       }"
+}
 
+start() {
+       local clamd_socket=$(get_config clamd LocalSocket /tmp/clamd)
        logfix
 
        if [ "${START_CLAMD}" = "yes" ]; then
-               if [ -S "${clamd_socket:-/tmp/clamd}" ]; then
-                       rm -f ${clamd_socket:-/tmp/clamd}
+               checkpath --quiet \
+                       --owner $(get_config clamd User clamav):root \
+                       --directory `dirname ${clamd_socket}`
+               if [ -S "${clamd_socket}" ]; then
+                       rm -f ${clamd_socket}
                fi
                ebegin "Starting clamd"
                start-stop-daemon --start --quiet \
                        --nicelevel ${CLAMD_NICELEVEL:-0} \
-                       --exec /usr/sbin/clamd
+                       --exec ${daemon_clamd}
                eend $? "Failed to start clamd"
        fi
 
@@ -30,7 +51,7 @@ start() {
                ebegin "Starting freshclam"
                start-stop-daemon --start --quiet \
                        --nicelevel ${FRESHCLAM_NICELEVEL:-0} \
-                       --exec /usr/bin/freshclam -- -d
+                       --exec ${daemon_freshclam} -- -d
                retcode=$?
                if [ ${retcode} = 1 ]; then
                        eend 0
@@ -48,7 +69,7 @@ start() {
                ebegin "Starting clamav-milter"
                start-stop-daemon --start --quiet \
                        --nicelevel ${MILTER_NICELEVEL:-0} \
-                       --exec /usr/sbin/clamav-milter -- -c ${MILTER_CONF_FILE}
+                       --exec ${daemon_milter} -- -c ${MILTER_CONF_FILE}
                eend $? "Failed to start clamav-milter"
        fi
 }
@@ -75,28 +96,24 @@ logfix() {
        if [ "${START_CLAMD}" = "yes" ]; then
                # fix clamd log permissions
                # (might be clobbered by logrotate or something)
-               local logfile=`awk '$1 == "LogFile" { print $2 }' /etc/clamd.conf`
-               local clamav_user=`awk '$1 == "User" { print $2 }' /etc/clamd.conf`
-               if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then
-                       if [ ! -f "${logfile}" ]; then
-                               touch ${logfile}
-                       fi
-                       chown ${clamav_user} ${logfile}
-                       chmod 640 ${logfile}
+               local logfile=$(get_config clamd LogFile)
+               if [ -n "${logfile}" ]; then
+                       checkpath --quiet \
+                               --owner $(get_config clamd User clamav):root \
+                               --mode 640 \
+                               --file ${logfile}
                fi
        fi
 
        if [ "${START_FRESHCLAM}" = "yes" ]; then
                # fix freshclam log permissions
                # (might be clobbered by logrotate or something)
-               logfile=`awk '$1 == "UpdateLogFile" { print $2 }' /etc/freshclam.conf`
-               local freshclam_user=`awk '$1 == "DatabaseOwner" { print $2 }' /etc/freshclam.conf`
-               if [ -n "${logfile}" -a -n "${clamav_user}" ]; then
-                       if [ ! -f "${logfile}" ]; then
-                               touch ${logfile}
-                       fi      
-                       chown ${freshclam_user} ${logfile}
-                       chmod 640 ${logfile}
+               local logfile=$(get_config freshclam UpdateLogFile)
+               if [ -n "${logfile}" ]; then
+                       checkpath --quiet \
+                               --owner $(get_config freshclam DatabaseOwner clamav):root \
+                               --mode 640 \
+                               --file ${logfile}
                fi
        fi
 }
diff --git a/logrotate.d/._cfg0000_clamav b/logrotate.d/._cfg0000_clamav
new file mode 100644 (file)
index 0000000..12c77e0
--- /dev/null
@@ -0,0 +1,15 @@
+/var/log/clamav/clamd.log {
+       missingok
+       postrotate
+               /etc/init.d/clamd logfix
+               /bin/kill -HUP `cat /var/run/clamav/clamd.pid 2> /dev/null` 2>/dev/null || true
+       endscript
+}
+
+/var/log/clamav/freshclam.log {
+       missingok
+       postrotate
+               /etc/init.d/clamd logfix
+               /bin/kill -HUP `cat /var/run/clamav/freshclam.pid 2> /dev/null` 2>/dev/null || true
+       endscript
+}