git: 46a10c978683 - main - security/headscale: add rc script and minimal working config
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Jul 2022 14:45:51 UTC
The branch main has been updated by woodsb02: URL: https://cgit.FreeBSD.org/ports/commit/?id=46a10c9786832983ef9b6afeebc030f8f4879bf2 commit 46a10c9786832983ef9b6afeebc030f8f4879bf2 Author: Christian McDonald <cmcdonald@netgate.com> AuthorDate: 2022-06-17 20:41:33 +0000 Commit: Ben Woods <woodsb02@FreeBSD.org> CommitDate: 2022-07-18 14:43:39 +0000 security/headscale: add rc script and minimal working config - Include rc script to enable/disable headscale service - Follow heir(7) with regards to headscale db, cache, config locations - Include a minimal configuration out of the box PR: 264744 Approved by: Michael Muenz <m.muenz@gmail.com> --- security/headscale/Makefile | 24 ++++++++++++++++++-- security/headscale/files/headscale.in | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/security/headscale/Makefile b/security/headscale/Makefile index db5148827dcd..a479bc62e156 100644 --- a/security/headscale/Makefile +++ b/security/headscale/Makefile @@ -1,7 +1,7 @@ PORTNAME= headscale PORTVERSION= 0.15.0 DISTVERSIONPREFIX= v -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= security MAINTAINER= m.muenz@gmail.com @@ -17,11 +17,31 @@ BROKEN_armv7= fails to compile: modernc.org/libc RUN_DEPENDS= ca_root_nss>0:security/ca_root_nss USES= go:modules +USE_RC_SUBR= headscale GO_MODULE= github.com/juanfont/headscale GO_TARGET= ./cmd/headscale -PLIST_FILES= bin/headscale +PLIST_FILES= ${ETCDIR}/config.yaml \ + "@dir /var/cache/${PORTNAME}" \ + "@dir /var/db/${PORTNAME}" \ + bin/${PORTNAME} + +post-patch: + @${REINPLACE_CMD} -e 's|/etc/headscale|${PREFIX}/etc/${PORTNAME}|g' \ + ${WRKSRC}/cmd/headscale/cli/utils.go + @${REINPLACE_CMD} -e 's|/var/lib/headscale/db.sqlite|/var/db/${PORTNAME}/db.sqlite|g' \ + ${WRKSRC}/config-example.yaml + @${REINPLACE_CMD} -e 's|/var/lib/headscale/cache|/var/cache/${PORTNAME}|g' \ + ${WRKSRC}/config-example.yaml + @${REINPLACE_CMD} -e 's|/var/lib/headscale/private.key|${PREFIX}/etc/${PORTNAME}/private.key|g' \ + ${WRKSRC}/config-example.yaml + +post-install: + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/${PORTNAME} + ${INSTALL_DATA} ${WRKSRC}/config-example.yaml ${STAGEDIR}${PREFIX}/etc/${PORTNAME}/config.yaml + ${MKDIR} ${STAGEDIR}/var/db/${PORTNAME} + ${MKDIR} ${STAGEDIR}/var/cache/${PORTNAME} .include <bsd.port.mk> diff --git a/security/headscale/files/headscale.in b/security/headscale/files/headscale.in new file mode 100644 index 000000000000..a3f4ada0b6f4 --- /dev/null +++ b/security/headscale/files/headscale.in @@ -0,0 +1,41 @@ +#!/bin/sh + +# PROVIDE: headscale +# REQUIRE: NETWORKING +# KEYWORD: shutdown +# + +. /etc/rc.subr + +name=headscale +rcvar=headscale_enable + +load_rc_config $name + +: ${headscale_enable:="NO"} +: ${headscale_syslog_output_enable:="NO"} +: ${headscale_syslog_output_priority:="info"} +: ${headscale_syslog_output_facility:="daemon"} + +if checkyesno headscale_syslog_output_enable; then + headscale_syslog_output_flags="-t ${name} -T ${name}" + + if [ -n "${headscale_syslog_output_priority}" ]; then + headscale_syslog_output_flags="${headscale_syslog_output_flags} -s ${headscale_syslog_output_priority}" + fi + + if [ -n "${headscale_syslog_output_facility}" ]; then + headscale_syslog_output_flags="${headscale_syslog_output_flags} -l ${headscale_syslog_output_facility}" + fi +fi + +pidfile=/var/run/${name}.pid +procname="%%PREFIX%%/bin/${name}" + +start_cmd="${name}_start" + +headscale_start() { + /usr/sbin/daemon -f ${headscale_syslog_output_flags} -p ${pidfile} ${procname} serve +} + +run_rc_command "$1"