updated scripts

This commit is contained in:
Daniel Sommer 2022-03-30 15:33:31 +02:00
parent 5354f40f4a
commit 50b4ecf44b
3 changed files with 12 additions and 18 deletions

View file

@ -1,8 +1,8 @@
export TERM=xterm export TERM=xterm
FONT_BOLD=$(tput bold) export FONT_BOLD=$(tput bold)
FONT_NORMAL=$(tput sgr0) export FONT_NORMAL=$(tput sgr0)
PBC_PROTOCOL="http" export PBC_PROTOCOL="http"
PBC_HOST="192.168.1.24" export PBC_HOST="192.168.1.24"
PBC_PORT="3000" export PBC_PORT="3000"

View file

@ -9,7 +9,7 @@ dir="$(dirname $(realpath "$0"))"
. "$dir/config.env" . "$dir/config.env"
url="$(""$dir"/url.sh" "/systemd/jack-capture")" url="$(""$dir"/url.sh" "/systemd" "$1")"
printf "> sending POST request to \'$url\'...${FONT_BOLD}" printf "> sending POST request to \'$url\'...${FONT_BOLD}"
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" -d "state=toggle" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n" [ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" -d "state=toggle" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"

14
url.sh
View file

@ -5,21 +5,15 @@
set -e set -e
[[ -z "$1" ]] && printf "error: no endpoint given\n" && exit 1 [[ -z "$1" ]] && printf "${FONT_BOLD}error:${FONT_NORMAL} no endpoint given\n" && exit 1
url="$1" url="$1"
[[ "$url" != "/"* ]] && url="/$url" [[ "$url" != "/"* ]] && url="/$url"
. "$(dirname $(realpath $0))/config.env" if [[ "$2" ]]; then
index="$2" index="$2"
if [[ "$index" ]] && [ "$index" -eq "$index" ] 2> /dev/null; then [[ "$index" != "/"* ]] && index="/$index"
if [ "$index" -lt 0 ]; then
index=0
elif [ "$index" -gt 7 ]; then
index=7
fi
url="$url/$index"
fi fi
url="$url$index"
function checkVariable() { function checkVariable() {
[[ "$1" ]] && return 0 [[ "$1" ]] && return 0