#!/bin/bash help() { echo "Usage: compose.sh (start|stop|update)" } network() { NETWORK="traefik" if docker network ls | grep -q "${NETWORK}"; then echo "Network ${NETWORK} already exists" else docker network create \ --driver bridge \ --subnet=172.20.0.0/16 \ --gateway=172.20.0.1 \ "${NETWORK}" fi } dispatch() { for dir in */; do if [ -f "${dir}/compose.yml" ]; then cd ${dir} ${cmd} cd .. fi done } case "$1" in start) network cmd="docker compose up -d" dispatch ;; stop) cmd="docker compose down" dispatch ;; update) cmd="docker compose pull" dispatch ;; *) help esac