Skip to content
Snippets Groups Projects
Commit dcc1487d authored by Jakob Moser's avatar Jakob Moser
Browse files

Draft restart script

parents
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
BASE_DIR="/coli"
declare -a DIRS_TO_RESTART=( )
for dir in ${BASE_DIR}/*
do
if [ -f "${dir}/docker-compose.yml" ] || [ -f "${dir}/docker-compose.yaml" ]
then
cd ${dir}
# Snippet to detect if the services are running taken and modified from
# answer to https://serverfault.com/a/1015665/ by drew2g
# (https://serverfault.com/users/573225/drew2g)
# CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/).
# -z option explained here https://stackoverflow.com/a/45563383/
# and here https://stackoverflow.com/a/45562906/
if [ -z "$(docker compose ps --services --filter 'status=running')" ]
then
echo "${dir} was down, keeping it down"
else
echo "${dir} was up, stopping it and queuing for restart"
DIRS_TO_RESTART+=(${dir})
docker compose down
fi
fi
done
echo "! Restarting Traefik"
cd /coli/traefik
docker compose up --detach
for dir in ${DIRS_TO_RESTART[*]}
do
echo "${dir} is starting"
cd ${dir}
docker compose up --detach
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment