-#!/bin/sh
-set -o errexit
-
-# First argument of this script is the package name
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-# Applying patches (if any)
-apply_patches ${1}
-
-groupadd -f clamav
-hv_useradd -g clamav -s /bin/false -c Clam-AntiVirus clamav
-
-cd ${LFS_TMP}/${1}
-SENDMAIL="/usr/sbin/sendmail" ./configure \
- --prefix=/usr \
- --sysconfdir=/etc \
- --with-dbdir=/srv/clamav \
- --enable-milter
-make
-make install
-touch /var/log/clamd.log
-chmod 600 /var/log/clamd.log
-chown clamav /var/log/clamd.log
-touch /var/log/freshclam.log
-chmod 600 /var/log/freshclam.log
-chown clamav /var/log/freshclam.log
-
-# Addition to /etc/fcron/fcrontab to update virus database
-string_add "Update the Clam AV database every hour" /etc/fcron/fcrontab
-string_add "&mail(false) 0 * * * * /usr/bin/freshclam --quiet" /etc/fcron/fcrontab
-
-# Configuration file
-cat > /etc/clamd.conf << "EOF"
+#!/bin/bash
+
+hvconfig_pre()
+{
+ groupadd -f clamav
+ hv_useradd -g clamav -s /bin/false -c Clam-AntiVirus clamav
+
+ # Is this really necessary?
+ export SENDMAIL="/usr/sbin/sendmail"
+
+ CONFIGURE_OPTS="\
+ ${CONFIGURE_OPTS} \
+ --with-dbdir=/srv/clamav \
+ --enable-milter"
+}
+
+hvconfig_post()
+{
+ unset SENDMAIL
+}
+
+hvbuild_post()
+{
+ install -v -m644 ${SCRDIR}/misc/freshclam /etc/fcron/fcron.d
+
+ touch /var/log/clamd.log
+ chmod 600 /var/log/clamd.log
+ chown clamav /var/log/clamd.log
+ touch /var/log/freshclam.log
+ chmod 600 /var/log/freshclam.log
+ chown clamav /var/log/freshclam.log
+
+ # Configuration file
+ cat > /etc/clamd.conf << "EOF"
# clamd.conf
# Configuration file for the Clam AV daemon
MaxFiles 0
EOF
-
-# Freshclam configuration file
-cat > /etc/freshclam.conf << "EOF"
+ # Freshclam configuration file
+ cat > /etc/freshclam.conf << "EOF"
# freshclam.conf
# Configuration file for Freshclam
#OnErrorExecute command
EOF
-# Create the DB directory
-mkdir -p /srv/clamav
-chown clamav:clamav /srv/clamav
-chmod 755 /srv/clamav
-
-# Create the run directory
-mkdir -p /var/run/clamav
-chown clamav:clamav /var/run/clamav
-chmod 755 /var/run/clamav
+ # Create the DB directory
+ mkdir -p /srv/clamav
+ chown clamav:clamav /srv/clamav
+ chmod 755 /srv/clamav
-# Bootscript
-install -v -m740 ${SCRDIR}/bootscripts/clamav /etc/rc.d/init.d
+ # Create the run directory
+ mkdir -p /var/run/clamav
+ chown clamav:clamav /var/run/clamav
+ chmod 755 /var/run/clamav
-# script-name start stop
-bootscript_add_rc3 clamav 55 35
+ # Bootscript
+ install -v -m740 ${SCRDIR}/bootscripts/clamav /etc/rc.d/init.d
-exit $?
+ # script-name start stop
+ bootscript_add_rc3 clamav 55 35
+}