Make the code a bit more DRY. Put sleep back into main loop

master
Tim Möhlmann 6 years ago
parent 508796eaab
commit 39c159bae9
No known key found for this signature in database
GPG Key ID: AFABC30066A39335

@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
containers=( containers=(
webmail_1 webmail
imap_1 imap
smtp_1 smtp
antispam_1 antispam
admin_1 admin
redis_1 redis
antivirus_1 antivirus
webdav_1 webdav
fetchmail_1 fetchmail
front_1 front
) )
# Default to mailu for DOCKER_ORG # Default to mailu for DOCKER_ORG
@ -29,20 +29,21 @@ v_sleep() {
} }
containers_check() { containers_check() {
v_sleep 1 status=0
STATUS=0
for container in "${containers[@]}"; do for container in "${containers[@]}"; do
echo "Checking ${DOCKER_ORG}_${container}" name="${DOCKER_ORG}_${container}_1"
docker inspect "${DOCKER_ORG}_${container}" | grep '"Status": "running"' || STATUS=1 echo "Checking $name"
docker inspect "$name" | grep '"Status": "running"' || status=1
done done
docker ps -a docker ps -a
return $STATUS return $status
} }
container_logs() { container_logs() {
for container in "${containers[@]}"; do for container in "${containers[@]}"; do
echo "Showing logs for ${DOCKER_ORG}_${container}" name="${DOCKER_ORG}_${container}_1"
docker container logs "${DOCKER_ORG}_${container}" echo "Showing logs for $name"
docker container logs "$name"
done done
} }
@ -60,6 +61,7 @@ die() {
for file in tests/compose/*.env ; do for file in tests/compose/*.env ; do
cp $file .env cp $file .env
docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d
v_sleep 1
container_logs container_logs
containers_check || die 1 containers_check || die 1
clean clean

Loading…
Cancel
Save