29 lines
787 B
Nix
Executable File
29 lines
787 B
Nix
Executable File
{ secrets, pkgs, ... }:
|
|
{
|
|
systemd.services.update-dns = {
|
|
serviceConfig.Type = "oneshot";
|
|
description = "Update the leaf.ninja DNS records";
|
|
path = with pkgs; [ curl ];
|
|
script = ''
|
|
public_ip=$(curl -s https://ifconfig.me/ip)
|
|
endpoint="https://api.gandi.net/v5/livedns/domains/leaf.ninja/records"
|
|
curl \
|
|
-X PUT \
|
|
-H "Authorization: Bearer ${secrets.gandi.token}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"rrset_values\":[\"$public_ip\"]}" \
|
|
$endpoint/ostiary/A
|
|
'';
|
|
};
|
|
|
|
systemd.timers.update-dns = {
|
|
wantedBy = [ "timers.target" ];
|
|
partOf = [ "update-dns.service" ];
|
|
timerConfig = {
|
|
OnBootSec = "15m";
|
|
OnUnitActiveSec = "15m";
|
|
Unit = "update-dns.service";
|
|
};
|
|
};
|
|
}
|