Subject: [PATCH] testing/tailscale: new aport

From: Robert Günzler <[email-masked]>
Date: Sun, 3 Jan 2021 17:27:00 +0300

https://tailscale.com
The easiest, most secure way to use WireGuard and 2FA.
---
 testing/tailscale/APKBUILD               | 70 ++++++++++++++++++++++++
 testing/tailscale/tailscale.confd        |  5 ++
 testing/tailscale/tailscale.initd        | 27 +++++++++
 testing/tailscale/tailscale.logrotate    |  6 ++
 testing/tailscale/tailscale.modules-load |  1 +
 5 files changed, 109 insertions(+)
 create mode 100644 testing/tailscale/APKBUILD
 create mode 100644 testing/tailscale/tailscale.confd
 create mode 100644 testing/tailscale/tailscale.initd
 create mode 100644 testing/tailscale/tailscale.logrotate
 create mode 100644 testing/tailscale/tailscale.modules-load

diff --git a/testing/tailscale/APKBUILD b/testing/tailscale/APKBUILD
new file mode 100644
index 0000000000..689091eeec
--- /dev/null
+++ b/testing/tailscale/APKBUILD
@@ -0,0 +1,70 @@
+# Contributor: Robert Günzler <[email-masked]>
+# Maintainer: Robert Günzler <[email-masked]>
+pkgname=tailscale
+pkgver=1.2.10
+pkgrel=0
+pkgdesc="The easiest, most secure way to use WireGuard and 2FA."
+url="https://tailscale.com/"
+arch="all !mips !mips64"
+license="MIT"
+options="chmod-clean !check" # No test suite from upstream
+depends="iptables"
+makedepends="go linux-headers"
+subpackages="$pkgname-doc $pkgname-openrc"
+source="$pkgname-$pkgver.tar.gz::https://github.com/tailscale/tailscale/archive/v$pkgver.tar.gz
+	tailscale.confd
+	tailscale.initd
+	tailscale.logrotate
+	tailscale.modules-load
+	"
+builddir="$srcdir/src/github.com/tailscale/$pkgname"
+
+prepare() {
+	export GOPATH="$srcdir"
+
+	mkdir -p "$(dirname $builddir)"
+	mv "$srcdir"/$pkgname-$pkgver "$builddir"/
+
+	default_prepare
+}
+
+build() {
+	msg2 "Prepare GOPATH and GOBIN..."
+	export GOPATH="$srcdir"
+	export GOBIN="$GOPATH/bin"
+
+	msg2 "Building tailscale..."
+
+	TAGS="netcgo osusergo static_build xversion"
+	VERSIONFLAGS="
+	-X tailscale.com/version.Short=$pkgver
+	-X tailscale.com/version.Long=${pkgver}-AlpineLinux
+	-X tailscale.com/version.GitCommit=AlpineLinux
+	"
+	GOLDFLAGS="-w -s"
+
+	go build -tags "$TAGS" -ldflags "$VERSIONFLAGS $GOLDFLAGS" ./cmd/tailscale
+	go build -tags "$TAGS" -ldflags "$VERSIONFLAGS $GOLDFLAGS" ./cmd/tailscaled
+}
+
+package() {
+	install -m755 -D tailscale \
+		"$pkgdir"/usr/bin/tailscale
+	install -m755 -D tailscaled \
+		"$pkgdir"/usr/sbin/tailscaled
+
+	install -m644 -D -t "$pkgdir"/usr/share/doc/$pkgname README.md
+
+	install -m755 -D "$srcdir"/tailscale.initd "$pkgdir"/etc/init.d/tailscale
+	install -m644 -D "$srcdir"/tailscale.confd "$pkgdir"/etc/conf.d/tailscale
+	install -m644 -D "$srcdir"/tailscale.logrotate "$pkgdir"/etc/logrotate.d/tailscale
+	install -m644 -D "$srcdir"/tailscale.modules-load "$pkgdir"/etc/modules-load.d/tailscale.conf
+}
+
+sha512sums="
+67046bf9e5d49058d8f510e4541f50e5bbdd0cca2a6ca76f3e98734d3244f79ddcb7e23da29854b9ef7064227b42b24793b4992d983156ab6d65940c6b5e6b79  tailscale-1.2.10.tar.gz
+24706f10a6f5f7091c0f73a13e0c2d72e969e92e6f7aa21abe504f8e2c16af4d1d80fd28c33acbe4866dd8174abd9dc201d97eb5271f6355f7589a56f470f52c  tailscale.confd
+f43aa46608a7b9e7339fdf782c51f68a4a0ec87b4a987fe32c6f03cebc25c219b6adc9de758665d98024abf17e67b26098bbcd914fec329ae893bf10a37a883d  tailscale.initd
+c139461ff829359bfdc66866ef4cd6561f781e2bc3b40e5cfe9c9d06e3e749d179835ee8548d2b2e725f9a59644db64b1136393dff78ae29955c905e76c8ef46  tailscale.logrotate
+871b650ff982be061532b4c5fe4812f41e6e2c58fc69b24f8a745f9a43389da44e742a69b0467b3c3d9e2b031af0728e20f10fa4584695c4f5ac87768a1fd34e  tailscale.modules-load
+"
diff --git a/testing/tailscale/tailscale.confd b/testing/tailscale/tailscale.confd
new file mode 100644
index 0000000000..3f35df4bac
--- /dev/null
+++ b/testing/tailscale/tailscale.confd
@@ -0,0 +1,5 @@
+# tailscaled options
+#
+# TAILSCALED_LOGFILE
+# TAILSCALED_PORT
+# TAILSCALED_OPTS
diff --git a/testing/tailscale/tailscale.initd b/testing/tailscale/tailscale.initd
new file mode 100644
index 0000000000..4790c34a89
--- /dev/null
+++ b/testing/tailscale/tailscale.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+
+TAILSCALED_LOGFILE="${TAILSCALED_LOGFILE:-/var/log/${RC_SVCNAME}d.log}"
+TAILSCALED_PORT="${TAILSCALED_PORT:-41641}"
+
+supervisor=supervise-daemon
+
+name="tailscaled"
+command="/usr/sbin/tailscaled"
+command_args="--state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port ${TAILSCALED_PORT} ${TAILSCALED_OPTS} >>${TAILSCALED_LOGFILE} 2>&1"
+
+output_log=${TAILSCALED_LOGFILE}
+error_log=${TAILSCALED_LOGFILE}
+
+pidfile="/run/tailscaled.pid"
+respawn_delay=5
+respawn_max=0
+
+depend() {
+	need net
+	after firewall
+	use logger
+}
+
+start_pre() {
+	checkpath -f -m 0644 -o root:root "${TAILSCALED_LOGFILE}"
+}
diff --git a/testing/tailscale/tailscale.logrotate b/testing/tailscale/tailscale.logrotate
new file mode 100644
index 0000000000..c897172ffa
--- /dev/null
+++ b/testing/tailscale/tailscale.logrotate
@@ -0,0 +1,6 @@
+/var/log/tailscaled.log {
+        missingok
+        notifempty
+        sharedscripts
+        endscript
+}
diff --git a/testing/tailscale/tailscale.modules-load b/testing/tailscale/tailscale.modules-load
new file mode 100644
index 0000000000..0cb2f0a64b
--- /dev/null
+++ b/testing/tailscale/tailscale.modules-load
@@ -0,0 +1 @@
+tun
-- 
2.26.2