some fixes from shellcheck

This commit is contained in:
mmaster 2021-09-22 04:40:47 +02:00
parent 5c88fc2203
commit dc15b6fe01
5 changed files with 12 additions and 12 deletions

View File

@ -15,29 +15,29 @@ while true; do
dev_plug_state="$(lsblk | 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"
sudo mount /dev/$device $mountpoint -o $mountoptions
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"
elif [ -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
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"
playershstat="$(pgrep $playersh)"
if [ ! -z "$playershstat" ]; then
if [ -n "$playershstat" ]; then
echo "Terminating $playersh"
pkill $playersh
echo "Done!"
fi
playerstat="$(pgrep $player)"
if [ ! -z "$playerstat" ]; then
if [ -n "$playerstat" ]; then
echo "Terminating $player"
pkill $player
echo "Done!"

View File

@ -33,7 +33,7 @@ $gpiocmd write $gpiopin_led_b 0
while true; do
if [ ! -z "$(pgrep $player)" ]; then
if [ -n "$(pgrep $player)" ]; then
$gpiocmd write $gpiopin_led_b 1
sleep 0.1
$gpiocmd write $gpiopin_led_b 0

View File

@ -45,7 +45,7 @@ while true; do
$gpiocmd mode $gpiopin_led_r out
$gpiocmd write $gpiopin_led_g 1
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
counter="$(($counter + 1))"
counter="$((counter + 1))"
#echo "$counter"
sleep $buttonpolling
done
@ -61,7 +61,7 @@ while true; do
$gpiocmd mode $gpiopin_led_r out
$gpiocmd write $gpiopin_led_g 1
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
counter="$(($counter + 1))"
counter="$((counter + 1))"
#echo "$counter"
sleep $buttonpolling
done
@ -77,7 +77,7 @@ while true; do
$gpiocmd mode $gpiopin_led_r out
$gpiocmd write $gpiopin_led_g 1
while [ "$($gpiocmd read $gpiopin_sw)" -eq "1" ] && [ "$counter" -lt "$countermax" ]; do
counter="$(($counter + 1))"
counter="$((counter + 1))"
#echo "$counter"
sleep $buttonpolling
done

View File

@ -37,7 +37,7 @@ while true; do
if [ -z "$mountstat" ]; then
folder="$folderint"
elif [ ! -z "$mountstat" ]; then
elif [ -n "$mountstat" ]; then
folder="$folderext"
fi

View File

@ -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
randomvideoproc="randomvideo.sh" ### var: name of process for random video script
if [ ! -z "$(pgrep $playerproc)" ]; then
if [ -n "$(pgrep $playerproc)" ]; then
pkill $playerproc
fi
if [ ! -z "$(pgrep $randomvideoproc)" ]; then
if [ -n "$(pgrep $randomvideoproc)" ]; then
pkill $randomvideoproc
fi