I had a few issues getting HAVP to work thanks to permission issues (my misconfiguration) which were quickly sorted out by Hege and karesmakro.
I thought I'd post this Slackware-rc style script if anyone needs it. If you have improvements, and I'm sure some will, please add them.
Hege, feel free to include it with the next HAVP release or move it to the Documents and FAQ section Please note the use of chown to parent directory and the importance of it being done AFTER mounting the RAMdisk and BEFORE starting HAVP.
If you're using a directory on your hard disk as TEMPDIR; remove the mount and umount commands and change $MNTDIR to match your TEMPDIR in havp.conf
Hell, you get the point.
You will need to change $USERID below to match your havp/clamav/whatever uid HAVP is running as.
Please read and edit to your needs before running it.
This script comes with no warranty. Use at your own risk.Code:
#!/bin/sh
#
# Create RAM-fs and start HAVP HTTP AV proxy
#
# Specify paths to binaries and configuration files
HAVP="/usr/local/sbin/havp" #Can also use `which havp` on most UNIX's
CONF="/usr/local/etc/havp/havp.config" #Change if config is someplace else
SWITCHBIN="-c" #HAVP conf options
SWITCHMNT="-t ext3 -o mand" #Mount options
MNTDIR="/mnt/memory/clamav" #The TEMPDIR in havp.config
USER="clamav" #We use clamav's UID/GID for HAVP and all installed AV scannners
USERID="210" #Look in /etc/passwd for the USER listed above
# Create ext3 FS in RAM assuming lilo loads RAM disks. See http://www.vanemery.com/Linux/Ramdisk/ramdisk.html
# Why ram0?
# RedHat lists 19 but only the first 15 work.
# ls -l /dev/ram* - Slackware loads 15 RAMdisks. The first will do just fine.
# Check if HAVP binary and config files exist
if [ ! -x $HAVP ]; then
echo "HAVP binary not found or not executable!"
echo "Cannot start, exiting.."
exit 1
fi
if [ ! -f $CONF ]; then
echo "HAVP config file missing.. exiting!"
exit 1
fi
havp_start() {
/usr/bin/pgrep -U $USERID havp 2>/dev/null
if [ $? = 1 ]; then
/sbin/umount $MNTDIR 2>/dev/null # Just in case this script is not run on boot
/sbin/mkfs.ext3 -q /dev/ram0
/usr/bin/sleep 2 # Give it a few to settle down.
/sbin/mount $SWITCHMNT /dev/ram0 $MNTDIR 2>/dev/null
/usr/bin/chown -R $USER:$USER /mnt/memory # chown a dir up to remove any permission issues. strace to debug mkdir errors
/usr/bin/chown -R $USER:$USER /var/run/havp # check havp.config for PIDFILE
$HAVP $SWITCHBIN $CONF
else
echo "HAVP is already running."
exit 1
fi
}
havp_stop() {
/usr/bin/pkill -U $USERID havp
/sbin/umount $MNTDIR 2>/dev/null # Unmount HAVP's TEMPDIR
if [ $? = 1 ]; then
echo "HAVP is not running."
else
echo "Stopping HAVP."
fi
}
havp_restart() {
havp_stop
/usr/bin/sleep 5
havp_start
}
case "$1" in
'start')
havp_start
;;
'stop')
havp_stop
;;
'restart')
havp_restart
;;
*)
echo "usage $0 start|stop|restart"
esac
#EOF