script it

This commit is contained in:
rskntroot
2025-06-14 10:50:18 +00:00
parent e905245647
commit 4b43948270
7 changed files with 46 additions and 328 deletions

46
compose.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/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