Skip to content

Commit 3c8b430

Browse files
committed
πŸ› fix deployment failure will cause the terminal to close
1 parent 76654b3 commit 3c8b430

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

β€Ždocker/deploy.shβ€Ž

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ fi
88

99
# Exit immediately if a command exits with a non-zero status
1010
set -e
11-
12-
ERROR_OCCURRED=0
13-
1411
set -a
1512
source .env
1613

@@ -64,7 +61,7 @@ is_windows_env() {
6461
if [[ "$os_name" == mingw* || "$os_name" == msys* ]]; then
6562
return 0
6663
fi
67-
return 0
64+
return 1
6865
}
6966

7067
is_port_in_use() {
@@ -76,27 +73,27 @@ is_port_in_use() {
7673
if lsof -iTCP:"$port" -sTCP:LISTEN -P -n >/dev/null 2>&1; then
7774
return 0
7875
fi
79-
return 0
76+
return 1
8077
fi
8178

8279
# Fallback to ss if available
8380
if command -v ss >/dev/null 2>&1; then
8481
if ss -ltn 2>/dev/null | awk '{print $4}' | grep -qE "[:\.]${port}$"; then
8582
return 0
8683
fi
87-
return 0
84+
return 1
8885
fi
8986

9087
# Fallback to netstat (works on Windows and many Linux distributions)
9188
if command -v netstat >/dev/null 2>&1; then
9289
if netstat -an 2>/dev/null | grep -qE "[:\.]${port}[[:space:]]"; then
9390
return 0
9491
fi
95-
return 0
92+
return 1
9693
fi
9794

9895
# If no inspection tool is available, assume the port is free
99-
return 0
96+
return 1
10097
}
10198

10299
add_port_if_new() {
@@ -242,8 +239,7 @@ generate_minio_ak_sk() {
242239

243240
if [ -z "$ACCESS_KEY" ] || [ -z "$SECRET_KEY" ]; then
244241
echo " ❌ ERROR Failed to generate MinIO access keys"
245-
ERROR_OCCURRED=1
246-
return 0
242+
return 1
247243
fi
248244

249245
export MINIO_ACCESS_KEY=$ACCESS_KEY
@@ -325,7 +321,7 @@ generate_env_for_infrastructure() {
325321
# Check if generate_env.sh exists
326322
if [ ! -f "generate_env.sh" ]; then
327323
echo " ❌ ERROR generate_env.sh not found in docker directory"
328-
return 0
324+
return 1
329325
fi
330326

331327
# Make sure the script is executable and run it
@@ -345,11 +341,11 @@ generate_env_for_infrastructure() {
345341
echo " βœ… Environment variables loaded from ../.env"
346342
else
347343
echo " ⚠️ Warning: ../.env file not found after generation"
348-
return 0
344+
return 1
349345
fi
350346
else
351347
echo " ❌ ERROR Failed to generate environment file"
352-
return 0
348+
return 1
353349
fi
354350

355351
echo ""
@@ -498,17 +494,15 @@ create_dir_with_permission() {
498494
# Check if parameters are provided
499495
if [ -z "$dir_path" ] || [ -z "$permission" ]; then
500496
echo " ❌ ERROR Directory path and permission parameters are required." >&2
501-
ERROR_OCCURRED=1
502-
return 0
497+
return 1
503498
fi
504499

505500
# Create the directory if it doesn't exist
506501
if [ ! -d "$dir_path" ]; then
507502
mkdir -p "$dir_path"
508503
if [ $? -ne 0 ]; then
509504
echo " ❌ ERROR Failed to create directory $dir_path." >&2
510-
ERROR_OCCURRED=1
511-
return 0
505+
return 1
512506
fi
513507
fi
514508

@@ -581,15 +575,13 @@ deploy_infrastructure() {
581575
# Check if the supabase compose file exists
582576
if [ ! -f "docker-compose-supabase${COMPOSE_FILE_SUFFIX}" ]; then
583577
echo " ❌ ERROR Supabase compose file not found: docker-compose-supabase${COMPOSE_FILE_SUFFIX}"
584-
ERROR_OCCURRED=1
585-
return 0
578+
return 1
586579
fi
587580

588581
# Start Supabase services
589582
if ! $docker_compose_command -p nexent -f "docker-compose-supabase${COMPOSE_FILE_SUFFIX}" up -d; then
590583
echo " ❌ ERROR Failed to start supabase services"
591-
ERROR_OCCURRED=1
592-
return 0
584+
return 1
593585
fi
594586

595587
echo " βœ… Supabase services started successfully"
@@ -661,7 +653,6 @@ setup_package_install_script() {
661653
echo " βœ… Package installation script created/updated"
662654
else
663655
echo " ❌ ERROR openssh-install-script.sh not found"
664-
ERROR_OCCURRED=1
665656
return 0
666657
fi
667658
}
@@ -753,17 +744,15 @@ select_terminal_tool() {
753744
echo ""
754745
if [ -z "$input_password" ]; then
755746
echo "❌ SSH password cannot be empty"
756-
ERROR_OCCURRED=1
757-
return 0
747+
return 1
758748
fi
759749
SSH_PASSWORD="$input_password"
760750
fi
761751

762752
# Validate credentials
763753
if [ -z "$SSH_USERNAME" ] || [ -z "$SSH_PASSWORD" ]; then
764754
echo "❌ Both username and password are required"
765-
ERROR_OCCURRED=1
766-
return 0
755+
return 1
767756
fi
768757

769758
# Export environment variables
@@ -795,7 +784,7 @@ create_default_admin_user() {
795784

796785
if [ -z "$RESPONSE" ]; then
797786
echo " ❌ No response received from Supabase."
798-
return 0
787+
return 1
799788
elif echo "$RESPONSE" | grep -q '"access_token"' && echo "$RESPONSE" | grep -q '"user"'; then
800789
echo " βœ… Default admin user has been successfully created."
801790
echo ""
@@ -806,7 +795,7 @@ create_default_admin_user() {
806795
echo " 🚧 Default admin user already exists. Skipping creation."
807796
else
808797
echo " ❌ Response from Supabase does not contain 'access_token' or 'user'."
809-
return 0
798+
return 1
810799
fi
811800

812801
echo ""

0 commit comments

Comments
Β (0)