USB canary includes details of the device which was connected or disconnected

This commit is contained in:
Bob Mottram 2018-05-13 10:58:10 +01:00
parent 1b349bbd53
commit 5aabd2c130
1 changed files with 11 additions and 1 deletions

View File

@ -33,9 +33,19 @@ if [ ! -f /tmp/.upgrading ]; then
if [ "$UPTIME" -gt 240 ]; then
ADMIN_USER=$(grep 'Admin user' /root/${PROJECT_NAME}-completed.txt | awk -F ':' '{print $2}')
MY_EMAIL_ADDRESS=${ADMIN_USER}@$(cat /etc/hostname)
echo "USB device connected on ${DEVPATH}" | mail -s "${PROJECT_NAME} USB canary" "${MY_EMAIL_ADDRESS}"
# Which devices have changed?
devices_changed=
if [ -f /tmp/.usb_devices ]; then
lsusb -v > /tmp/.curr_usb_devices
devices_changed=$(diff /tmp/.curr_usb_devices /tmp/.usb_devices)
rm /tmp/.curr_usb_devices
fi
echo -e "USB device connected on ${DEVPATH}\\n\\n${devices_changed}" | mail -s "${PROJECT_NAME} USB canary" "${MY_EMAIL_ADDRESS}"
echo "${ACTION}" > /tmp/usb-canary
echo "${MY_EMAIL_ADDRESS}" >> /tmp/usb-canary
date >> /tmp/usb-canary
fi
fi
lsusb -v > /tmp/.usb_devices