mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 04:31:13 +01:00
Implemented check for excited != 0 https://chat.openai.com/share/981ecca4-9df7-4086-b99e-1b60f2632bf6
This commit is contained in:
parent
d1b2d8e653
commit
6c0c8e0fc0
@ -1,20 +1,30 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
docker_ps_grep_unhealthy="$(docker ps --filter health=unhealthy --format '{{.Names}}')"
|
docker_ps_grep_unhealthy="$(docker ps --filter health=unhealthy --format '{{.Names}}')"
|
||||||
docker_ps_grep_exited="$(docker ps --filter status=exited --format '{{.Names}}')"
|
docker_ps_grep_exited="$(docker ps --filter status=exited --format '{{.ID}}')"
|
||||||
|
|
||||||
exitcode=0
|
exitcode=0
|
||||||
if [ ! -z "$docker_ps_grep_unhealthy" ]
|
|
||||||
then
|
if [ -n "$docker_ps_grep_unhealthy" ]; then
|
||||||
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
|
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
|
||||||
exitcode=1
|
exitcode=1
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$docker_ps_grep_exited" ]
|
|
||||||
then
|
if [ -n "$docker_ps_grep_exited" ]; then
|
||||||
echo "Some docker containers exited: $docker_ps_grep_exited"
|
for container_id in $docker_ps_grep_exited
|
||||||
exitcode=2
|
do
|
||||||
|
container_exit_code="$(docker inspect "$container_id" --format='{{.State.ExitCode}}')"
|
||||||
|
container_name="$(docker inspect "$container_id" --format='{{.Name}}')"
|
||||||
|
container_name="${container_name#/}" # Entfernt das führende '/'
|
||||||
|
if [ "$container_exit_code" -ne "0" ]; then
|
||||||
|
echo "Container $container_name exited with code $container_exit_code"
|
||||||
|
exitcode=2
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
if [ "$exitcode" -ne "0" ]
|
|
||||||
then
|
if [ "$exitcode" -ne "0" ]; then
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "All docker containers are healthy."
|
echo "All docker containers are healthy."
|
||||||
exit
|
exit
|
||||||
|
Loading…
Reference in New Issue
Block a user