Extensible DDNS
This commit is contained in:
parent
82cd5fb545
commit
e08c4b27e2
4 changed files with 85 additions and 8 deletions
|
|
@ -1,13 +1,23 @@
|
|||
{ config, pkgs, inputs, ... }:
|
||||
{ config, pkgs, inputs, lib, ... }:
|
||||
let
|
||||
domain = "per-aspera.space";
|
||||
hostedZoneId = "Z09728753LLLNSYFXIBIM";
|
||||
|
||||
# Configurable list of DNS records to update
|
||||
dnsRecords = [
|
||||
domain
|
||||
"jellyfin.${domain}"
|
||||
# Add more records here as needed
|
||||
# "api.${domain}"
|
||||
# "mail.${domain}"
|
||||
];
|
||||
|
||||
updateRoute53 = pkgs.writeShellScript "update-route53" ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HOSTED_ZONE_ID="Z09728753LLLNSYFXIBIM"
|
||||
DOMAIN="${domain}"
|
||||
SUBDOMAIN="jellyfin.${domain}"
|
||||
HOSTED_ZONE_ID="${hostedZoneId}"
|
||||
DNS_RECORDS=(${lib.concatStringsSep " " (map lib.escapeShellArg dnsRecords)})
|
||||
|
||||
# Get current public IP
|
||||
CURRENT_IP=$(${pkgs.curl}/bin/curl -s https://ifconfig.me)
|
||||
|
|
@ -46,9 +56,10 @@ let
|
|||
fi
|
||||
}
|
||||
|
||||
# Update both records
|
||||
update_record "$DOMAIN"
|
||||
update_record "$SUBDOMAIN"
|
||||
# Update all configured records
|
||||
for record in "''${DNS_RECORDS[@]}"; do
|
||||
update_record "$record"
|
||||
done
|
||||
'';
|
||||
in {
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue