git: 958cdc4cbf51 - main - dns/doh-proxy: Add rc script

From: Ashish SHUKLA <ashish_at_FreeBSD.org>
Date: Sat, 31 Aug 2024 13:58:10 UTC
The branch main has been updated by ashish:

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

commit 958cdc4cbf51590f032c8a653bd3ec5137b3b252
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-08-31 13:44:34 +0000
Commit:     Ashish SHUKLA <ashish@FreeBSD.org>
CommitDate: 2024-08-31 13:57:34 +0000

    dns/doh-proxy: Add rc script
    
    PR:             256829
---
 dns/doh-proxy/Makefile           |  4 +++-
 dns/doh-proxy/files/doh-proxy.in | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/dns/doh-proxy/Makefile b/dns/doh-proxy/Makefile
index cdca83b5c188..a6030e46c347 100644
--- a/dns/doh-proxy/Makefile
+++ b/dns/doh-proxy/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	doh-proxy
 DISTVERSION=	0.9.11
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	dns
 MASTER_SITES=	CRATESIO
 DISTFILES=	${CARGO_DIST_SUBDIR}/${DISTNAME}${CARGO_CRATE_EXT}
@@ -15,6 +15,8 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 BROKEN_i386=	fails to build
 USES=		cargo
 
+USE_RC_SUBR=	doh-proxy
+
 PLIST_FILES=	bin/doh-proxy
 
 # make cargo-crates > Makefile.crates
diff --git a/dns/doh-proxy/files/doh-proxy.in b/dns/doh-proxy/files/doh-proxy.in
new file mode 100644
index 000000000000..dc656afb51e5
--- /dev/null
+++ b/dns/doh-proxy/files/doh-proxy.in
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# PROVIDE: doh-proxy
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+# Add the following line in /etc/rc.conf to enable doh-proxy:
+#
+# doh_proxy_enable="YES"
+# doh_proxy_flags="<set as needed>"
+#
+
+. /etc/rc.subr
+
+name=doh_proxy
+rcvar=doh_proxy_enable
+
+load_rc_config ${name}
+
+: ${doh_proxy_enable:="NO"}
+: ${doh_proxy_flags:=""}
+
+command="%%PREFIX%%/bin/doh-proxy"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+doh_proxy_start()
+{
+    echo -n "Starting ${name}."
+    /usr/sbin/daemon -u nobody -S -p ${pidfile} \
+        ${command} ${doh_proxy_flags} && \
+        echo "Done"
+}
+
+run_rc_command "$1"