Skip to content
Snippets Groups Projects
Commit b5d8f788 authored by Bob Mottram's avatar Bob Mottram
Browse files

Check if device exists

parent 84627d48
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment