Files
.github
.vscode
docs
hydra
keys
lib
modules
pkgs
systems
artemision
palatine-hill
attic
docker
wg
act-runner.nix
archiveteam.nix
books.nix
default.nix
firefly.nix
foundry.nix
glances.nix
haproxy.cfg
haproxy.nix
minecraft.nix
nextcloud.nix
postgres.nix
restic.nix
torr.nix
unifi.nix
watchtower.bash
haproxy
acme.nix
configuration.nix
default.nix
firewall.nix
gitea.nix
hardware-changes.nix
hardware.nix
hydra.nix
loki.nix
minio.nix
networking.nix
nextcloud.nix
postgresql.nix
samba.nix
secrets.yaml
vars.nix
zfs.nix
users
utils
.envrc
.gitconfig
.gitignore
.sops.yaml
CONTRIBUTING.md
README.md
checks.nix
flake.lock
flake.nix
shell.nix
statix.toml
treefmt.toml
nix-dotfiles/systems/palatine-hill/docker/watchtower.bash

27 lines
809 B
Bash
Raw Normal View History

2024-11-17 22:15:39 -05:00
#! /usr/bin/env nix
#! nix shell nixpkgs#docker nixpkgs#bash nixpkgs#gawk --command bash
2024-11-17 22:15:39 -05:00
outdated_msg="Project code is out of date and needs to be upgraded. To remedy this problem immediately, you may reboot your warrior."
label="$1"
label_val="$2"
2025-03-13 17:50:03 -04:00
if (($# != 2)); then
echo "usage: $0 label label_value"
2024-11-17 22:15:39 -05:00
fi
containers=$(docker ps --format '{{.Names}}' -f "label=${label}=${label_val}")
for container in ${containers[@]}; do
echo "checking ${container}"
last_msg=$(docker logs -n 1 "${container}")
if [[ $last_msg =~ $outdated_msg ]]; then
echo "${container} is outdated, restarting"
imageTag=$(docker ps --format '{{.Names}}\t{{.Image}}' -f "name=$container" | grep -w "$container" | awk '{print $NF}')
docker pull "$imageTag"
2024-11-17 22:15:39 -05:00
systemctl restart "docker-${container}"
fi
done