From b7cc8591b5f0e2b64c50165c410ba992fb6cde15 Mon Sep 17 00:00:00 2001 From: Martin Selbmann Date: Thu, 24 Sep 2020 21:52:14 +0200 Subject: [PATCH] check some depencies --- RandomVideo.sh | 19 +++++++++++++++---- buzzer.sh | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/RandomVideo.sh b/RandomVideo.sh index a6ace62..3f8ebe5 100755 --- a/RandomVideo.sh +++ b/RandomVideo.sh @@ -1,24 +1,35 @@ #!/bin/sh # SPDX-License-Identifier: Unlicense -cmdjq="$(command -v jq)" +configfile="config.json" +cmdjq="$(command -v jq)" if [ -z "$cmdjq" ]; then echo "Missing \"jq\"!" exit 1 fi -configfile="config.json" +cmdgpio="$(command -v gpio)" +if [ -z "$cmdgpio" ]; then + echo "Missing \"gpio\"!" + echo "This is a part of WiringPi-Package." + exit 1 +fi + +player="$($cmdjq -r ".player" < $configfile)" +if [ -z "$(command -v $player)" ]; then + echo "Missing \"$player\"!" + exit 1 +fi folder="$($cmdjq -r ".RandomVideo | .folder" < $configfile)" -player="$($cmdjq -r ".player" < $configfile)" playerparam="$($cmdjq -r ".playerparam" < $configfile)" pgrepplayer="$($cmdjq -r ".pgrepplayer" < $configfile)" swupgpio="$($cmdjq -r ".swupgpio" < $configfile)" playerfull="$(command -v $player) $playerparam" -swupstat="$($(command -v gpio) read $swupgpio)" +swupstat="$($cmdgpio read $swupgpio)" if [ $# -eq 0 ]; then echo "Parameter fehlt" diff --git a/buzzer.sh b/buzzer.sh index 9ff04f5..6b5177e 100755 --- a/buzzer.sh +++ b/buzzer.sh @@ -1,21 +1,32 @@ #!/bin/sh # SPDX-License-Identifier: Unlicense -cmdjq="$(command -v jq)" +configfile="config.json" +cmdjq="$(command -v jq)" if [ -z "$cmdjq" ]; then echo "Missing \"jq\"!" exit 1 fi -configfile="config.json" +cmdgpio="$(command -v gpio)" +if [ -z "$cmdgpio" ]; then + echo "Missing \"gpio\"!" + echo "This is a part of WiringPi-Package." + exit 1 +fi + +player="$($cmdjq -r ".player" < $configfile)" +if [ -z "$(command -v $player)" ]; then + echo "Missing \"$player\"!" + exit 1 +fi buzzergpio="$($cmdjq -r ".buzzer | .buzzergpio" < $configfile)" strobegpio="$($cmdjq -r ".buzzer | .strobegpio" < $configfile)" swupgpio="$($cmdjq -r ".swupgpio" < $configfile)" swdowngpio="$($cmdjq -r ".buzzer | .swdowngpio" < $configfile)" -player="$($cmdjq -r ".player" < $configfile)" playerparam="$($cmdjq -r ".playerparam" < $configfile)" playerloop="$($cmdjq -r ".buzzer | .playerloop" < $configfile)" @@ -30,7 +41,6 @@ volumedelay="$($cmdjq -r ".buzzer | .volumedelay" < $configfile)" volumemax="$($cmdjq -r ".buzzer | .volumemax" < $configfile)" playerfull="$(command -v $player) $playerparam" -cmdgpio="$(command -v gpio)" cmdamixer="$(command -v amixer)" $cmdgpio mode $buzzergpio in