Skip to content

Commit 4ed2b1f

Browse files
feat: add retry to get_token
1 parent 657564d commit 4ed2b1f

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

scripts/init.sh

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,14 @@
22

33
set -e
44

5-
function confirm {
6-
local message="$1"
7-
echo -e "$message Continue? [Y/n]"
8-
read confirm
9-
10-
if [ "$confirm" == "n" ] || [ "$confirm" == "N" ]; then
11-
echo "Aborting script..."
12-
exit 1
13-
elif [ -z "$confirm" ] || [ "$confirm" == "y" ] || [ "$confirm" == "Y" ]; then
14-
confirm="y"
15-
else
16-
echo "Invalid input. Aborting script..."
17-
exit 1
18-
fi
19-
}
20-
215
if ! command -v jq >/dev/null; then
226
echo "Error: jq is not installed. Please install jq to continue."
237
exit 1
248
fi
259

2610
function get_token {
27-
local token=$(curl -X POST -H "Content-Type: application/json" -d '{"email": "'"$ADMIN_EMAIL"'", "password": "'"$ADMIN_PASSWORD"'"}' $DIRECTUS_URL/auth/login | jq -r '.data.access_token')
11+
local response=$(curl --fail --retry 5 -X POST -H "Content-Type: application/json" -d '{"email": "'"$ADMIN_EMAIL"'", "password": "'"$ADMIN_PASSWORD"'"}' $DIRECTUS_URL/auth/login)
12+
local token=$(echo "$response" | jq -r '.data.access_token')
2813
echo "$token"
2914
}
3015

0 commit comments

Comments
 (0)