git: 1e38c92fd199 - main - security/tailscale: Add suupport for extra arguments

From: Ashish SHUKLA <ashish_at_FreeBSD.org>
Date: Sat, 22 Oct 2022 04:52:14 UTC
The branch main has been updated by ashish:

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

commit 1e38c92fd199d83be41d4a15b894a45e552cf1be
Author:     Ashish SHUKLA <ashish@FreeBSD.org>
AuthorDate: 2022-10-21 16:12:08 +0000
Commit:     Ashish SHUKLA <ashish@FreeBSD.org>
CommitDate: 2022-10-22 04:50:12 +0000

    security/tailscale: Add suupport for extra arguments
    
    Add a rc.conf variable to support passing extra arguments to tailscale
    up.
    
    Thanks to Gregory for advicing on the implementation.
    
    Reported by:    Gregory Shapiro <gshapiro at gshapiro dot net>
---
 security/tailscale/Makefile            | 1 +
 security/tailscale/files/tailscaled.in | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/security/tailscale/Makefile b/security/tailscale/Makefile
index 390cb5f50d63..e041a8b7991a 100644
--- a/security/tailscale/Makefile
+++ b/security/tailscale/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	tailscale
 PORTVERSION=	1.32.0
+PORTREVISION=	1
 DISTVERSIONPREFIX=	v
 CATEGORIES=	security net-vpn
 
diff --git a/security/tailscale/files/tailscaled.in b/security/tailscale/files/tailscaled.in
index f70c8cd71873..cfa72604f5e3 100644
--- a/security/tailscale/files/tailscaled.in
+++ b/security/tailscale/files/tailscaled.in
@@ -19,6 +19,8 @@
 #						Default is "daemon". See daemon(8).
 # tailscaled_exitnode_enable (bool):	Set it to YES to announce tailscaled as
 #                                       an exit node. Default is "NO".
+# tailscaled_up_args (str):		Additional arguments to pass to tailscale up
+#                                       Default is "" (empty string).
 # tailscaled_tun_dev (str):	Set the name of the tun interface tailscaled creates.
 #				Default is "tailscale0"
 
@@ -32,6 +34,7 @@ load_rc_config $name
 : ${tailscaled_enable:="NO"}
 : ${tailscaled_port:="41641"}
 : ${tailscaled_exitnode_enable:="NO"}
+: ${tailscaled_up_args:=""}
 : ${tailscaled_tun_dev:="tailscale0"}
 
 DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?)
@@ -78,7 +81,10 @@ tailscaled_poststart()
 {
         if checkyesno tailscaled_exitnode_enable; then
 		logger -s -t tailscale "Enabling Exit node mode"
-                ${ctlname} up --advertise-exit-node
+		tailscaled_up_args=" --advertise-exit-node ${tailscaled_up_args}"
+        fi
+        if [ -n "${tailscaled_up_args}" ]; then
+                ${ctlname} up ${tailscaled_up_args}
         fi
 }