summaryrefslogtreecommitdiff
path: root/packages/clamav/files/clamav-daemon.init
diff options
context:
space:
mode:
authorJamie Lenehan <lenehan@twibble.org>2006-09-13 23:16:01 +0000
committerJamie Lenehan <lenehan@twibble.org>2006-09-13 23:16:01 +0000
commit506afe9fc6e1a8c2edfad0702797f3a66b8bb605 (patch)
tree867fc2457ada654401fd05f5f047928e5086b65e /packages/clamav/files/clamav-daemon.init
parent672d04d32f12b96b47dd6d16293f7ff8e96c3d97 (diff)
clamav: New package for the CLAM anti-virus toolkit for UNIX. It
includes a multi-threaded daemon, a command line scanner, a tool for automatic updating via Internet and a shared library implementation for the scanner. Tested on sh4 and i486.
Diffstat (limited to 'packages/clamav/files/clamav-daemon.init')
-rw-r--r--packages/clamav/files/clamav-daemon.init75
1 files changed, 75 insertions, 0 deletions
diff --git a/packages/clamav/files/clamav-daemon.init b/packages/clamav/files/clamav-daemon.init
new file mode 100644
index 0000000000..a70e14f3f4
--- /dev/null
+++ b/packages/clamav/files/clamav-daemon.init
@@ -0,0 +1,75 @@
+#! /bin/sh
+# This is a modified version of the debian clamav-daemon init script
+set -e
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/clamd
+NAME="clamd"
+DESC="ClamAV daemon"
+CLAMAVCONF=/etc/clamd.conf
+
+[ -x "$DAEMON" ] || exit 0
+[ -r /etc/default/clamav-daemon ] && . /etc/default/clamav-daemon
+
+if [ ! -f "$CLAMAVCONF" ]; then
+ echo "There is no configuration file for $DESC."
+ exit 0;
+fi
+if grep -q "^Example" $CLAMAVCONF; then
+ echo "$DESC is not configured. Please edit $CLAMAVCONF"
+ exit 0
+fi
+
+THEPIDFILE="`grep ^PidFile $CLAMAVCONF | awk '{print $2}'`"
+[ -e "$THEPIDFILE" ] && PID=`cat $THEPIDFILE`
+[ "$PID" = '1' ] && unset PID
+
+# Make sure dirs exist and are correct
+for i in /var/run/clamav /var/log/clamav /var/lib/clamav
+do
+ [ ! -d $i ] && mkdir -p $i && chown clamav:clamav $i
+done
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ start-stop-daemon --oknodo -S -x $DAEMON
+ echo "$NAME"
+ ;;
+
+ stop)
+ echo -n "Stopping $DESC: "
+ if [ -n "$PID" ]; then
+ kill -15 -"$PID"
+ sleep 1
+ if kill -0 "$PID" 2>/dev/null; then
+ echo -n "Waiting . "
+ cnt=0
+ while kill -0 "$PID" 2>/dev/null; do
+ cnt=`expr "$cnt" + 1`
+ if [ "$cnt" -gt 60 ]; then
+ echo -n " Failed.. "
+ kill -9 -"$PID"
+ break
+ fi
+ sleep 2
+ echo -n ". "
+ done
+ fi
+ else
+ start-stop-daemon -o -K -q -p $THEPIDFILE
+ fi
+ echo "$NAME"
+ ;;
+
+ restart|force-reload)
+ $0 stop
+ $0 start
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0