birdcam-pi/check_playerproc.sh

44 lines
1.0 KiB
Bash
Raw Normal View History

2021-09-19 20:24:31 +02:00
#!/bin/sh
gpiocmd="$(command -v gpio)"
if [ -z "$gpiocmd" ]; then
echo "Command gpio missing, try to install ..."
echo "Check internet connection ..."
2021-09-21 23:09:37 +02:00
pingserver="raspbian.raspberrypi.org" ### var: pingcheck destination
2021-09-19 20:24:31 +02:00
if ! ping -q -c1 $pingserver>/dev/null; then
echo "No internet connection ..."
exit 0
fi
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
rm wiringpi-latest.deb
# sudo apt update; sudo apt -y install wiringpi
gpiocmd="$(command -v gpio)"
if [ -z "$gpiocmd" ]; then
echo "cannot install wiringpi, exiting ..."
exit 0
fi
fi
2021-09-21 23:05:25 +02:00
player="vlc" ### var: player process
2021-09-21 23:09:37 +02:00
gpiopin_led_b="28" ### var: gpio led blue
2021-09-19 20:24:31 +02:00
$gpiocmd mode $gpiopin_led_b out
$gpiocmd write $gpiopin_led_b 0
while true; do
2021-09-22 04:40:47 +02:00
if [ -n "$(pgrep $player)" ]; then
2021-09-19 20:24:31 +02:00
$gpiocmd write $gpiopin_led_b 1
sleep 0.1
$gpiocmd write $gpiopin_led_b 0
fi
sleep 5
done