update to use BASE_DIR
This commit is contained in:
parent
0644e9f647
commit
3aac573369
@ -2,14 +2,14 @@
|
||||
|
||||
DEVICE_NAME=$1 # Get the device name passed from udev
|
||||
|
||||
LOGFILE="/home/dietpi/media_change.log"
|
||||
BASE_DIR="/home/dietpi"
|
||||
LOGFILE="$BASE_DIR/media_change.log"
|
||||
|
||||
# Check if the device exists in the fdisk -l output and log the result
|
||||
if sudo fdisk -l | grep -q "$DEVICE_NAME"; then
|
||||
echo "$(date) Floppy disk is present in device $DEVICE_NAME" >> $LOGFILE
|
||||
echo "$(date) Mounting device $1 to /mnt/floppy." >> $LOGFILE
|
||||
/usr/bin/systemd-mount --umount /mnt/floppy
|
||||
echo "$(date) Floppy unmounted" >> $LOGFILE
|
||||
/usr/bin/systemd-mount $1 /mnt/floppy
|
||||
echo "$(date) Floppy mounted" >> $LOGFILE
|
||||
|
||||
@ -17,10 +17,10 @@ if sudo fdisk -l | grep -q "$DEVICE_NAME"; then
|
||||
var=$(cat /mnt/floppy/diskplayer.contents)
|
||||
echo "$(date) Running Python script with argument: '$var'" >> $LOGFILE
|
||||
# Run the Python script and capture both stdout and stderr to the log
|
||||
/usr/bin/python3 /home/dietpi/floppy-ytube-player/main.py "$var" >> $LOGFILE 2>&1
|
||||
/usr/bin/python3 $BASE_DIR/floppy-ytube-player/main.py "$var" >> $LOGFILE 2>&1
|
||||
else
|
||||
echo "$(date): No floppy disk is present in device $DEVICE_NAME" >> $LOGFILE
|
||||
/usr/bin/systemd-mount --umount /mnt/floppy
|
||||
echo "$(date) Floppy unmounted" >> $LOGFILE
|
||||
/usr/bin/python3 /home/dietpi/floppy-ytube-player/main.py EJECT >> $LOGFILE 2>&1
|
||||
/usr/bin/python3 $BASE_DIR/floppy-ytube-player/main.py EJECT >> $LOGFILE 2>&1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user