add automounter and check for storage device
This commit is contained in:
parent
c8f0cc6164
commit
7ac3f78715
17
automount.sh
17
automount.sh
|
@ -1,8 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mountpoint="/media/video"
|
mountpoint="/media/video" ### var: mountpoint
|
||||||
mountoptions="ro"
|
mountoptions="ro" ### var: mountoptions
|
||||||
device="sda1"
|
device="sda1" ### var: mount device
|
||||||
|
player="randomvideo.sh" ### var: player process
|
||||||
|
|
||||||
if [ ! -d "$mountpoint" ]; then
|
if [ ! -d "$mountpoint" ]; then
|
||||||
sudo mkdir $mountpoint
|
sudo mkdir $mountpoint
|
||||||
|
@ -26,8 +27,18 @@ while true; do
|
||||||
|
|
||||||
elif [ -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
elif [ -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
||||||
echo "/dev/$device is not plugged in and is mounted on $mountpoint"
|
echo "/dev/$device is not plugged in and is mounted on $mountpoint"
|
||||||
|
|
||||||
|
playerstat="$(pgrep $player)"
|
||||||
|
|
||||||
|
if [ ! -z "$playerstat" ]; then
|
||||||
|
echo "Terminating $player"
|
||||||
|
pkill $player
|
||||||
|
echo "Done!"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Umounting $mountpoint"
|
echo "Umounting $mountpoint"
|
||||||
sudo umount $mountpoint
|
sudo umount $mountpoint
|
||||||
|
echo "Done!"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
folder="/home/pi/Video" ### var: path to video files
|
folderext="/media/video" ### var: path to videofiles on external device
|
||||||
|
folderint="/home/pi/Video" ### var: path to videofiles on sdcard storage
|
||||||
player="cvlc" ### var: player command
|
player="cvlc" ### var: player command
|
||||||
playerparam="--no-osd --play-and-exit" ### var: player parameters
|
playerparam="--no-osd --play-and-exit" ### var: player parameters
|
||||||
|
|
||||||
player_path="$(command -v $player)"
|
player_path="$(command -v $player)"
|
||||||
|
|
||||||
player_package="vlc" ### var: player apt package
|
player_package="vlc" ### var: player apt package
|
||||||
|
mountdevice="sda1" ### var: device for mediafiles
|
||||||
|
|
||||||
if [ -z "$player_path" ]; then
|
if [ -z "$player_path" ]; then
|
||||||
echo "Missing $player, try to install it ..."
|
echo "Missing $player, try to install it ..."
|
||||||
|
@ -29,12 +31,23 @@ if [ -z "$player_path" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
mountstat="$(mount | grep $mountdevice)"
|
||||||
|
|
||||||
|
if [ -z "$mountstat" ]; then
|
||||||
|
folder="$folderint"
|
||||||
|
|
||||||
|
elif [ ! -z "$mountstat" ]; then
|
||||||
|
folder="$folderext"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
||||||
|
|
||||||
while [ "$file" = "$oldfile" ]; do
|
while [ "$file" = "$oldfile" ]; do
|
||||||
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)"
|
||||||
done
|
done
|
||||||
|
|
||||||
oldfile="$file"
|
oldfile="$file"
|
||||||
$player $playerparam $file
|
$player $playerparam $file
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue