Skip to content

Commit f46e3d4

Browse files
alexey-yarmoshMartinKolarik
authored andcommitted
feat: improve default setup scripts (#124)
1 parent 72d49ea commit f46e3d4

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎.env.development.example‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DB
22
DB_CLIENT=mysql
3-
DB_HOST=host.docker.internal
4-
DB_PORT=13306
3+
DB_HOST=mariadb
4+
DB_PORT=3306
55
DB_DATABASE=dashboard-globalping
66
DB_USER=directus
77
DB_PASSWORD=password

‎.env.e2e.example‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ ENABLE_E2E_MOCKS=true
33

44
# DB
55
DB_CLIENT=mysql
6-
# This is an ip of `host.docker.internal` on Linux
7-
DB_HOST=172.17.0.1
8-
DB_PORT=13306
6+
DB_HOST=mariadb
7+
DB_PORT=3306
98
DB_DATABASE=dashboard-globalping
109
DB_USER=directus
1110
DB_PASSWORD=password

‎scripts/auth.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ function get_token {
99

1010
token=$(get_token)
1111

12+
if [ -z "$token" ] || [ "$token" == "null" ]; then
13+
echo "Error: Obtained token is empty: '$token'. Please check ADMIN_EMAIL and ADMIN_PASSWORD values in .env file."
14+
exit 1
15+
fi
16+
1217
perl -pi -e "s/ADMIN_ACCESS_TOKEN=.*/ADMIN_ACCESS_TOKEN=$token/" .env

‎scripts/init.sh‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ function confirm {
2020
fi
2121
}
2222

23+
if ! command -v jq >/dev/null; then
24+
echo "Error: jq is not installed. Please install jq to continue."
25+
exit 1
26+
fi
27+
2328
function get_token {
2429
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')
2530
echo "$token"
@@ -44,6 +49,11 @@ echo "Compose file $compose_file is used."
4449

4550
token=$(get_token)
4651

52+
if [ -z "$token" ] || [ "$token" == "null" ]; then
53+
echo "Error: Obtained token is empty: '$token'. Please check ADMIN_EMAIL and ADMIN_PASSWORD values in .env file."
54+
exit 1
55+
fi
56+
4757
perl -pi -e "s/ADMIN_ACCESS_TOKEN=.*/ADMIN_ACCESS_TOKEN=$token/" .env
4858

4959
pnpm run schema:apply

0 commit comments

Comments
 (0)