Follow up/solution: Have been tinkering the past few weeks to resolve the issue and finally struck gold! So, rather than outline all the failures, here's the solution (for me at least):
Comment out/remove the chown line as follows:
Code: Select all
LOG_FILE="/var/log/clamav/freshclam.log"
if [ ! -f "$LOG_FILE" ]; then
touch "$LOG_FILE"
chmod 644 "$LOG_FILE"
#chown qscand.qscand "$LOG_FILE"
fi
Then add this directly afterwards, so it will check the owner is qscand outside the logic check for the freshclam.log file existing:
Code: Select all
if [ `ls -l "$LOG_FILE" | awk '{print $3}'` != "qscand" ]; then
chown qscand.qscand "$LOG_FILE"
fi
Leave the rest in place as follows:
Code: Select all
/usr/bin/freshclam \
--quiet \
--datadir="/var/clamav" \
--log="$LOG_FILE" \
--log-verbose \
--daemon-notify="/etc/clamd.conf"
Here's the whole thing in one go:
Code: Select all
#!/bin/sh
### fix log file if needed
LOG_FILE="/var/log/clamav/freshclam.log"
if [ ! -f "$LOG_FILE" ]; then
touch "$LOG_FILE"
chmod 644 "$LOG_FILE"
fi
if [ `ls -l "$LOG_FILE" | awk '{print $3}'` != "qscand" ]; then
chown qscand.qscand "$LOG_FILE"
fi
/usr/bin/freshclam \
--quiet \
--datadir="/var/clamav" \
--log="$LOG_FILE" \
--log-verbose \
--daemon-notify="/etc/clamd.conf"