From 6b9fea0f6966b4816fe5016493666d3e53fea08d Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Thu, 5 Jul 2018 21:04:33 +0200 Subject: Unification of scripts, move to sbin --- usr/local/sbin/freshclamd | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 usr/local/sbin/freshclamd (limited to 'usr/local/sbin') diff --git a/usr/local/sbin/freshclamd b/usr/local/sbin/freshclamd new file mode 100755 index 0000000..a3bc2b3 --- /dev/null +++ b/usr/local/sbin/freshclamd @@ -0,0 +1,36 @@ +#!/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 + [ "$?" -eq 0 ]&&exit 1 + else + FCPID="$(cat "$FCPIDF")" + [ -z "$FCPID" ]&&exit 2 + ps -p "$FCPID" >/dev/null 2>&1 + if [ "$?" -ne 0 ];then + rm -f "$FCPIDF" >/dev/null 2>&1 + [ "$?" -ne 0 ]&&exit 3 + else + 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 + 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 -- cgit v1.2.3