From 565d5ae3d71f4a8c791ade4eb3961c144acb6819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Sun, 1 Feb 2026 10:20:16 +0100 Subject: [PATCH] Auto-update containers : test on frigate --- deploy.sh | 2 +- templates/nix-config/podman/frigate.nix | 30 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/deploy.sh b/deploy.sh index bc3726c..d748ad6 100644 --- a/deploy.sh +++ b/deploy.sh @@ -311,7 +311,7 @@ disks_selection() { echo -e "\n\n ⚠️ One boot disk selected, continuing with striped boot disk configuration." echo -e "Consider using 2 boot disks instead to get data protection features on the boot disks." export BOOT_DISK_1_ID="${BOOT_DISKS_ID[0]}" - export BOOT_DISK_1_NAME="${DISK_NAME[0]}" + export BOOT_DISK_1_NAME="${BOOT_DISKS_NAME[0]}" elif [[ "${#BOOT_DISKS_ID[@]}" -eq 2 ]]; then echo -e "\n\n ✅ Two boot disks selected, continuing with mirrored boot disks configuration." echo -e "\n\n ⚠️ If the two disks are different sizes, the resulting usable space size will be \ diff --git a/templates/nix-config/podman/frigate.nix b/templates/nix-config/podman/frigate.nix index 4d6e118..3e66260 100644 --- a/templates/nix-config/podman/frigate.nix +++ b/templates/nix-config/podman/frigate.nix @@ -53,27 +53,45 @@ in external: true ''; - systemd.services.${container_name} = { + systemd.services."${container_name}" = { description = "Podman container : ${container_name}"; after = [ "network.target" ]; requires = [ "traefik.service" "home-assistant.service" ]; wantedBy = [ "multi-user.target" ]; - path = [ pkgs.podman ]; + path = [ pkgs.podman pkgs.coreutils ]; serviceConfig = { User = "numbus-admin"; Environment = [ "XDG_RUNTIME_DIR=/run/user/1000" ]; Type = "exec"; - # Pull the latest image before running - ExecStartPre = "${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} pull"; - # Bring the service up + ExecStartPre = [ + "${pkgs.coreutils}/bin/sleep 180" + "-${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} pull" + ]; ExecStart = "${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} up --remove-orphans"; - # Take it down gracefully ExecStop = "${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} down"; Restart = "on-failure"; RestartSec = "5m"; StartLimitBurst = "3"; }; }; + + systemd.services."update-${container_name}" = { + description = "Update ${container_name} container"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.systemd}/bin/systemctl restart ${container_name}.service"; + }; + }; + + systemd.timers."update-${container_name}" = { + timerConfig = { + OnCalendar = "daily"; + OnCalendar = "02:00"; + RandomizedDelaySec = "60m"; + Unit = "update-${container_name}.service"; + }; + wantedBy = [ "timers.target" ]; + }; }; } \ No newline at end of file