aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/clamav/APKBUILD114
-rw-r--r--main/clamav/clamav-daemon.post-install3
-rw-r--r--main/clamav/clamav-daemon.pre-install3
-rw-r--r--main/clamav/clamav-db.post-install3
-rw-r--r--main/clamav/clamd.confd3
-rwxr-xr-x[-rw-r--r--]main/clamav/clamd.initd20
-rw-r--r--main/clamav/freshclam.initd31
-rw-r--r--main/clamav/freshclam.pre-install5
8 files changed, 109 insertions, 73 deletions
diff --git a/main/clamav/APKBUILD b/main/clamav/APKBUILD
index c09dc5a310..29cd1561ae 100644
--- a/main/clamav/APKBUILD
+++ b/main/clamav/APKBUILD
@@ -2,18 +2,19 @@
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=clamav
pkgver=0.97.4
-pkgrel=1
-pkgusers=clamav
-pkggroups=clamav
+pkgrel=2
+pkgusers="clamav"
+pkggroups="clamav"
pkgdesc="An anti-virus toolkit for UNIX"
url="http://www.clamav.net/"
arch="all"
license="GPL"
depends="$pkgname-scanner $pkgname-daemon"
-install=""
+install="freshclam.pre-install
+ clamav-daemon.pre-install clamav-daemon.pre-upgrade"
makedepends="ncurses-dev zlib-dev bzip2-dev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-lib $pkgname-libunrar
- $pkgname-daemon $pkgname-scanner $pkgname-db"
+ $pkgname-daemon $pkgname-scanner $pkgname-db freshclam"
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
clamd.initd
clamd.confd
@@ -40,6 +41,8 @@ build() {
--infodir=/usr/share/info \
--without-iconv \
--disable-llvm \
+ --with-user=clamav \
+ --with-group=clamav \
--with-dbdir=/var/lib/clamav \
--enable-clamdtop
make || return 1
@@ -49,6 +52,26 @@ package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
rm "$pkgdir"/usr/lib/*.la || return 1
+
+ # set proper defaults
+ sed -i -e "s:^\(Example\):\# \1:" \
+ -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/freshclam.pid:" \
+ -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
+ -e "s:^\#\(UpdateLogFile\) .*:\1 /var/log/clamav/freshclam.log:" \
+ -e "s:^\#\(NotifyClamd\).*:\1 /etc/clamav/clamd.conf:" \
+ -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$pkgdir"/etc/clamav/freshclam.conf
+
+ # set proper defaults
+ sed -i -e "s:^\(Example\):\# \1:" \
+ -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/clamd.pid:" \
+ -e "s:.*\(LocalSocket\) .*:\1 /var/run/clamav/clamd.sock:" \
+ -e "s:.*\(User\) .*:\1 clamav:" \
+ -e "s:^\#\(LogFile\) .*:\1 /var/log/clamav/clamd.log:" \
+ -e "s:^\#\(LogTime\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$pkgdir"/etc/clamav/clamd.conf
}
lib() {
@@ -69,11 +92,35 @@ libunrar() {
"$subpkgdir"/usr/lib/
}
-db() {
- pkgdesc="ClamAV virus database and update program"
+freshclam() {
+ pkgdesc="Auto-updater for the Clam Antivirus scanner data-files"
depends="logrotate"
+ replaces="clamav clamav-db"
+ mkdir -p "$subpkgdir"/usr/bin \
+ "$subpkgdir"/etc/init.d \
+ "$subpkgdir"/etc/conf.d \
+ "$subpkgdir"/etc/clamav
+
+ mv "$pkgdir"/usr/bin/freshclam "$subpkgdir"/usr/bin || return 1
+ mv "$pkgdir"/etc/clamav/freshclam.conf \
+ "$subpkgdir"/etc/clamav/ || return 1
+ install -d -m755 -o clamav -g clamav \
+ "$subpkgdir"/var/run/clamav \
+ "$subpkgdir"/var/log/clamav \
+ "$subpkgdir"/var/lib/clamav || return 1
+
+ install -m755 -D "$srcdir"/freshclam.initd \
+ "$subpkgdir"/etc/init.d/freshclam || return 1
+ install -m644 -D "$srcdir"/freshclam.confd \
+ "$subpkgdir"/etc/conf.d/freshclam || return 1
+ install -m644 -D "$srcdir"/freshclam.logrotate \
+ "$pkgdir"/etc/logrotate.d/freshclam || return 1
+}
+
+db() {
+ pkgdesc="ClamAV virus database"
replaces="clamav"
- install="$subpkgname.pre-install $subpkgname.post-install $subpkgname.pre-upgrade"
+ depends="freshclam"
mkdir -p "$subpkgdir"/var/lib/ \
"$subpkgdir"/usr/bin \
"$subpkgdir"/etc/clamav \
@@ -81,31 +128,13 @@ db() {
"$subpkgdir"/var/log/clamav
mv "$pkgdir"/var/lib/clamav \
"$subpkgdir"/var/lib/ || return 1
- mv "$pkgdir"/usr/bin/freshclam \
- "$subpkgdir"/usr/bin || return 1
- install -m755 -D "$srcdir"/freshclam.initd \
- "$subpkgdir"/etc/init.d/freshclam || return 1
- install -m644 -D "$srcdir"/freshclam.confd \
- "$subpkgdir"/etc/conf.d/freshclam || return 1
- mv "$pkgdir"/etc/clamav/freshclam.conf \
- "$subpkgdir"/etc/clamav/ || return 1
- # set proper defaults
- sed -i -e "s:^\(Example\):\# \1:" \
- -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/freshclam.pid:" \
- -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
- -e "s:^\#\(UpdateLogFile\) .*:\1 /var/log/clamav/freshclam.log:" \
- -e "s:^\#\(NotifyClamd\).*:\1 /etc/clamav/clamd.conf:" \
- -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
- -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
- "$subpkgdir"/etc/clamav/freshclam.conf
- install -m644 -D "$srcdir"/freshclam.logrotate \
- "$subpkgdir"/etc/logrotate.d/freshclam || return 1
+ chown -R clamav:clamav "$subpkgdir"/var/lib/clamav
}
scanner() {
pkgdesc="ClamAV command-line scanner and utils"
replaces="clamav"
- depends="$pkgname-db"
+ depends="freshclam"
mkdir -p "$subpkgdir"/usr/bin
mv "$pkgdir"/usr/bin/clamscan \
"$subpkgdir"/usr/bin/ || return 1
@@ -119,13 +148,15 @@ scanner() {
daemon() {
pkgdesc="ClamAV daemon scanner"
replaces="clamav"
- depends="$pkgname-db logrotate"
- install="$subpkgname.pre-install $subpkgname.post-install $subpkgname.pre-upgrade"
+ depends="freshclam logrotate"
mkdir -p "$subpkgdir"/usr/bin \
"$subpkgdir"/usr/sbin \
"$subpkgdir"/etc/clamav \
+ || return 1
+ install -d -m 755 -o clamav -g clamav \
"$subpkgdir"/var/run/clamav \
- "$subpkgdir"/var/log/clamav
+ "$subpkgdir"/var/log/clamav \
+ "$subpkgdir"/var/lib/clamav
mv "$pkgdir"/usr/bin/clamconf \
"$subpkgdir"/usr/bin/ || return 1
mv "$pkgdir"/usr/sbin/clamd \
@@ -134,29 +165,20 @@ daemon() {
"$subpkgdir"/usr/bin/ || return 1
mv "$pkgdir"/usr/bin/clamdscan \
"$subpkgdir"/usr/bin/ || return 1
+ mv "$pkgdir"/etc/clamav/clamd.conf \
+ "$subpkgdir"/etc/clamav/ || return 1
install -m755 -D "$srcdir"/clamd.initd \
"$subpkgdir"/etc/init.d/clamd || return 1
install -m644 -D "$srcdir"/clamd.confd \
"$subpkgdir"/etc/conf.d/clamd || return 1
- mv "$pkgdir"/etc/clamav/clamd.conf \
- "$subpkgdir"/etc/clamav/ || return 1
- # set proper defaults
- sed -i -e "s:^\(Example\):\# \1:" \
- -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/clamd.pid:" \
- -e "s:.*\(LocalSocket\) .*:\1 /var/run/clamav/clamd.sock:" \
- -e "s:.*\(User\) .*:\1 clamav:" \
- -e "s:^\#\(LogFile\) .*:\1 /var/log/clamav/clamd.log:" \
- -e "s:^\#\(LogTime\).*:\1 yes:" \
- -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
- "$subpkgdir"/etc/clamav/clamd.conf
install -m644 -D "$srcdir"/clamd.logrotate \
- "$subpkgdir"/etc/logrotate.d/clamd || return 1
+ "$pkgdir"/etc/logrotate.d/clamd || return 1
}
md5sums="dc1e5abc093b11f120e4eac94a7f78aa clamav-0.97.4.tar.gz
-db77dd9d975b9d3d525c44e50fb202b9 clamd.initd
-567bc32b657dd7031b9b7beaa946203a clamd.confd
-daff7838573513114a6404878ccac225 freshclam.initd
+b4523253843761d7a7e5fa765b3fb2b9 clamd.initd
+e8a03fad6ce603631e8fe71a24d387c6 clamd.confd
+401fe30d9af2fea3151f938b26ff01c0 freshclam.initd
e48466ddfb56f66c623b83e58777b778 freshclam.confd
0d08fd29656bd4b018ecf8ce9706ac55 clamav-0.95.1-nls.patch
ae1e48ab56a0fff1acdde023c1f6f350 clamd.logrotate
diff --git a/main/clamav/clamav-daemon.post-install b/main/clamav/clamav-daemon.post-install
deleted file mode 100644
index e40badb09b..0000000000
--- a/main/clamav/clamav-daemon.post-install
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-chown -R clamav:clamav /var/run/clamav /var/log/clamav
diff --git a/main/clamav/clamav-daemon.pre-install b/main/clamav/clamav-daemon.pre-install
index 59ac60a44d..201184a29f 100644
--- a/main/clamav/clamav-daemon.pre-install
+++ b/main/clamav/clamav-daemon.pre-install
@@ -1,4 +1,5 @@
#!/bin/sh
-adduser -H -s /bin/false -D clamav 2>/dev/null
+addgroup -S clamav 2>/dev/null
+adduser -S -h /var/lib/clamav -H -s /bin/false -D -G clamav clamav 2>/dev/null
exit 0
diff --git a/main/clamav/clamav-db.post-install b/main/clamav/clamav-db.post-install
deleted file mode 100644
index b43342f31a..0000000000
--- a/main/clamav/clamav-db.post-install
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-chown -R clamav:clamav /var/lib/clamav /var/run/clamav /var/log/clamav
diff --git a/main/clamav/clamd.confd b/main/clamav/clamd.confd
index bc8072aead..bdf73b0fb4 100644
--- a/main/clamav/clamd.confd
+++ b/main/clamav/clamd.confd
@@ -4,3 +4,6 @@ CLAMD_NICELEVEL=0
# make sure we also start freshclam
# comment out if you dont want start freshclam
rc_need="freshclam"
+
+# timeout for the database download
+FRESHCLAM_TIMEOUT=120
diff --git a/main/clamav/clamd.initd b/main/clamav/clamd.initd
index 0e17010247..10c9c6db16 100644..100755
--- a/main/clamav/clamd.initd
+++ b/main/clamav/clamd.initd
@@ -20,6 +20,24 @@ start() {
if [ -S "${clamd_socket:=/tmp/clamd}" ]; then
rm -f ${clamd_socket}
fi
+
+ local dbdir=$(awk '$1 == "DatabaseDirectory" { print $2 }' $CONF)
+ local timout=${FRESHCLAM_TIMEOUT:-120}
+ local cvd="${dbdir:-/var/lib/clamav}"/main.cvd
+
+ if ! [ -e "$cvd" ]; then
+ ebegin "Waiting for clamav database download"
+ while ! [ -e "$cvd" ]; do
+ timeout=$(( $timeout - 1 ))
+ if [ $timeout -eq 0 ]; then
+ eend 1 "Timed out"
+ return 1
+ fi
+ sleep 1
+ done
+ eend 0
+ fi
+
ebegin "Starting ${NAME}"
start-stop-daemon --start --quiet \
--nicelevel ${CLAMD_NICELEVEL:-0} \
@@ -39,7 +57,7 @@ reload() {
eend 1 "${NAME} is not started"
return 1
fi
- start-stop-daemon --stop --oknodo --signal HUP \
+ start-stop-daemon --stop --signal HUP \
--exec /usr/sbin/clamd
eend $?
}
diff --git a/main/clamav/freshclam.initd b/main/clamav/freshclam.initd
index 2efd2e48d7..be8aa16e49 100644
--- a/main/clamav/freshclam.initd
+++ b/main/clamav/freshclam.initd
@@ -3,8 +3,8 @@
extra_started_commands="reload"
extra_commands="logfix"
-NAME=freshclam
-DAEMON=/usr/bin/$NAME
+command=/usr/bin/freshclam
+pidfile=/var/run/clamav/freshclam.pid
CONF=/etc/clamav/freshclam.conf
depend() {
@@ -16,30 +16,23 @@ start() {
ebegin "Starting freshclam"
start-stop-daemon --start --quiet \
--nicelevel ${FRESHCLAM_NICELEVEL:-0} \
- --exec /usr/bin/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
+ --exec $command \
+ -- \
+ --daemon \
+ --pid=$pidfile
+ eend $?
}
stop() {
- ebegin "Stopping ${NAME}"
- start-stop-daemon --stop --quiet --name ${NAME}
+ ebegin "Stopping freshclam"
+ start-stop-daemon --stop --quiet --pidfile $pidfile
eend $?
}
reload() {
- ebegin "Reloading ${NAME}"
- if ! service_started "${NAME}" ; then
- eend 1 "${NAME} is not started"
- return 1
- fi
- start-stop-daemon --stop --oknodo --signal HUP \
- --exec ${DAEMON} --name $NAME
+ ebegin "Reloading freshclam"
+ start-stop-daemon --stop --signal HUP \
+ --exec $command --pidfile $pidfile
eend $?
}
diff --git a/main/clamav/freshclam.pre-install b/main/clamav/freshclam.pre-install
new file mode 100644
index 0000000000..201184a29f
--- /dev/null
+++ b/main/clamav/freshclam.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S clamav 2>/dev/null
+adduser -S -h /var/lib/clamav -H -s /bin/false -D -G clamav clamav 2>/dev/null
+exit 0