scripts
This commit is contained in:
		
							parent
							
								
									dcf7accac9
								
							
						
					
					
						commit
						386db9ba31
					
				
							
								
								
									
										1
									
								
								100-floppy-change.rules
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								100-floppy-change.rules
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					ACTION=="change", ATTRS{idVendor}=="057b", ATTRS{idProduct}=="0000", ENV{DISK_MEDIA_CHANGE}=="1", RUN+="/home/dietpi/floppy-ytube-player/media_change.sh $env{DEVNAME}"
 | 
				
			||||||
							
								
								
									
										26
									
								
								media_change.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								media_change.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					exec >> /home/dietpi/mount.log 2>&1
 | 
				
			||||||
 | 
					export LC_ALL=en_GB.utf-8
 | 
				
			||||||
 | 
					export LANG=en_GB.utf-8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "$(date) Start."
 | 
				
			||||||
 | 
					echo "$(date) Media change detected on device $1"
 | 
				
			||||||
 | 
					device=${1##*/}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					lsblk | grep $device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ $? -eq 0 ]; then
 | 
				
			||||||
 | 
					    echo "$(date) Device exists on machine."
 | 
				
			||||||
 | 
					    echo "$(date) Mounting device $1 to /mnt/floppy."
 | 
				
			||||||
 | 
					    /usr/bin/systemd-mount --umount /mnt/floppy
 | 
				
			||||||
 | 
					    echo "$(date) Floppy unmounted"
 | 
				
			||||||
 | 
					    /usr/bin/systemd-mount $1 /mnt/floppy
 | 
				
			||||||
 | 
					    echo "$(date) Floppy mounted"
 | 
				
			||||||
 | 
					    var=$(cat /mnt/floppy/diskplayer.contents)
 | 
				
			||||||
 | 
					    echo python3 /home/pi/pythonDiskPlayer/player.py \"$var\"
 | 
				
			||||||
 | 
					    runuser -l dietpi -c "python3 /home/dietpi/floppy-ytube-player/main.py \"$var\""
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo "$(date) Device does not exist on machine."
 | 
				
			||||||
 | 
					    runuser -l dietpi -c "python3 /home/dietpi/floppy-ytube-player/main.py stop"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					echo "$(date) End."
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user