diff options
author | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
---|---|---|
committer | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
commit | cec37e643f4889b4b8652bdfce886b1e5e81f2bd (patch) | |
tree | c992d8325923324f5d318f57b4c05dd5fe494988 /pcr/openrc-misc/clamd.initd-r6 | |
parent | 7385c6143c1b587bca68deade6e5989d11879767 (diff) | |
download | abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.tar.gz abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.tar.bz2 abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.zip |
openrc-misc: add new package to [pcr]
Diffstat (limited to 'pcr/openrc-misc/clamd.initd-r6')
-rw-r--r-- | pcr/openrc-misc/clamd.initd-r6 | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/pcr/openrc-misc/clamd.initd-r6 b/pcr/openrc-misc/clamd.initd-r6 new file mode 100644 index 000000000..276e07aa8 --- /dev/null +++ b/pcr/openrc-misc/clamd.initd-r6 @@ -0,0 +1,129 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-antivirus/clamav/files/clamd.initd-r6,v 1.1 2013/09/27 16:04:14 eras Exp $ + +daemon_clamd="/usr/sbin/clamd" +daemon_freshclam="/usr/bin/freshclam" +daemon_milter="/usr/sbin/clamav-milter" + +extra_commands="logfix" + +depend() { + use net + provide antivirus +} + +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() { + # populate variables and fix log file permissions + logfix + + if [ "${START_CLAMD}" = "yes" ]; then + checkpath --quiet --mode 755 \ + --owner "${clamd_user}":"${clamd_user}" \ + --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} \ + --ionice ${IONICE_LEVEL:-0} \ + --exec ${daemon_clamd} + eend $? "Failed to start clamd" + fi + + if [ "${START_FRESHCLAM}" = "yes" ]; then + checkpath --quiet --mode 755 \ + --owner "${clamd_user}":"${clamd_user}" \ + --directory `dirname ${clamd_socket}` + ebegin "Starting freshclam" + start-stop-daemon --start --quiet \ + --nicelevel ${FRESHCLAM_NICELEVEL:-0} \ + --ionice ${IONICE_LEVEL:-0} \ + --exec ${daemon_freshclam} -- -d + retcode=$? + if [ ${retcode} = 1 ]; then + eend 0 + einfo "Virus databases are already up to date." + else + eend ${retcode} "Failed to start freshclam" + fi + fi + + if [ "${START_MILTER}" = "yes" ]; then + if [ -z "${MILTER_CONF_FILE}" ]; then + MILTER_CONF_FILE="/etc/clamav-milter.conf" + fi + + ebegin "Starting clamav-milter" + start-stop-daemon --start --quiet \ + --nicelevel ${MILTER_NICELEVEL:-0} \ + --ionice ${IONICE_LEVEL:-0} \ + --exec ${daemon_milter} -- -c ${MILTER_CONF_FILE} + eend $? "Failed to start clamav-milter" + fi +} + +stop() { + if [ "${START_CLAMD}" = "yes" ]; then + ebegin "Stopping clamd" + start-stop-daemon --stop --quiet --name clamd + eend $? "Failed to stop clamd" + fi + if [ "${START_FRESHCLAM}" = "yes" ]; then + ebegin "Stopping freshclam" + start-stop-daemon --stop --quiet --name freshclam + eend $? "Failed to stop freshclam" + fi + if [ "${START_MILTER}" = "yes" ]; then + ebegin "Stopping clamav-milter" + start-stop-daemon --stop --quiet --name clamav-milter + eend $? "Failed to stop clamav-milter" + fi +} + +logfix() { + clamd_socket=$(get_config clamd LocalSocket /run/clamav/clamd.sock) + clamd_user=$(get_config clamd User clamav) + freshclam_user=$(get_config freshclam DatabaseOwner clamav) + + if [ "${START_CLAMD}" = "yes" ]; then + # fix clamd log permissions + # (might be clobbered by logrotate or something) + local logfile=$(get_config clamd LogFile) + if [ -n "${logfile}" ]; then + checkpath --quiet \ + --owner "${clamd_user}":"${clamd_user}" \ + --mode 640 \ + --file ${logfile} + fi + fi + + if [ "${START_FRESHCLAM}" = "yes" ]; then + # fix freshclam log permissions + # (might be clobbered by logrotate or something) + local logfile=$(get_config freshclam UpdateLogFile) + if [ -n "${logfile}" ]; then + checkpath --quiet \ + --owner "${freshclam_user}":"${freshclam_user}" \ + --mode 640 \ + --file ${logfile} + fi + fi +} |