2022-03-25 15:16:17 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# author: Daniel Sommer <daniel.sommer@velvettear.de>
|
|
|
|
# license: MIT
|
|
|
|
|
2022-03-25 16:18:43 +01:00
|
|
|
set -e
|
2022-03-25 15:16:17 +01:00
|
|
|
|
2022-03-30 15:33:31 +02:00
|
|
|
[[ -z "$1" ]] && printf "${FONT_BOLD}error:${FONT_NORMAL} no endpoint given\n" && exit 1
|
2022-03-25 16:18:43 +01:00
|
|
|
url="$1"
|
|
|
|
[[ "$url" != "/"* ]] && url="/$url"
|
|
|
|
|
2022-03-30 15:33:31 +02:00
|
|
|
if [[ "$2" ]]; then
|
|
|
|
index="$2"
|
|
|
|
[[ "$index" != "/"* ]] && index="/$index"
|
2022-03-25 15:16:17 +01:00
|
|
|
fi
|
2022-03-30 15:33:31 +02:00
|
|
|
url="$url$index"
|
2022-03-25 15:16:17 +01:00
|
|
|
|
|
|
|
function checkVariable() {
|
|
|
|
[[ "$1" ]] && return 0
|
|
|
|
printf "error: variable"
|
|
|
|
[[ "$2" ]] && printf " \'$2\'"
|
|
|
|
printf " is not set\n"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
checkVariable "$PBC_PROTOCOL" "PBC_PROTOCOL"
|
|
|
|
checkVariable "$PBC_HOST" "PBC_HOST"
|
|
|
|
checkVariable "$PBC_PORT" "PBC_PORT"
|
|
|
|
|
|
|
|
url="$PBC_PROTOCOL://$PBC_HOST:$PBC_PORT$url"
|
|
|
|
|
2022-03-25 16:18:43 +01:00
|
|
|
printf "$url"
|