From 87ce6c9b47b4fb484918dce4ecc833b5c4b411f6 Mon Sep 17 00:00:00 2001 From: naturallaw77 Date: Fri, 27 Mar 2026 19:17:27 -0500 Subject: [PATCH] added njalla script --- modules/core/njalla_.nix | 32 ++++++++++++++++++++ modules/core/sovran-manage-domains.nix | 42 ++++++++------------------ modules/modules.nix | 1 + 3 files changed, 45 insertions(+), 30 deletions(-) create mode 100644 modules/core/njalla_.nix diff --git a/modules/core/njalla_.nix b/modules/core/njalla_.nix new file mode 100644 index 0000000..7677212 --- /dev/null +++ b/modules/core/njalla_.nix @@ -0,0 +1,32 @@ +{ config, pkgs, lib, ... }: + +{ + # ── Ensure njalla directory and base script exist on every build ── + systemd.tmpfiles.rules = [ + "d /var/lib/njalla 0750 root root -" + ]; + + # ── Create base njalla.sh if it doesn't exist yet ──────────── + systemd.services.njalla-init = { + description = "Initialize Njal.la DDNS script if missing"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + unitConfig = { + ConditionPathExists = "!/var/lib/njalla/njalla.sh"; + }; + script = '' + cat > /var/lib/njalla/njalla.sh <<'SCRIPT' +#!/usr/bin/env bash +IP=$(dig @resolver4.opendns.com myip.opendns.com +short -4) + +## Add DDNS entries below — one curl per line +## Run 'sudo sovran-setup-domains' to configure automatically +SCRIPT + + chmod 700 /var/lib/njalla/njalla.sh + ''; + }; +} \ No newline at end of file diff --git a/modules/core/sovran-manage-domains.nix b/modules/core/sovran-manage-domains.nix index 14aa2b7..7ac3eee 100644 --- a/modules/core/sovran-manage-domains.nix +++ b/modules/core/sovran-manage-domains.nix @@ -151,7 +151,6 @@ $PENDING_NJALLA" # ── Create directories ──────────────────────────── mkdir -p /var/lib/domains - mkdir -p /var/lib/njalla NJALLA_ENTRIES="" PENDING_NJALLA="" @@ -223,18 +222,13 @@ $PENDING_NJALLA" exit 1 fi - # ── Write njalla.sh ─────────────────────────────── - echo "" - printf "%b%s%b\n" "$GREEN" "── Generating DDNS script ──" "$NC" - - cat > /var/lib/njalla/njalla.sh <