some fixes from shellcheck
This commit is contained in:
parent
5c88fc2203
commit
dc15b6fe01
10
automount.sh
10
automount.sh
|
@ -15,29 +15,29 @@ while true; do
|
||||||
dev_plug_state="$(lsblk | grep $device)"
|
dev_plug_state="$(lsblk | grep $device)"
|
||||||
dev_mount_state="$(mount | grep $device)"
|
dev_mount_state="$(mount | grep $device)"
|
||||||
|
|
||||||
if [ ! -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
if [ -n "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
||||||
echo "Mount /dev/$device on $mountpoint with options $mountoptions"
|
echo "Mount /dev/$device on $mountpoint with options $mountoptions"
|
||||||
sudo mount /dev/$device $mountpoint -o $mountoptions
|
sudo mount /dev/$device $mountpoint -o $mountoptions
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
|
|
||||||
elif [ ! -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
elif [ -n "$dev_plug_state" ] && [ -n "$dev_mount_state" ]; then
|
||||||
echo "/dev/$device is already mounted on $mountpoint"
|
echo "/dev/$device is already mounted on $mountpoint"
|
||||||
|
|
||||||
elif [ -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
elif [ -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
||||||
echo "/dev/$device not plugged in and is not mounted!"
|
echo "/dev/$device not plugged in and is not mounted!"
|
||||||
|
|
||||||
elif [ -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
elif [ -z "$dev_plug_state" ] && [ -n "$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"
|
||||||
|
|
||||||
playershstat="$(pgrep $playersh)"
|
playershstat="$(pgrep $playersh)"
|
||||||
if [ ! -z "$playershstat" ]; then
|
if [ -n "$playershstat" ]; then
|
||||||
echo "Terminating $playersh"
|
echo "Terminating $playersh"
|
||||||
pkill $playersh
|
pkill $playersh
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
playerstat="$(pgrep $player)"
|
playerstat="$(pgrep $player)"
|
||||||
if [ ! -z "$playerstat" ]; then
|
if [ -n "$playerstat" ]; then
|
||||||
echo "Terminating $player"
|
echo "Terminating $player"
|
||||||
pkill $player
|
pkill $player
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
|
|
|
@ -33,7 +33,7 @@ $gpiocmd write $gpiopin_led_b 0
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
if [ ! -z "$(pgrep $player)" ]; then
|
if [ -n "$(pgrep $player)" ]; then
|
||||||
$gpiocmd write $gpiopin_led_b 1
|
$gpiocmd write $gpiopin_led_b 1
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
$gpiocmd write $gpiopin_led_b 0
|
$gpiocmd write $gpiopin_led_b 0
|
||||||
|
|
|
@ -45,7 +45,7 @@ while true; do
|
||||||
$gpiocmd mode $gpiopin_led_r out
|
$gpiocmd mode $gpiopin_led_r out
|
||||||
$gpiocmd write $gpiopin_led_g 1
|
$gpiocmd write $gpiopin_led_g 1
|
||||||
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
||||||
counter="$(($counter + 1))"
|
counter="$((counter + 1))"
|
||||||
#echo "$counter"
|
#echo "$counter"
|
||||||
sleep $buttonpolling
|
sleep $buttonpolling
|
||||||
done
|
done
|
||||||
|
@ -61,7 +61,7 @@ while true; do
|
||||||
$gpiocmd mode $gpiopin_led_r out
|
$gpiocmd mode $gpiopin_led_r out
|
||||||
$gpiocmd write $gpiopin_led_g 1
|
$gpiocmd write $gpiopin_led_g 1
|
||||||
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
||||||
counter="$(($counter + 1))"
|
counter="$((counter + 1))"
|
||||||
#echo "$counter"
|
#echo "$counter"
|
||||||
sleep $buttonpolling
|
sleep $buttonpolling
|
||||||
done
|
done
|
||||||
|
@ -77,7 +77,7 @@ while true; do
|
||||||
$gpiocmd mode $gpiopin_led_r out
|
$gpiocmd mode $gpiopin_led_r out
|
||||||
$gpiocmd write $gpiopin_led_g 1
|
$gpiocmd write $gpiopin_led_g 1
|
||||||
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
|
||||||
counter="$(($counter + 1))"
|
counter="$((counter + 1))"
|
||||||
#echo "$counter"
|
#echo "$counter"
|
||||||
sleep $buttonpolling
|
sleep $buttonpolling
|
||||||
done
|
done
|
||||||
|
|
|
@ -37,7 +37,7 @@ while true; do
|
||||||
if [ -z "$mountstat" ]; then
|
if [ -z "$mountstat" ]; then
|
||||||
folder="$folderint"
|
folder="$folderint"
|
||||||
|
|
||||||
elif [ ! -z "$mountstat" ]; then
|
elif [ -n "$mountstat" ]; then
|
||||||
folder="$folderext"
|
folder="$folderext"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -37,11 +37,11 @@ streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream
|
||||||
randomvideosh="/home/pi/birdcam/randomvideo.sh" ### var: path to random video script
|
randomvideosh="/home/pi/birdcam/randomvideo.sh" ### var: path to random video script
|
||||||
randomvideoproc="randomvideo.sh" ### var: name of process for random video script
|
randomvideoproc="randomvideo.sh" ### var: name of process for random video script
|
||||||
|
|
||||||
if [ ! -z "$(pgrep $playerproc)" ]; then
|
if [ -n "$(pgrep $playerproc)" ]; then
|
||||||
pkill $playerproc
|
pkill $playerproc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$(pgrep $randomvideoproc)" ]; then
|
if [ -n "$(pgrep $randomvideoproc)" ]; then
|
||||||
pkill $randomvideoproc
|
pkill $randomvideoproc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue