reworked and renamed scripts

This commit is contained in:
Daniel Sommer 2022-03-25 16:18:43 +01:00
parent 295daab9ab
commit b697b70db1
4 changed files with 41 additions and 14 deletions

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1
source "./config.env"

17
set-pedalboard.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
set -e
dir="$(dirname $(realpath "$0"))"
. "$dir/config.env"
[[ -z "$1" ]] && printf "${FONT_BOLD}error: ${FONT_NORMAL}no pedalboard id given\n" && exit 1
url="$(""$dir"/url.sh" "/pedalboards" "$1")"
printf "> sending POST request to \'$url\'...${FONT_BOLD}"
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"

15
toggle-bypass.sh Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
set -e
dir="$(dirname $(realpath "$0"))"
. "$dir/config.env"
url="$(""$dir"/url.sh" "/bypass" "$1")"
printf "> sending POST request to \'$url\'...${FONT_BOLD}"
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"

View file

@ -3,11 +3,15 @@
# author: Daniel Sommer <daniel.sommer@velvettear.de> # author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT # license: MIT
[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1 set -e
source "./config.env"
url="/bypass" [[ -z "$1" ]] && printf "error: no endpoint given\n" && exit 1
index="$1" url="$1"
[[ "$url" != "/"* ]] && url="/$url"
. "$(dirname $(realpath $0))/config.env"
index="$2"
if [[ "$index" ]] && [ "$index" -eq "$index" ] 2> /dev/null; then if [[ "$index" ]] && [ "$index" -eq "$index" ] 2> /dev/null; then
if [ "$index" -lt 0 ]; then if [ "$index" -lt 0 ]; then
index=0 index=0
@ -31,5 +35,4 @@ checkVariable "$PBC_PORT" "PBC_PORT"
url="$PBC_PROTOCOL://$PBC_HOST:$PBC_PORT$url" url="$PBC_PROTOCOL://$PBC_HOST:$PBC_PORT$url"
printf "sending POST request: \'$url\'...${FONT_BOLD}" printf "$url"
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"