From 82d4f40a0866003224e8c64b6fcc1deb75708f82 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Mon, 2 Jun 2025 20:10:33 +0200 Subject: [PATCH] Helper to auto deploy from cron --- scripts/pull-and-restart.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 scripts/pull-and-restart.sh diff --git a/scripts/pull-and-restart.sh b/scripts/pull-and-restart.sh new file mode 100755 index 0000000..171a8f6 --- /dev/null +++ b/scripts/pull-and-restart.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# +# Try to pull the most recent image, and restart docker compose if it has changes +# +if [ $# -ne 2 ]; then + echo "usage: pull-and-restart image compose.yaml" >&2 + exit 64 +fi + +before="$(docker inspect --format='{{index .RepoDigests 0}}' $1)" +docker pull docker inspect --format='{{index .RepoDigests 0}}' +after="$(docker inspect --format='{{index .RepoDigests 0}}' $1)" + +if [ "$before" != "$after" ]; then + docker compose -f $2 up -d +fi