33# Ensure the script is executed with bash (required for arrays and [[ ]])
44if [ -z " $BASH_VERSION " ]; then
55 echo " ❌ This script must be run with bash. Please use: bash deploy.sh or ./deploy.sh"
6- exit 0
6+ exit 1
77fi
88
99# Exit immediately if a command exits with a non-zero status
@@ -225,7 +225,7 @@ check_ports_in_env_files() {
225225 confirm_continue=$( sanitize_input " $confirm_continue " )
226226 if ! [[ " $confirm_continue " =~ ^[Yy]$ ]]; then
227227 echo " 🚫 Deployment aborted due to port conflicts."
228- exit 0
228+ exit 1
229229 fi
230230
231231 echo " ⚠️ Continuing deployment even though some required ports are already in use."
@@ -595,7 +595,7 @@ deploy_core_services() {
595595 echo " 👀 Starting core services..."
596596 if ! ${docker_compose_command} -p nexent -f " docker-compose${COMPOSE_FILE_SUFFIX} " up -d nexent-config nexent-runtime nexent-mcp nexent-northbound nexent-web nexent-data-process; then
597597 echo " ❌ ERROR Failed to start core services"
598- return 0
598+ return 1
599599 fi
600600}
601601
@@ -612,7 +612,7 @@ deploy_infrastructure() {
612612
613613 if ! ${docker_compose_command} -p nexent -f " docker-compose${COMPOSE_FILE_SUFFIX} " up -d $INFRA_SERVICES ; then
614614 echo " ❌ ERROR Failed to start infrastructure services"
615- return 0
615+ return 1
616616 fi
617617
618618 if [ " $ENABLE_TERMINAL_TOOL_CONTAINER " = " true" ]; then
@@ -704,7 +704,7 @@ setup_package_install_script() {
704704 echo " ✅ Package installation script created/updated"
705705 else
706706 echo " ❌ ERROR openssh-install-script.sh not found"
707- return 0
707+ return 1
708708 fi
709709}
710710
@@ -892,40 +892,40 @@ main_deploy() {
892892 APP_VERSION=" $( get_app_version) "
893893 if [ -z " $APP_VERSION " ]; then
894894 echo " ❌ Failed to get app version, please check the backend/consts/const.py file"
895- exit 0
895+ exit 1
896896 fi
897897 echo " 🌐 App version: $APP_VERSION "
898898
899899 # Check all relevant ports from environment files before starting deployment
900900 check_ports_in_env_files
901901
902902 # Select deployment version, mode and image source
903- select_deployment_version || { echo " ❌ Deployment version selection failed" ; exit 0 ; }
904- select_deployment_mode || { echo " ❌ Deployment mode selection failed" ; exit 0 ; }
905- select_terminal_tool || { echo " ❌ Terminal tool container configuration failed" ; exit 0 ; }
906- choose_image_env || { echo " ❌ Image environment setup failed" ; exit 0 ; }
903+ select_deployment_version || { echo " ❌ Deployment version selection failed" ; exit 1 ; }
904+ select_deployment_mode || { echo " ❌ Deployment mode selection failed" ; exit 1 ; }
905+ select_terminal_tool || { echo " ❌ Terminal tool container configuration failed" ; exit 1 ; }
906+ choose_image_env || { echo " ❌ Image environment setup failed" ; exit 1 ; }
907907
908908 # Add permission
909- prepare_directory_and_data || { echo " ❌ Permission setup failed" ; exit 0 ; }
910- generate_minio_ak_sk || { echo " ❌ MinIO key generation failed" ; exit 0 ; }
909+ prepare_directory_and_data || { echo " ❌ Permission setup failed" ; exit 1 ; }
910+ generate_minio_ak_sk || { echo " ❌ MinIO key generation failed" ; exit 1 ; }
911911
912912
913913 # Generate Supabase secrets
914- generate_supabase_keys || { echo " ❌ Supabase secrets generation failed" ; exit 0 ; }
914+ generate_supabase_keys || { echo " ❌ Supabase secrets generation failed" ; exit 1 ; }
915915
916916 # Deploy infrastructure services
917- deploy_infrastructure || { echo " ❌ Infrastructure deployment failed" ; exit 0 ; }
917+ deploy_infrastructure || { echo " ❌ Infrastructure deployment failed" ; exit 1 ; }
918918
919919 # Generate Elasticsearch API key
920- generate_elasticsearch_api_key || { echo " ❌ Elasticsearch API key generation failed" ; exit 0 ; }
920+ generate_elasticsearch_api_key || { echo " ❌ Elasticsearch API key generation failed" ; exit 1 ; }
921921
922922 echo " "
923923 echo " --------------------------------"
924924 echo " "
925925
926926 # Special handling for infrastructure mode
927927 if [ " $DEPLOYMENT_MODE " = " infrastructure" ]; then
928- generate_env_for_infrastructure || { echo " ❌ Environment generation failed" ; exit 0 ; }
928+ generate_env_for_infrastructure || { echo " ❌ Environment generation failed" ; exit 1 ; }
929929 echo " 🎉 Infrastructure deployment completed successfully!"
930930 echo " You can now start the core services manually using dev containers"
931931 echo " Environment file available at: $( cd .. && pwd) /.env"
@@ -935,7 +935,7 @@ main_deploy() {
935935 fi
936936
937937 # Start core services
938- deploy_core_services || { echo " ❌ Core services deployment failed" ; exit 0 ; }
938+ deploy_core_services || { echo " ❌ Core services deployment failed" ; exit 1 ; }
939939
940940 echo " ✅ Core services started successfully"
941941 echo " "
@@ -944,7 +944,7 @@ main_deploy() {
944944
945945 # Create default admin user
946946 if [ " $DEPLOYMENT_VERSION " = " full" ]; then
947- create_default_admin_user || { echo " ❌ Default admin user creation failed" ; exit 0 ; }
947+ create_default_admin_user || { echo " ❌ Default admin user creation failed" ; exit 1 ; }
948948 fi
949949
950950 persist_deploy_options
@@ -956,7 +956,7 @@ main_deploy() {
956956version_info=$( get_compose_version)
957957if [[ $version_info == " unknown" ]]; then
958958 echo " Error: Docker Compose not found or version detection failed"
959- exit 0
959+ exit 1
960960fi
961961
962962# extract version
@@ -971,7 +971,7 @@ case $version_type in
971971 # The version v1.28.0 is the minimum requirement in Docker Compose v1 that explicitly supports interpolation syntax with default values like ${VAR:-default}
972972 if [[ $version_number < " 1.28.0" ]]; then
973973 echo " Warning: V1 version is too old, consider upgrading to V2"
974- exit 0
974+ exit 1
975975 fi
976976 docker_compose_command=" docker-compose"
977977 ;;
@@ -981,14 +981,14 @@ case $version_type in
981981 ;;
982982 * )
983983 echo " Error: Unknown docker compose version type."
984- exit 0
984+ exit 1
985985 ;;
986986esac
987987
988988# Execute main deployment with error handling
989989if ! main_deploy; then
990990 echo " ❌ Deployment failed. Please check the error messages above and try again."
991- exit 0
991+ exit 1
992992fi
993993
994994clean
0 commit comments