From 7a325ec7deccd573ed1c741c44bc81c7c2e6b249 Mon Sep 17 00:00:00 2001 From: "Ruben Hartenstein (PEA4-Fe)" Date: Fri, 5 Mar 2021 13:21:11 +0000 Subject: [PATCH] Adjust usb-detect for Raspberry Pi --- usb-detect/10-usb-detect.rules | 2 +- usb-detect/usb-detect.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/usb-detect/10-usb-detect.rules b/usb-detect/10-usb-detect.rules index 98c55a8..0e3f52a 100644 --- a/usb-detect/10-usb-detect.rules +++ b/usb-detect/10-usb-detect.rules @@ -1 +1 @@ -ACTION=="add", KERNEL=="sd[b-z]1", SUBSYSTEM=="block", RUN+="/home/kske/usb.sh" +ACTION=="add", KERNEL=="sd[a-z]1", SUBSYSTEM=="block", RUN+="/home/pi/git/opus-data/usb-detect/usb-detect.sh" diff --git a/usb-detect/usb-detect.sh b/usb-detect/usb-detect.sh index bd5c921..a753ceb 100755 --- a/usb-detect/usb-detect.sh +++ b/usb-detect/usb-detect.sh @@ -11,7 +11,10 @@ LOGFILE=/var/log/usb-detect.log exec &>> $LOGFILE # Processing function (file name is passed as parameter) -PROCESS_FUNC=cat +PROC_FUNC="Rscript /home/pi/git/opus-data/OpusData.R" + +# Directory inside which the processing function is run +PROC_DIR="/home/pi/git/opus-data/" echo "USB device detected at $DEVNAME" @@ -30,7 +33,10 @@ for f in $MOUNTPOINT/*.[0-9] do found=1 echo "Processing $f..." - $PROCESS_FUNC $f + ( + cd $PROC_DIR + $PROC_FUNC $f + ) || echo "Failed executing $PROC_FUNC $f in $PROC_DIR" echo "Removing $f..." rm $f done