blob: a70e14f3f47cf9dad72cf277bc73bfe3eeb3034e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
|