Browse Source

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

Bob Mottram 6 years ago
parent
commit
5aabd2c130
1 changed files with 11 additions and 1 deletions
  1. 11
    1
      src/freedombone-usb-canary

+ 11
- 1
src/freedombone-usb-canary View File

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