From 3be351091603da3a5710255d070104eca57d6923 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Fri, 15 May 2020 19:50:59 +0200 Subject: [PATCH] clamav-daemon.service fix and clamav sock fix --- src/deb/vesta/postinst | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/deb/vesta/postinst b/src/deb/vesta/postinst index 91047359..e2f64c33 100755 --- a/src/deb/vesta/postinst +++ b/src/deb/vesta/postinst @@ -76,20 +76,33 @@ if [ "$check_cron" -eq 0 ]; then crontab -l | { cat; echo "10 2 * * 6 sudo find /home/*/tmp/ -type f -mtime +5 -exec rm {} \;"; } | crontab - fi -if [ ! -f "/usr/local/vesta/data/upgrades/change-clamav-socket" ]; then - touch /usr/local/vesta/data/upgrades/change-clamav-socket - check_grep=$(grep -c '/var/lib/clamav/clamd.sock' /etc/clamav/clamd.conf) +# make sure clamav-daemon.service has mkdir fix +if [ -f "/lib/systemd/system/clamav-daemon.service" ]; then + check_grep=$(grep -c 'mkdir' /lib/systemd/system/clamav-daemon.service) if [ "$check_grep" -eq 0 ]; then - touch /var/lib/clamav/clamd.sock - chown clamav:clamav /var/lib/clamav/clamd.sock - sed -i "s#/var/run/clamav/clamd.ctl#/var/lib/clamav/clamd.sock#g" /etc/clamav/clamd.conf - sed -i "s#/var/run/clamav/clamd.ctl#/var/lib/clamav/clamd.sock#g" /etc/exim4/exim4.conf.template + echo "=== patching clamav-daemon.service" + exec_pre1='ExecStartPre=-/bin/mkdir -p /var/run/clamav' + exec_pre2='ExecStartPre=-/bin/chown -R clamav:clamav /var/run/clamav' + sed -i "s|\[Service\]|[Service]\n$exec_pre1\n$exec_pre2|g" /lib/systemd/system/clamav-daemon.service + systemctl daemon-reload systemctl restart clamav-daemon systemctl restart clamav-freshclam - systemctl restart exim4 fi fi +# reverting to default clamd sock +if [ ! -f "/usr/local/vesta/data/upgrades/change-clamav-socket-v2" ]; then + touch /usr/local/vesta/data/upgrades/change-clamav-socket-v2 + sed -i "s#/var/lib/clamav/clamd.sock#/var/run/clamav/clamd.ctl#g" /etc/clamav/clamd.conf + sed -i "s#/var/lib/clamav/clamd.sock#/var/run/clamav/clamd.ctl#g" /etc/exim4/exim4.conf.template + sed -i "s#/var/lib/clamav/clamd.sock#/var/run/clamav/clamd.ctl#g" /lib/systemd/system/clamav-daemon.socket + sed -i "s#=/run/clamav/clamd.ctl#=/var/run/clamav/clamd.ctl#g" /lib/systemd/system/clamav-daemon.socket + systemctl daemon-reload + systemctl restart clamav-daemon + systemctl restart clamav-freshclam + systemctl restart exim4 +fi + # Run custom triggers if [ -x "/root/vesta-patch.sh" ]; then /root/vesta-patch.sh