Added a test_setup command.

This commit is contained in:
2025-04-07 02:40:20 +03:00
parent bf84a61ef0
commit df90c30c69

View File

@@ -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