git: 7d9616b7e434 - main - comms/rtl-433: Add rc script

From: Rodrigo Osorio <rodrigo_at_FreeBSD.org>
Date: Sat, 20 Jan 2024 22:19:19 UTC
The branch main has been updated by rodrigo:

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

commit 7d9616b7e434ef3c057777caa929fc8de33e18a7
Author:     Rodrigo Osorio <rodrigo@FreeBSD.org>
AuthorDate: 2024-01-20 16:54:50 +0000
Commit:     Rodrigo Osorio <rodrigo@FreeBSD.org>
CommitDate: 2024-01-20 22:17:36 +0000

    comms/rtl-433: Add rc script
    
    rtl-433 can be started as a daemon process capturing radio messages
    and using several backends to store or propagate those messages.
---
 comms/rtl-433/Makefile         |  5 +++++
 comms/rtl-433/files/rtl_433.in | 34 ++++++++++++++++++++++++++++++++++
 comms/rtl-433/pkg-plist        |  1 +
 3 files changed, 40 insertions(+)

diff --git a/comms/rtl-433/Makefile b/comms/rtl-433/Makefile
index dd0a7c791227..b505965d2781 100644
--- a/comms/rtl-433/Makefile
+++ b/comms/rtl-433/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	rtl-433
 PORTVERSION=	23.11
+PORTREVISION=	1
 CATEGORIES=	comms hamradio
 
 MAINTAINER=	rodrigo@FreeBSD.org
@@ -17,5 +18,9 @@ USES=		cmake pkgconfig ssl
 USE_GITHUB=	yes
 GH_ACCOUNT=	merbanan
 GH_PROJECT=	rtl_433
+USE_RC_SUBR=	rtl_433
+
+post-install:
+	${INSTALL} ${WRKSRC}/conf/rtl_433.example.conf ${STAGEDIR}${PREFIX}/etc/rtl_433.conf
 
 .include <bsd.port.mk>
diff --git a/comms/rtl-433/files/rtl_433.in b/comms/rtl-433/files/rtl_433.in
new file mode 100755
index 000000000000..0d35810be2e6
--- /dev/null
+++ b/comms/rtl-433/files/rtl_433.in
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# PROVIDE: rtl_433
+# REQUIRE: DAEMON NETWORKING
+# KEYWORD: shutdown
+
+#
+# Add the following lines to /etc/rc.conf.local, /etc/rc.conf or
+# /etc/rc.conf.d/rtl_433 to enable this service:
+#
+# rtl_433_enable (bool):        Set to NO by default.
+#                               Set it to "YES" to enable rtl_433.
+# rtl_433_config (str):         Set to /usr/local/etc/rtl_433.conf by default.
+#                               Path to configuration file.
+# rtl_433_user (str):           Set to "root" by default.
+#                               User to run rtl_433
+
+. /etc/rc.subr
+
+name=rtl_433
+rcvar=rtl_433_enable
+
+load_rc_config $name
+
+: ${rtl_433_enable:="NO"}
+: ${rtl_433_config:="/usr/local/etc/rtl_433.conf"}
+: ${rtl_433_user:="root"}
+
+pidfile="/var/run/${name}.pid"
+procname="/usr/local/bin/${name}"
+command="/usr/sbin/daemon"
+command_args="-S -m 3 -s info -l daemon -p ${pidfile} ${procname} -c ${rtl_433_config}"
+
+run_rc_command "$1"
diff --git a/comms/rtl-433/pkg-plist b/comms/rtl-433/pkg-plist
index e238b9ab3ee6..735c47dfcbc6 100644
--- a/comms/rtl-433/pkg-plist
+++ b/comms/rtl-433/pkg-plist
@@ -1,4 +1,5 @@
 bin/rtl_433
+@sample etc/rtl_433.conf etc/rtl_433.conf.sample
 @sample etc/rtl_433/CAME-TOP432.conf etc/rtl_433/CAME-TOP432.conf.sample
 @sample etc/rtl_433/ContinentalRemote.conf etc/rtl_433/ContinentalRemote.conf.sample
 @sample etc/rtl_433/DrivewayAlert.conf etc/rtl_433/DrivewayAlert.conf.sample