diff --git a/src/freedombone-notification b/src/freedombone-notification index 09981542e1ee6975e4e8d65a68f1308ffce7cc3e..5ecd09db7d8a63f4f38366a8df9f9eeabac36a8f 100755 --- a/src/freedombone-notification +++ b/src/freedombone-notification @@ -76,21 +76,19 @@ if [ ! "$ADMIN_EMAIL_ADDRESS" ]; then ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME} fi -canary_subject=$'USB canary' notification_image_filename=/tmp/notification.jpg -image_extra='' -if [[ "$SUBJECT" == *"$canary_subject"* ]]; then +if [[ "$SUBJECT" == *"USB"* ]]; then if [ -f /usr/bin/fswebcam ]; then # Preferentially use a secondary camera which can # be set up from an appropriate viewing angle - if [ -f /dev/video1 ]; then + if [ -e /dev/video1 ]; then if [ -f $notification_image_filename ]; then rm $notification_image_filename fi fswebcam -d /dev/video1 --jpeg 50 -D 1 $notification_image_filename else # Otherwise use the built-in camera - if [ -f /dev/video0 ]; then + if [ -e /dev/video0 ]; then if [ -f $notification_image_filename ]; then rm $notification_image_filename fi @@ -99,7 +97,10 @@ if [[ "$SUBJECT" == *"$canary_subject"* ]]; then fi fi fi + +image_extra='' if [ -f $notification_image_filename ]; then + # extra option for mail command image_extra="-A $notification_image_filename" # If syncthing is installed then copy the image to the admin