2019-10-26 20:05:31 +03:00
|
|
|
#!/bin/bash
|
|
|
|
PATH=/usr/bin
|
|
|
|
|
|
|
|
alert="Signature detected: $CLAM_VIRUSEVENT_VIRUSNAME in $CLAM_VIRUSEVENT_FILENAME"
|
|
|
|
|
|
|
|
# Send the alert to systemd logger if exist, othewise to /var/log
|
|
|
|
if [[ -z $(command -v systemd-cat) ]]; then
|
2022-09-16 20:08:03 +03:00
|
|
|
echo "$(date) - $alert" >>/var/log/clamav/infected.log
|
2019-10-26 20:05:31 +03:00
|
|
|
else
|
2022-09-16 20:08:03 +03:00
|
|
|
# as "emerg", this could cause your DE to show a visual alert. Happen in Plasma. but the next visual alert is much nicer
|
|
|
|
echo "$alert" | /usr/bin/systemd-cat -t clamav -p emerg
|
2019-10-26 20:05:31 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
#send an alrt to all graphical user
|
2022-09-16 20:08:03 +03:00
|
|
|
XUSERS=($(who | awk '{print $1}' | sort -u))
|
2019-10-26 20:05:31 +03:00
|
|
|
|
|
|
|
for XUSER in $XUSERS; do
|
2022-09-16 20:08:03 +03:00
|
|
|
NAME=(${XUSER/(/ })
|
|
|
|
DISPLAY=${NAME[1]/)/}
|
|
|
|
DBUS_ADDRESS=unix:path=/run/user/$(id -u ${NAME[0]})/bus
|
|
|
|
echo "run $NAME - $DISPLAY - $DBUS_ADDRESS -" >>/tmp/testlog
|
|
|
|
/usr/bin/sudo -u ${NAME[0]} DISPLAY=${DISPLAY} \
|
|
|
|
DBUS_SESSION_BUS_ADDRESS=${DBUS_ADDRESS} \
|
|
|
|
PATH=${PATH} \
|
|
|
|
/usr/bin/notify-send -i dialog-warning "clamAV" "$alert"
|
2019-10-26 20:05:31 +03:00
|
|
|
done
|