diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | etc/systemd/system/freshclam.service | 15 | ||||
-rw-r--r-- | etc/tmpfiles.d/freshclam.conf | 1 | ||||
-rwxr-xr-x | usr/local/bin/freshclam-die | 16 | ||||
-rwxr-xr-x | usr/local/bin/freshclam-start | 3 |
5 files changed, 41 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6871f7 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +## Scope + +This contains all sorts of systemd units I have written for whatever purpose. +Sometimes just for lack of alternatives :) e.g. freshclam? No reason for it on +Debian, but on Fedora. KVM machines? libvirtd-guests is great, but not always +wanted. diff --git a/etc/systemd/system/freshclam.service b/etc/systemd/system/freshclam.service new file mode 100644 index 0000000..735d817 --- /dev/null +++ b/etc/systemd/system/freshclam.service @@ -0,0 +1,15 @@ +[Unit] +Description=ClamAV database updater (freshclam) +Wants=network.target +Requires=network.target +After=network.target + +[Service] +Type=forking +ExecStart=/usr/local/bin/freshclam-start +ExecStop=/usr/local/bin/freshclam-die +TimeoutStartSec=10s +TimeoutStopSec=30s + +[Install] +WantedBy=multi-user.target diff --git a/etc/tmpfiles.d/freshclam.conf b/etc/tmpfiles.d/freshclam.conf new file mode 100644 index 0000000..62e8d5d --- /dev/null +++ b/etc/tmpfiles.d/freshclam.conf @@ -0,0 +1 @@ +D /run/freshclam 0750 clamupdate clamupdate - diff --git a/usr/local/bin/freshclam-die b/usr/local/bin/freshclam-die new file mode 100755 index 0000000..0cd3e4b --- /dev/null +++ b/usr/local/bin/freshclam-die @@ -0,0 +1,16 @@ +#!/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 new file mode 100755 index 0000000..e8096d2 --- /dev/null +++ b/usr/local/bin/freshclam-start @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/freshclam --daemon --checks=4 --pid="/run/freshclam/freshclam.pid" |