From b697b70db111155e7c6289c4ef223ace70f984d0 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 25 Mar 2022 16:18:43 +0100 Subject: [PATCH] reworked and renamed scripts --- pedalboard.sh | 8 -------- set-pedalboard.sh | 17 +++++++++++++++++ toggle-bypass.sh | 15 +++++++++++++++ bypass.sh => url.sh | 15 +++++++++------ 4 files changed, 41 insertions(+), 14 deletions(-) delete mode 100755 pedalboard.sh create mode 100755 set-pedalboard.sh create mode 100755 toggle-bypass.sh rename bypass.sh => url.sh (66%) diff --git a/pedalboard.sh b/pedalboard.sh deleted file mode 100755 index c86b51e..0000000 --- a/pedalboard.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -# author: Daniel Sommer -# license: MIT - -[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1 -source "./config.env" - diff --git a/set-pedalboard.sh b/set-pedalboard.sh new file mode 100755 index 0000000..022e33c --- /dev/null +++ b/set-pedalboard.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# 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" \ No newline at end of file diff --git a/toggle-bypass.sh b/toggle-bypass.sh new file mode 100755 index 0000000..0a236c2 --- /dev/null +++ b/toggle-bypass.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# 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" \ No newline at end of file diff --git a/bypass.sh b/url.sh similarity index 66% rename from bypass.sh rename to url.sh index e68093c..9d5612c 100755 --- a/bypass.sh +++ b/url.sh @@ -3,11 +3,15 @@ # author: Daniel Sommer # license: MIT -[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1 -source "./config.env" +set -e -url="/bypass" -index="$1" +[[ -z "$1" ]] && printf "error: no endpoint given\n" && exit 1 +url="$1" +[[ "$url" != "/"* ]] && url="/$url" + +. "$(dirname $(realpath $0))/config.env" + +index="$2" if [[ "$index" ]] && [ "$index" -eq "$index" ] 2> /dev/null; then if [ "$index" -lt 0 ]; then index=0 @@ -31,5 +35,4 @@ checkVariable "$PBC_PORT" "PBC_PORT" url="$PBC_PROTOCOL://$PBC_HOST:$PBC_PORT$url" -printf "sending POST request: \'$url\'...${FONT_BOLD}" -[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n" \ No newline at end of file +printf "$url" \ No newline at end of file