From 335c5ffa2e047ea3400239feaf1f2b017e1a4a88 Mon Sep 17 00:00:00 2001 From: naturallaw77 Date: Fri, 27 Mar 2026 17:46:52 -0500 Subject: [PATCH] added script for domains --- modules/core/sovran-manage-domains.nix | 285 ++++++++++++++++++------- modules/element-calling.nix | 12 ++ modules/haven.nix | 3 + modules/synapse.nix | 3 + modules/vaultwarden.nix | 3 + 5 files changed, 231 insertions(+), 75 deletions(-) diff --git a/modules/core/sovran-manage-domains.nix b/modules/core/sovran-manage-domains.nix index ab44e26..5f91b24 100644 --- a/modules/core/sovran-manage-domains.nix +++ b/modules/core/sovran-manage-domains.nix @@ -3,7 +3,9 @@ let domains = config.sovran_systemsOS.domainRequirements; - # Build the domain prompts dynamically from registered modules + # Build list of domain names for the missing-check script + domainNamesList = lib.concatMapStringsSep " " (d: d.name) domains; + domainPrompts = lib.concatMapStringsSep "\n" (d: '' echo "" echo -e "''${GREEN}── ${d.label} ──''${NC}" @@ -30,104 +32,237 @@ curl \"''${DDNS_URL%auto}''${DOLLAR}{IP}\"" fi '') domains; - # Build the summary list + # Only prompt for domains that don't have a file yet + missingDomainPrompts = lib.concatMapStringsSep "\n" (d: '' + if [ ! -f "/var/lib/domains/${d.name}" ]; then + MISSING=true + echo "" + echo -e "''${GREEN}── ${d.label} (NEW) ──''${NC}" + read -p " Subdomain (e.g. ${d.example}): " DOMAIN + + if [ -n "$DOMAIN" ]; then + echo "$DOMAIN" > "/var/lib/domains/${d.name}" + echo " Saved: $DOMAIN" + ${lib.optionalString d.needsDDNS '' + read -p " Njal.la DDNS URL for $DOMAIN (paste full URL, or Enter to skip): " DDNS_URL + if [ -n "$DDNS_URL" ]; then + NEW_NJALLA_ENTRIES="$NEW_NJALLA_ENTRIES +curl \"''${DDNS_URL%auto}''${DOLLAR}{IP}\"" + fi + ''} + else + echo " Skipped." + fi + fi + '') domains; + domainSummary = lib.concatMapStringsSep "\n" (d: '' if [ -f "/var/lib/domains/${d.name}" ]; then echo " ${d.label}: $(cat /var/lib/domains/${d.name})" fi '') domains; -in -{ - environment.systemPackages = [ - (pkgs.writeShellScriptBin "sovran-setup-domains" '' - set -euo pipefail - GREEN='\033[0;32m' - YELLOW='\033[1;33m' - CYAN='\033[0;36m' - NC='\033[0m' - DOLLAR='$' + # ── Full setup (first boot) ───────────────────────────────── + setupScript = pkgs.writeShellScriptBin "sovran-setup-domains" '' + set -euo pipefail - echo "" - echo -e "''${CYAN}══════════════════════════════════════════════''${NC}" - echo -e "''${CYAN} Sovran_SystemsOS — Domain & DDNS Setup''${NC}" - echo -e "''${CYAN}══════════════════════════════════════════════''${NC}" - echo "" - echo -e "''${YELLOW}Before running this, you need:''${NC}" - echo "" - echo " 1. Domains/subdomains purchased on https://njal.la" - echo " 2. For each subdomain, add a Dynamic record in" - echo " your Njal.la dashboard." - echo " 3. Njal.la will give you a DDNS URL like:" - echo "" - echo -e " ''${CYAN}https://njal.la/update/?h=sub.domain.com&k=abc123&auto''${NC}" - echo "" - echo " Have those URLs ready." - echo "" - read -p "Press Enter to continue..." + GREEN='\033[0;32m' + YELLOW='\033[1;33m' + CYAN='\033[0;36m' + NC='\033[0m' + DOLLAR='$' - # ── Create directories ──────────────────────────── - mkdir -p /var/lib/domains - mkdir -p /var/lib/njalla + echo "" + echo -e "''${CYAN}══════════════════════════════════════════════''${NC}" + echo -e "''${CYAN} Sovran_SystemsOS — Domain & DDNS Setup''${NC}" + echo -e "''${CYAN}══════════════════════════════════════════════''${NC}" + echo "" + echo -e "''${YELLOW}Before running this, you need:''${NC}" + echo "" + echo " 1. Domains/subdomains purchased on https://njal.la" + echo " 2. For each subdomain, add a Dynamic record in" + echo " your Njal.la dashboard." + echo " 3. Njal.la will give you a DDNS URL like:" + echo "" + echo -e " ''${CYAN}https://njal.la/update/?h=sub.domain.com&k=abc123&auto''${NC}" + echo "" + echo " Have those URLs ready." + echo "" + read -p "Press Enter to continue..." - NJALLA_ENTRIES="" + # ── Create directories ──────────────────────────── + mkdir -p /var/lib/domains + mkdir -p /var/lib/njalla - # ── SSL Email ───────────────────────────────────── - echo "" - echo -e "''${GREEN}── SSL Certificate Email ──''${NC}" - echo "Let's Encrypt needs an email for certificate notifications." - EXISTING_EMAIL="" - if [ -f "/var/lib/domains/sslemail" ]; then - EXISTING_EMAIL=$(cat /var/lib/domains/sslemail) - echo -e " Current: ''${CYAN}$EXISTING_EMAIL''${NC}" - fi - read -p " Email address (or Enter to keep current): " EMAIL_INPUT - SSL_EMAIL="''${EMAIL_INPUT:-$EXISTING_EMAIL}" - if [ -n "$SSL_EMAIL" ]; then - echo "$SSL_EMAIL" > /var/lib/domains/sslemail - echo " Saved." - fi + NJALLA_ENTRIES="" - # ── Module domains (auto-generated from enabled modules) ── - ${domainPrompts} + # ── SSL Email ───────────────────────────────────── + echo "" + echo -e "''${GREEN}── SSL Certificate Email ──''${NC}" + echo "Let's Encrypt needs an email for certificate notifications." + EXISTING_EMAIL="" + if [ -f "/var/lib/domains/sslemail" ]; then + EXISTING_EMAIL=$(cat /var/lib/domains/sslemail) + echo -e " Current: ''${CYAN}$EXISTING_EMAIL''${NC}" + fi + read -p " Email address (or Enter to keep current): " EMAIL_INPUT + SSL_EMAIL="''${EMAIL_INPUT:-$EXISTING_EMAIL}" + if [ -n "$SSL_EMAIL" ]; then + echo "$SSL_EMAIL" > /var/lib/domains/sslemail + echo " Saved." + fi - # ── Write njalla.sh ─────────────────────────────── - echo "" - echo -e "''${GREEN}── Generating DDNS script ──''${NC}" + # ── All module domains ──────────────────────────── + ${domainPrompts} - cat > /var/lib/njalla/njalla.sh <