From df90c30c69dc67278c54c5fdff406a3f1b5ef75d Mon Sep 17 00:00:00 2001 From: abdulhade Date: Mon, 7 Apr 2025 02:40:20 +0300 Subject: [PATCH] Added a `test_setup` command. --- scripts/manager.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scripts/manager.sh b/scripts/manager.sh index 56ff4a1..ea2ef5d 100755 --- a/scripts/manager.sh +++ b/scripts/manager.sh @@ -683,6 +683,38 @@ stop() { fi } +test_setup(){ + # Check if the container exists (running or stopped) + if docker ps -a --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then + # Check if the container is running + if docker ps --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then + # Stop the container + RESPONSE=$(wget -qO- "http://127.0.0.1:$API_PORT/ping" 2>/dev/null) + + if [ "$RESPONSE" = '"Ok"' ]; then + print_header "Container '$CONTAINER_NAME' is Found. +Container '$CONTAINER_NAME' is running. +App returned Ok to ping request." + return 0 + else + print_header "Container Found. +Container Running. +Error with the return of the App, it is not working right. +Response: $RESPONSE" + return 1 + fi + + else + print_header "Container '$CONTAINER_NAME' is Found. +Container '$CONTAINER_NAME' is not running." + return 0 + fi + else + print_header "Container '$CONTAINER_NAME' does not exist." + return 1 + fi +} + help() { print_header "help: @@ -694,6 +726,7 @@ Source Code Management: App Running: > status + > test_setup > start > restart > stop @@ -735,6 +768,7 @@ main() { stop) stop ;; show_config) show_config ;; update_config) update_config ;; + test_setup) test_setup ;; help) help ;; *) echo "Invalid argument: $1"; help ;; esac