29 lines
596 B
Bash
Executable File
29 lines
596 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
GIT_URL="https://git.hangman-lab.top"
|
|
|
|
USER="$(secret-mgr get-username --key git)"
|
|
PASS="$(secret-mgr get-secret --key git)"
|
|
|
|
if [[ -z "$USER" || -z "$PASS" ]]; then
|
|
echo "Missing credentials from secret-mgr (key: git)"
|
|
exit 2
|
|
fi
|
|
|
|
response=$(curl -s -w "%{http_code}" -u "$USER:$PASS" "$GIT_URL/api/v1/user")
|
|
http_code="${response: -3}"
|
|
body="${response:0:-3}"
|
|
|
|
if [[ "$http_code" == "200" ]]; then
|
|
echo "OK"
|
|
exit 0
|
|
elif [[ "$http_code" == "401" ]]; then
|
|
echo "AUTH FAILED"
|
|
exit 1
|
|
else
|
|
echo "ERROR: HTTP $http_code"
|
|
echo "$body"
|
|
exit 1
|
|
fi
|