healthcheck_containers.sh added

containers maintenance
This commit is contained in:
Neovoid Pineapple 2024-07-07 07:33:24 +00:00
parent 20958f6bd6
commit 3b036c383d

17
healthcheck_containers.sh Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# To check if container is running and if found stopped it will restart it and also renews the unix socket.
# Recommended to use with revive_pods.sh which is systemd service check certain containers hourly.
for container in "$@"; do
status=$(podman inspect -f '{{.State.Status}}' $container)
if [ "$status" = "exited" ]; then
podman start $container && echo "Container $container started" || echo "failed to start container $container"
rm /srv/http/$container && echo "reloaded clean socket file" || echo "failed to remove old socket file for $container"
systemctl --user restart $container.service && echo "service restarted" || echo "failed to restart service"
else
echo "Container $container is $status"
fi
done