git: b7b2320af6f7 - main - dns/knot3: Workaround due to bug in service(8): /usr/sbin/service: ERROR: USAGE: load_rc_config_var name var

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Thu, 23 Jan 2025 13:57:21 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b7b2320af6f78ddc1a92a0a605ceee49183ab6fc

commit b7b2320af6f78ddc1a92a0a605ceee49183ab6fc
Author:     Tomáš Čiernik <tomas@ciernik.sk>
AuthorDate: 2025-01-23 13:41:20 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-01-23 13:53:25 +0000

    dns/knot3: Workaround due to bug in service(8): /usr/sbin/service: ERROR: USAGE: load_rc_config_var name var
    
    /usr/sbin/service: ERROR: USAGE: load_rc_config_var name var
    
    This is very old and known bug in service(8) from 2016:
    https://bugs.freebsd.org/208534
    https://reviews.freebsd.org/D5833
    
    PR:             284100
    Approved by:    Leo Vandewoestijne <freebsd@dns.company> (maintainer)
    MFH:            2025Q1
---
 dns/knot3/Makefile      | 1 +
 dns/knot3/files/knot.in | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/dns/knot3/Makefile b/dns/knot3/Makefile
index 18fbd0e13dab..56bff20d0635 100644
--- a/dns/knot3/Makefile
+++ b/dns/knot3/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	knot
 DISTVERSION=	${KNOT_VERSION}
+PORTREVISION=	1
 CATEGORIES=	dns
 MASTER_SITES=	https://secure.nic.cz/files/knot-dns/ \
 		https://dns.company/downloads/knot-dns/
diff --git a/dns/knot3/files/knot.in b/dns/knot3/files/knot.in
index df885ed7c9c2..5c7807beca32 100644
--- a/dns/knot3/files/knot.in
+++ b/dns/knot3/files/knot.in
@@ -45,12 +45,18 @@
 
 . /etc/rc.subr
 
+# Workaround due to bug in service(8)
+name="$file" ;
+
 case "$0" in
 /etc/rc*)
 	# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
 	# so get the name of the script from $_file
 	name="$_file"
 	;;
+*/service)
+	# do not use this as $0
+	;;
 *)
 	name="$0"
 	;;