#!/bin/sh # SPDX-License-Identifier: Unlicense cmdjq="$(command -v jq)" if [ -z "$cmdjq" ]; then echo "Missing \"jq\"!" exit 1 fi configfile="config.json" 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)" if [ $# -eq 0 ]; then echo "Parameter fehlt" exit 1 fi if [ $# -gt 1 ]; then echo "Zu viele Parameter" exit 1 fi if [ "$swupstat" -eq 1 ]; then exit 1 fi if [ "buzzer" != "$1" ] && [ "cron" != "$1" ]; then echo "Parameter muss \"buzzer\" oder \"cron\" sein" exit 1 fi if pgrep "$pgrepplayer" > /dev/null; then if [ "$1" = "buzzer" ]; then pkill "$pgrepplayer" elif [ "$1" = "cron" ]; then exit 1 fi else $playerfull "$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" & fi