#!/bin/bash # Array of container names or IDs containers=("nc6" "nc6_govod" "nc6_cron" "nc6_clamav" "nc6_db" "nc6_onlyoffice" "nc6_redis") # Function to stop containers stop_containers() { for container in "${containers[@]}"; do if docker ps --filter "name=$container" --filter "status=running" | grep -q "$container"; then echo "Stopping container: $container" docker stop "$container" else echo "Container $container is not running or does not exist." fi done } # Function to start containers start_containers() { for container in "${containers[@]}"; do if docker ps --filter "name=$container" --filter "status=running" | grep -q "$container"; then echo "Container $container is already running." else echo "Starting container: $container" docker start "$container" fi done } # Main routine if [[ "$1" == "stop" ]]; then echo "Shutting down containers..." stop_containers elif [[ "$1" == "start" ]]; then echo "Bringing up containers..." start_containers else echo "Usage: $0 {start|stop}" exit 1 fi