From eeca39baa8bca7318bed8df5b4d830d7d7f710b2 Mon Sep 17 00:00:00 2001
From: Matthew Baggett <matthew@baggett.me>
Date: Fri, 14 Feb 2025 21:23:19 +0100
Subject: [PATCH] Working ddclient.

---
 products/ddclient/ddclient.conf.tpl | 5 +++--
 products/ddclient/ddclient.tf       | 2 ++
 products/ddclient/inputs.tf         | 8 ++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/products/ddclient/ddclient.conf.tpl b/products/ddclient/ddclient.conf.tpl
index 7370a0d..6dfdd44 100644
--- a/products/ddclient/ddclient.conf.tpl
+++ b/products/ddclient/ddclient.conf.tpl
@@ -1,5 +1,6 @@
 # General Configuration
-daemon=300
+daemon=${interval}
+syslog=yes
 
 # Router
 usev4=${router}
@@ -10,4 +11,4 @@ protocol=${protocol}
 %{ if password != null }password=${password}%{ endif }
 %{ if apikey != null }apikey=${apikey}%{ endif }
 %{ if secretapikey != null }secretapikey=${secretapikey}%{ endif }
-${domain}
\ No newline at end of file
+%{ if onrootdomain == true }on-root-domain=yes %{ endif }${domain}
\ No newline at end of file
diff --git a/products/ddclient/ddclient.tf b/products/ddclient/ddclient.tf
index 646f0b8..966eeb3 100644
--- a/products/ddclient/ddclient.tf
+++ b/products/ddclient/ddclient.tf
@@ -15,6 +15,7 @@ module "service" {
   #}
   secrets = {
     "/defaults/ddclient.conf" = templatefile("${path.module}/ddclient.conf.tpl", {
+      interval     = var.interval_seconds
       protocol     = var.protocol
       router       = var.router
       login        = var.login
@@ -22,6 +23,7 @@ module "service" {
       apikey       = var.apikey
       secretapikey = var.secretapikey
       domain       = var.domain
+      onrootdomain = var.onrootdomain
     })
   }
   environment_variables = {
diff --git a/products/ddclient/inputs.tf b/products/ddclient/inputs.tf
index ab9eb6b..c3a8fab 100644
--- a/products/ddclient/inputs.tf
+++ b/products/ddclient/inputs.tf
@@ -1,3 +1,7 @@
+variable "interval_seconds" {
+  default = 300
+  type    = number
+}
 variable "stack_name" {
   default     = "dns"
   type        = string
@@ -18,6 +22,10 @@ variable "router" {
 variable "domain" {
   type = string
 }
+variable "onrootdomain" {
+  default = false
+  type    = bool
+}
 variable "login" {
   type    = string
   default = null