git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/usr/local/sbin/freshclamd
blob: 1dd474dbca272e3d8f3996f3ce1c61aac66206f1 (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
#!/bin/sh
FCPIDF="/run/freshclam/freshclam.pid"

fresh_start() {
	/usr/bin/freshclam --daemon --checks=4 --pid="/run/freshclam/freshclam.pid"
}

fresh_stop() {
	if [ ! -e "$FCPIDF" ];then
		pidof "$(which freshclam)" >/dev/null&&exit 1
	else
		FCPID="$(cat "$FCPIDF")"
		[ -z "$FCPID" ]&&exit 2
		if ps -p "$FCPID" >/dev/null 2>&1; then
			kill "$FCPID" >/dev/null 2>&1
			sleep 1
			ps -p "$FCPID" >/dev/null 2>&1||exit 0
			sleep 10
			kill -9 "$FCPID" >/dev/null 2>&1
			sleep 2
			ps -p "$FCPID" >/dev/null 2>&1&&exit 4||exit 0
		else
			rm -f "$FCPIDF" >/dev/null 2>&1||exit 3
		fi
	fi
}

case "$1" in
	"start") fresh_start;;
	"stop") fresh_stop;;
	"restart") fresh_stop&&fresh_start;;
	*) echo "USAGE: $(basename "$0") start|stop|restart" >&2&&exit 1;;
esac