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