git: 55d213c5c990 - main - sysutils/ttyd: add daemon mode

From: Dave Cottlehuber <dch_at_FreeBSD.org>
Date: Wed, 25 Sep 2024 13:52:13 UTC
The branch main has been updated by dch:

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

commit 55d213c5c9903a133612983f6e0abaa7a6c796ba
Author:     Dave Cottlehuber <dch@FreeBSD.org>
AuthorDate: 2024-09-25 07:29:19 +0000
Commit:     Dave Cottlehuber <dch@FreeBSD.org>
CommitDate: 2024-09-25 13:50:48 +0000

    sysutils/ttyd: add daemon mode
    
    Differential Revision: https://reviews.freebsd.org/D45362
    
    Approved by:    nc (maintainer)
    Sponsored by:   SkunkWerks, GmbH
---
 sysutils/ttyd/Makefile      |  2 ++
 sysutils/ttyd/files/ttyd.in | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/sysutils/ttyd/Makefile b/sysutils/ttyd/Makefile
index 5c0f78cd6bc1..8f1aec83cd4f 100644
--- a/sysutils/ttyd/Makefile
+++ b/sysutils/ttyd/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	ttyd
 DISTVERSION=	1.7.7
+PORTREVISION=	1
 CATEGORIES=	sysutils
 
 MAINTAINER=	nc@FreeBSD.org
@@ -17,6 +18,7 @@ LIB_DEPENDS=	libjson-c.so:devel/json-c \
 USES=		cmake pkgconfig ssl
 USE_GITHUB=	yes
 GH_ACCOUNT=	tsl0922
+USE_RC_SUBR=	${PORTNAME}
 
 CMAKE_ARGS=	-DCMAKE_DISABLE_FIND_PACKAGE_Git:BOOL=True
 
diff --git a/sysutils/ttyd/files/ttyd.in b/sysutils/ttyd/files/ttyd.in
new file mode 100755
index 000000000000..56b8188deeda
--- /dev/null
+++ b/sysutils/ttyd/files/ttyd.in
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# PROVIDE: ttyd
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# ttyd_enable (bool):        Set to NO by default. Set it to YES to enable ttyd.
+# ttyd_acct (string):        Default user to run ttyd under, "nobody"
+# ttyd_exec (string):        Default command to run in ttyd, "/bin/sh"
+# ttyd_args (string):        Extra arguments passed to ttyd.
+#                            Default is "--interface lo0 --port 7681"
+
+. /etc/rc.subr
+
+name=ttyd
+rcvar=ttyd_enable
+
+load_rc_config $name
+
+: ${ttyd_enable:="NO"}
+: ${ttyd_acct:="nobody"}
+: ${ttyd_exec:="/bin/sh"}
+: ${ttyd_args:="--interface lo0 --port 7681"}
+
+procname="/usr/local/bin/${name}"
+
+command="/usr/sbin/daemon"
+command_args="-r -R 15 -f -t ${name} -T ttyd -u ${ttyd_acct} /usr/local/bin/ttyd ${ttyd_args} ${ttyd_exec}"
+
+run_rc_command "$1"