manatee: Update machine IP for ha.ppp.pm

This commit is contained in:
Alexander Heldt
2026-01-07 14:35:15 +01:00
parent 7a510c5d14
commit 6c74fb07a8
3 changed files with 65 additions and 1 deletions

View File

@@ -1,4 +1,9 @@
{ lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
nginxEnabled = config.mod.nginx.enable; nginxEnabled = config.mod.nginx.enable;
in in
@@ -54,6 +59,64 @@ in
}; };
}; };
systemd.user = {
timers = {
"update-hetzner-ha-dns" = {
unitConfig = {
Description = "updates Hetzner DNS for home-assistant";
};
timerConfig = {
Unit = "update-hetzner-ha-dns.service";
OnCalendar = "*-*-* *:00/30:00";
Persistent = true;
};
wantedBy = [ "timers.target" ];
};
};
services = {
"update-hetzner-ha-dns" = {
unitConfig = {
Description = "updates Hetzner DNS for home-assistant";
};
serviceConfig = {
Type = "exec";
EnvironmentFile = config.age.secrets.hetzner-dns.path;
};
path = [
pkgs.curl
pkgs.coreutils # For `cat`
];
script = ''
LAST_IP_FILE="/tmp/hetzner-dns-ha-ip"
INTERFACE="enp3s0"
CURRENT_IP=$(curl -s --fail --interface "$INTERFACE" ifconfig.me')
LAST_IP=""
if [[ -f "$LAST_IP_FILE" ]]; then
LAST_IP=$(cat "$LAST_IP_FILE")')
fi
if [[ "$CURRENT_IP" == "$LAST_IP" ]]; then
echo "IP unchanged, NOOP update."
exit 0
else
echo "checking DNS"
curl \
-H "Authorization: Bearer $HETZNER_API_TOKEN" \
"https://api.hetzner.cloud/v1/zones/$ZONE_NAME/rrsets/$RRSET_NAME/A"
fi
'';
};
};
};
age = { age = {
secrets = { secrets = {
"hetzner-dns".file = ../../../../secrets/manatee/hetzner-dns.age; "hetzner-dns".file = ../../../../secrets/manatee/hetzner-dns.age;

Binary file not shown.

View File

@@ -35,6 +35,7 @@ in {
"manatee/syncthing-cert.age".publicKeys = [ manatee alex ]; "manatee/syncthing-cert.age".publicKeys = [ manatee alex ];
"manatee/syncthing-key.age".publicKeys = [ manatee alex ]; "manatee/syncthing-key.age".publicKeys = [ manatee alex ];
"manatee/hetzner-dns.age".publicKeys = [ manatee alex ]; "manatee/hetzner-dns.age".publicKeys = [ manatee alex ];
"manatee/hetzner-dns-ha-env-vars.age".publicKeys = [ manatee alex ];
"backwards/root.backwards.age".publicKeys = [ backwards alex ]; "backwards/root.backwards.age".publicKeys = [ backwards alex ];
"backwards/root.backwards.pub.age".publicKeys = [ backwards alex ]; "backwards/root.backwards.pub.age".publicKeys = [ backwards alex ];