diff options
-rw-r--r-- | etc/systemd/system/freshclam.service | 4 | ||||
-rwxr-xr-x | usr/local/bin/freshclam-die | 16 | ||||
-rwxr-xr-x | usr/local/bin/freshclam-start | 3 | ||||
-rwxr-xr-x | usr/local/sbin/freshclamd | 36 |
4 files changed, 38 insertions, 21 deletions
diff --git a/etc/systemd/system/freshclam.service b/etc/systemd/system/freshclam.service index 735d817..a14de83 100644 --- a/etc/systemd/system/freshclam.service +++ b/etc/systemd/system/freshclam.service @@ -6,8 +6,8 @@ After=network.target [Service] Type=forking -ExecStart=/usr/local/bin/freshclam-start -ExecStop=/usr/local/bin/freshclam-die +ExecStart=/usr/local/sbin/freshclamd start +ExecStop=/usr/local/sbin/freshclamd stop TimeoutStartSec=10s TimeoutStopSec=30s diff --git a/usr/local/bin/freshclam-die b/usr/local/bin/freshclam-die deleted file mode 100755 index 0cd3e4b..0000000 --- a/usr/local/bin/freshclam-die +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -FCPIDF="/run/freshclam/freshclam.pid" - -[ ! -e "$FCPIDF" ]&&exit 1 -FCPID="$(cat "$FCPIDF")" -[ -z "$FCPID" ]&&exit 2 -ps -p "$FCPID" >/dev/null 2>&1 -[ "$?" -ne 0 ]&&exit 3 -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 diff --git a/usr/local/bin/freshclam-start b/usr/local/bin/freshclam-start deleted file mode 100755 index e8096d2..0000000 --- a/usr/local/bin/freshclam-start +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/bin/freshclam --daemon --checks=4 --pid="/run/freshclam/freshclam.pid" 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 |