public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
* [git.ipfire.org] IPFire 2.x development tree branch, next, updated. ef08f8ca36b32203d08d2a5d6d9d7850eda5bd9f
@ 2026-05-27 11:10 Michael Tremer
  0 siblings, 0 replies; only message in thread
From: Michael Tremer @ 2026-05-27 11:10 UTC (permalink / raw)
  To: ipfire-scm

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, next has been updated
       via  ef08f8ca36b32203d08d2a5d6d9d7850eda5bd9f (commit)
       via  b725c89d8c34400df4342a265474a8c37ee1c3e1 (commit)
       via  79edbe52bba41ca998f3bfeec8930c6faf6e0b8a (commit)
       via  745104e06a9e53b72ebe3529dcefd005438c7618 (commit)
      from  4494939c7e41c144d040daf24a7b2bc0371f1d16 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ef08f8ca36b32203d08d2a5d6d9d7850eda5bd9f
Author: Michael Tremer <michael.tremer@ipfire.org>
Date:   Wed May 27 12:10:02 2026 +0100

    knot resolver: Backup the leases database
    
    Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

commit b725c89d8c34400df4342a265474a8c37ee1c3e1
Author: Michael Tremer <michael.tremer@ipfire.org>
Date:   Wed May 27 12:09:25 2026 +0100

    knot resolver: Rename the leases database
    
    It should simply be called like the module is called.
    
    Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

commit 79edbe52bba41ca998f3bfeec8930c6faf6e0b8a
Author: Michael Tremer <michael.tremer@ipfire.org>
Date:   Wed May 27 12:07:56 2026 +0100

    knot resolver: Create the leases database at build time
    
    Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

commit 745104e06a9e53b72ebe3529dcefd005438c7618
Author: Michael Tremer <michael.tremer@ipfire.org>
Date:   Wed May 27 12:04:18 2026 +0100

    knot-resolver: Move the leases schema into a separate file
    
    Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

-----------------------------------------------------------------------

Summary of changes:
 config/backup/include                 |  1 +
 config/knot-resolver/dhcp-lease       | 22 ++++++----------------
 config/knot-resolver/leases.lua       |  2 +-
 config/knot-resolver/leases.schema    | 13 +++++++++++++
 config/rootfiles/common/knot-resolver |  2 ++
 lfs/knot-resolver                     |  8 ++++++++
 6 files changed, 31 insertions(+), 17 deletions(-)
 create mode 100644 config/knot-resolver/leases.schema

Difference in files:
diff --git a/config/backup/include b/config/backup/include
index b547d1520..92b3510be 100644
--- a/config/backup/include
+++ b/config/backup/include
@@ -56,6 +56,7 @@ var/ipfire/urlfilter
 var/ipfire/vpn
 var/ipfire/wireguard
 var/lib/ipblocklist
+var/lib/knot-resolver/leases.db
 var/lib/suricata
 var/log/ip-acct/*
 var/log/rrd/*
diff --git a/config/knot-resolver/dhcp-lease b/config/knot-resolver/dhcp-lease
index 982bd3566..5dcfeaa7e 100644
--- a/config/knot-resolver/dhcp-lease
+++ b/config/knot-resolver/dhcp-lease
@@ -1,25 +1,15 @@
 #!/bin/bash
 
-readonly DB_PATH="/var/lib/knot-resolver/dhcp-leases.db"
+readonly DB_PATH="/var/lib/knot-resolver/leases.db"
 
 main() {
 	# Create the database if it does not exist
 	if [ ! -f "${DB_PATH}" ]; then
-		sqlite3 "${DB_PATH}" >/dev/null <<EOF
-			-- Create schema
-			CREATE TABLE IF NOT EXISTS leases(
-				address TEXT PRIMARY KEY,
-				hostname TEXT NOT NULL
-			);
-			CREATE UNIQUE INDEX IF NOT EXISTS
-				leases_address ON leases(address);
-			CREATE UNIQUE INDEX IF NOT EXISTS
-				leases_hostname ON leases(hostname COLLATE NOCASE);
-
-			-- Run in WAL mode
-			PRAGMA journal_mode=WAL;
-			PRAGMA synchronous=NORMAL;
-EOF
+		if ! sqlite3 "${DB_PATH}" >/dev/null \
+				</usr/lib/knot-resolver/leases.schema; then
+			echo "${0}: Failed to create database" >&2
+			return 1
+		fi
 	fi
 
 	local action="${1}"
diff --git a/config/knot-resolver/leases.lua b/config/knot-resolver/leases.lua
index a78a800c5..e07885e60 100644
--- a/config/knot-resolver/leases.lua
+++ b/config/knot-resolver/leases.lua
@@ -1,7 +1,7 @@
 -- Load modules
 local sqlite3 = require("lsqlite3")
 
-local DB_PATH = "/var/lib/knot-resolver/dhcp-leases.db"
+local DB_PATH = "/var/lib/knot-resolver/leases.db"
 local TTL = 60
 
 local M = {}
diff --git a/config/knot-resolver/leases.schema b/config/knot-resolver/leases.schema
new file mode 100644
index 000000000..23587939c
--- /dev/null
+++ b/config/knot-resolver/leases.schema
@@ -0,0 +1,13 @@
+CREATE TABLE IF NOT EXISTS leases(
+	address TEXT PRIMARY KEY,
+	hostname TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX IF NOT EXISTS
+	leases_address ON leases(address);
+CREATE UNIQUE INDEX IF NOT EXISTS
+	leases_hostname ON leases(hostname COLLATE NOCASE);
+
+-- Run in WAL mode
+PRAGMA journal_mode=WAL;
+PRAGMA synchronous=NORMAL;
diff --git a/config/rootfiles/common/knot-resolver b/config/rootfiles/common/knot-resolver
index 67068f984..11f90b165 100644
--- a/config/rootfiles/common/knot-resolver
+++ b/config/rootfiles/common/knot-resolver
@@ -100,6 +100,7 @@ usr/lib/knot-resolver/kres_modules/view.lua
 usr/lib/knot-resolver/kres_modules/watchdog.lua
 usr/lib/knot-resolver/kres_modules/workarounds.lua
 usr/lib/knot-resolver/krprint.lua
+usr/lib/knot-resolver/leases.schema
 usr/lib/knot-resolver/postconfig.lua
 usr/lib/knot-resolver/sandbox.lua
 usr/lib/knot-resolver/trust_anchors.lua
@@ -269,4 +270,5 @@ usr/sbin/kresd
 #usr/share/man/man8/kresd.8
 var/cache/knot-resolver
 var/lib/knot-resolver
+var/lib/knot-resolver/leases.db
 var/lib/knot-resolver/root.keys
diff --git a/lfs/knot-resolver b/lfs/knot-resolver
index 451f605bf..5ca378f1e 100644
--- a/lfs/knot-resolver
+++ b/lfs/knot-resolver
@@ -102,6 +102,14 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	install -v -m 644 $(DIR_SRC)/config/knot-resolver/leases.lua \
 		/usr/lib/knot-resolver/kres_modules/leases.lua
 
+	# Install the leases schema
+	install -v -m 6444 $(DIR_SRC)/config/knot-resolver/leases.schema \
+		/usr/lib/knot-resolver/leases.schema
+
+	# Create the leases database
+	sqlite3 "/var/lib/knot-resolver/leases.db" \
+		< /usr/lib/knot-resolver/leases.schema
+
 	# Install the DHCP leases helper script
 	install -v -m 755 $(DIR_SRC)/config/knot-resolver/dhcp-lease \
 		/usr/sbin/dhcp-lease


hooks/post-receive
--
IPFire 2.x development tree


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-27 11:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-27 11:10 [git.ipfire.org] IPFire 2.x development tree branch, next, updated. ef08f8ca36b32203d08d2a5d6d9d7850eda5bd9f Michael Tremer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox