Skip to content

Instantly share code, notes, and snippets.

@blackandred
Last active July 6, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackandred/ce2e01c4a795655d98c6a3ef615063b9 to your computer and use it in GitHub Desktop.
Save blackandred/ce2e01c4a795655d98c6a3ef615063b9 to your computer and use it in GitHub Desktop.
Wait until the last container of docker-compose will be stopped
#!/bin/bash
# Copyright 2020 RiotKit Tech Collective
# ======================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# About RiotKit
# =============
# We are grassroot activists for social change, we respond to the needs of grassroot organizations,
# check out those fantastic mutual aid initiatives:
# International:
# - International Workers Association (https://iwa-ait.org)
# - Anarchist Black Cross Worldwide (https://www.abcf.net/)
# Poland:
# - Anarchistyczne FAQ (http://anarchizm.info) a translation of Anarchist FAQ
# (https://theanarchistlibrary.org/library/the-anarchist-faq-editorial-collective-an-anarchist-faq)
# - Federacja Anarchistyczna (http://federacja-anarchistyczna.pl)
# - Związek Syndykalistów Polski (https://zsp.net.pl) (Polish section of IWA-AIT)
# - Komitet Obrony Praw Lokatorów (https://lokatorzy.info.pl)
# - Food Not Bombs (http://foodnotbombs.pl/)
# Slovakia:
# - Priama Akcia (https://priamaakcia.sk)
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/SLOVAKIA.html)
# England:
# - Solidarity Federation (http://solfed.org.uk)
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/ENGLAND.html)
# - Anarchist Federation (http://afed.org.uk/)
# USA:
# - Anarchist Federation (https://blackrosefed.org/)
# Russia:
# - KRAS (https://aitrus.info/)
# - Food Not Bombs (http://foodnotbombs.net/RUSSIA.html)
# India:
# - Muktivadi Ektra Morcha (https://muktivadi.blackblogs.org/)
# - Anarchist Federation (https://www.facebook.com/indiananarchists/, https://thecominganarchy.wordpress.com/)
# Spain:
# - CNT-AIT (http://cnt-ait.org/)
# - Food Not Bombs (https://www.foodnotbombs.net/SPAIN.html)
# - FAI (https://federacionanarquistaiberica.wordpress.com/)
# Denmark:
# - Örestad LS (https://orestadls.wordpress.com/)
# Australia:
# - ASF-IWA (http://asf-iwa.org.au/)
# - Food Not Bombs (https://www.foodnotbombs.net/australia.html)
# Bangladesh:
# - BASF (https://bangladeshasf.com/)
# Norway:
# - NSF (https://www.nsf-iaa.org/)
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/NORWAY.html)
# Serbia:
# - ASI-IWA (https://inicijativa.org/)
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/YUGOSLAVIA.html)
# France:
# - CNTF-AIT (http://www.cnt-ait.fr/)
# - Food Not Bombs (http://www.foodnotbombs.net/FRANCE.html)
ENV_NAME=$1
TIME_TO_WAIT=${2:-30}
is_compose_env_running () {
env_prefix=$1
if docker ps --filter name=$env_prefix | grep "$env_prefix" > /dev/null; then
return 0
fi
return 1
}
while is_compose_env_running "$ENV_NAME"; do
sleep "$TIME_TO_WAIT"
done
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment