2021-11-30 11:20:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Check if socket is available and readable
|
2025-08-11 14:28:12 +02:00
|
|
|
if ! [ -e "/var/run/docker.sock" ]; then
|
2021-11-30 11:20:42 +01:00
|
|
|
echo "Docker socket is not available. Cannot continue."
|
|
|
|
|
exit 1
|
2021-12-03 12:14:39 +01:00
|
|
|
elif ! test -r /var/run/docker.sock; then
|
2021-12-06 16:39:39 +01:00
|
|
|
echo "Docker socket is not readable by the root user. Cannot continue."
|
|
|
|
|
exit 1
|
2021-11-30 11:20:42 +01:00
|
|
|
fi
|
|
|
|
|
|
2025-06-11 22:48:52 -07:00
|
|
|
if [ -f /run/.containerenv ]; then
|
|
|
|
|
# If running under podman disable memory_swappiness setting in watchtower.
|
|
|
|
|
# It is a necessary workaround until https://github.com/containers/podman/issues/23824 gets fixed.
|
|
|
|
|
echo "Running under Podman. Setting WATCHTOWER_DISABLE_MEMORY_SWAPPINESS to 1."
|
|
|
|
|
export WATCHTOWER_DISABLE_MEMORY_SWAPPINESS=1
|
|
|
|
|
fi
|
|
|
|
|
|
2021-11-30 11:20:42 +01:00
|
|
|
if [ -n "$CONTAINER_TO_UPDATE" ]; then
|
2022-12-01 16:14:58 +01:00
|
|
|
exec /watchtower --cleanup --debug --run-once "$CONTAINER_TO_UPDATE"
|
2021-11-30 11:20:42 +01:00
|
|
|
else
|
|
|
|
|
echo "'CONTAINER_TO_UPDATE' is not set. Cannot update anything."
|
2021-12-03 12:14:39 +01:00
|
|
|
exit 1
|
2021-11-30 11:20:42 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exec "$@"
|