Posts Tagged ‘freshclam’
This simple init script is for daemonize freshclam (Clamd Antivirus Updater) on RHEL or CentOS.
Create a brand new file called freshclam in /etc/init.d/ with the following content :
#!/bin/sh
#
# Startup script for the Clam AntiVirus Update Tool
#
# chkconfig: 2345 62 38
# description: freshclam is an update daemon for Clam AV database.
#
# processname: freshclam
# config: /etc/freshclam.conf
# pidfile: /var/run/clamav/freshclam.pid
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================
# Source function library
. /etc/init.d/functions
# Get network config
. /etc/sysconfig/network
test -f /etc/freshclam.conf || exit 0
RETVAL=0
start() {
echo -n $"Starting freshclam: "
daemon /usr/bin/freshclam -d -p /var/run/clamav/freshclam.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
return $RETVAL
}
stop() {
echo -n $"Stopping freshclam: "
killproc freshclam
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading DB: "
killproc freshclam -ALRM
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status freshclam
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/freshclam ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac
exit $?
Assign to it corect ownership and permission :
chown root:root /etc/init.d/freshclam chmod 755 /etc/init.d/freshclam
Test if the scripts works correctly on your system with the following commands :
service freshclam start service freshclam stop service freshclam restart service freshclam reload service freshclam condstart
If all works fine you should add freshclam to the automatic startup services with the following command :
chkconfig freshclam on
Hope this help
Bye
Riccardo
Print This Post























