diff --git a/autoStart.bash b/autoStart.bash index 47ad50d..02f824d 100755 --- a/autoStart.bash +++ b/autoStart.bash @@ -11,11 +11,29 @@ if ! [ -x "$(command -v jq)" ]; then exit 1 fi +temp_headers=$(mktemp) + dataOfServers=$(curl -s "${baseURL}""/client" \ -H "Authorization: Bearer $apiToken" \ -H "Content-Type: application/json" \ + -D "${temp_headers}" \ -H "Accept: Application/vnd.pterodactyl.v1+json" | jq '.data') +read -r STATUS < <( + awk '/^HTTP/ { STATUS = $2 } + END { printf("%s\n",STATUS) }' < "$temp_headers" + ) + +rm -f "$temp_headers" + +if [[ $STATUS = 404 ]]; then + echo "The baseURL is wrong and/or cannot be accessed." + exit 1 +elif [[ $STATUS = 403 ]]; then + echo "Wrong token" + exit 1 +fi + numberOfServers=$(echo "${dataOfServers}" | jq length) for (( i=0; i < "$numberOfServers"; i++ )) @@ -32,4 +50,4 @@ do -X POST \ -d '{ "signal": "start" }' fi -done \ No newline at end of file +done