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