From 5aabd2c130ec27130bda5a70084242500dde54cc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 13 May 2018 10:58:10 +0100 Subject: [PATCH] USB canary includes details of the device which was connected or disconnected --- src/freedombone-usb-canary | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/freedombone-usb-canary b/src/freedombone-usb-canary index a165fd40..88cdd9db 100755 --- a/src/freedombone-usb-canary +++ b/src/freedombone-usb-canary @@ -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