Subject: [alpine-devel] [PATCH] testing/quicktun: added init script and config file

From: Johannes Matheis <[email-masked]>
Date: Sat, 13 Dec 2014 19:41:10 +0000

---
 testing/quicktun/APKBUILD             | 23 ++++++++++++-----
 testing/quicktun/quicktun.conf        | 47 +++++++++++++++++++++++++++++++++++
 testing/quicktun/quicktun.initd       | 25 +++++++++++++++++++
 testing/quicktun/quicktun.pre-install |  5 ++++
 4 files changed, 94 insertions(+), 6 deletions(-)
 create mode 100644 testing/quicktun/quicktun.conf
 create mode 100755 testing/quicktun/quicktun.initd
 create mode 100755 testing/quicktun/quicktun.pre-install

diff --git a/testing/quicktun/APKBUILD b/testing/quicktun/APKBUILD
index 9007e2c..abad6be 100644
--- a/testing/quicktun/APKBUILD
+++ b/testing/quicktun/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Johannes Matheis <[email-masked]>
 pkgname=quicktun
 pkgver=2.2.4
-pkgrel=1
+pkgrel=2
 pkgdesc="Simple and secure VPN software using NaCl encryption"
 url="http://wiki.ucis.nl/QuickTun"
 arch="all"
@@ -10,9 +10,11 @@ license="BSD"
 depends=""
 depends_dev="tar libsodium-dev"
 makedepends="$depends_dev"
-install=""
+install="quicktun.pre-install"
 subpackages="$pkgname-keypair"
-source="http://oss.ucis.nl/${pkgname}/src/${pkgname}-${pkgver}.tgz"
+source="http://oss.ucis.nl/${pkgname}/src/${pkgname}-${pkgver}.tgz
+	quicktun.initd
+	quicktun.conf"
 
 _builddir="$srcdir/${pkgname}-${pkgver}"
 prepare() {
@@ -34,13 +36,22 @@ package() {
 	cd "$_builddir"
 	install -D out/quicktun.combined "${pkgdir}/usr/bin/quicktun.combined"
 	ln -s quicktun.combined "${pkgdir}/usr/bin/quicktun"
+	install -D -m600 ${srcdir}/quicktun.conf "${pkgdir}"/etc/quicktun/quicktun.conf
+	install -D -m755 ${srcdir}/quicktun.initd "${pkgdir}"/etc/init.d/quicktun
 }
+
 keypair() {
 	pkgdesc="Tool to create a quicktun public/private keypair"
 	cd "$_builddir"
 	install -D out/quicktun.keypair "${subpkgdir}/usr/bin/quicktun.keypair"
 }
 
-md5sums="5e27c9b1ccae0c6d6e4b30ca476f910d  quicktun-2.2.4.tgz"
-sha256sums="652383d30f4a1ac2d42500e676f4c8590efaeea21a1e40a3ad1c332aa2ba3a0c  quicktun-2.2.4.tgz"
-sha512sums="da60fc39d8e85d5b2c162633840b887be3fd58d9f2b3a99fe605fa13546e4f53878ce6246d835b7931e42193fb044330c539b29751cdb6f54d025efc52041487  quicktun-2.2.4.tgz"
+md5sums="5e27c9b1ccae0c6d6e4b30ca476f910d  quicktun-2.2.4.tgz
+66a25dd9e7212001123e78901477337c  quicktun.initd
+097c43021134f43294c894464099a8fb  quicktun.conf"
+sha256sums="652383d30f4a1ac2d42500e676f4c8590efaeea21a1e40a3ad1c332aa2ba3a0c  quicktun-2.2.4.tgz
+53b6d6fbeb5267a62618f9b4fe992436d48d6b1c80940c698cd08132828094e8  quicktun.initd
+787a37b2fbae6b44adebd422e6476da08c37c8db6bf0ac35a8d790ba4c50fe59  quicktun.conf"
+sha512sums="da60fc39d8e85d5b2c162633840b887be3fd58d9f2b3a99fe605fa13546e4f53878ce6246d835b7931e42193fb044330c539b29751cdb6f54d025efc52041487  quicktun-2.2.4.tgz
+8d6808d3d359a25c489d344cd40d6e69df052deaba56414c23c8244bd6cf4f95a4ac1b498ceb5a3503bfb5ebf0511cb234fd8d75bba712bd8ef1a653cd97e9d6  quicktun.initd
+6056ea4d4f8f8c58198a101b0f59f258e9318c3b57b6efbc6f3587665315b5b5990dee5662a27ee0e15a2333446c1d18b2a3650af7abbfbb4fe572c002b2a1b7  quicktun.conf"
diff --git a/testing/quicktun/quicktun.conf b/testing/quicktun/quicktun.conf
new file mode 100644
index 0000000..6b839e8
--- /dev/null
+++ b/testing/quicktun/quicktun.conf
@@ -0,0 +1,47 @@
+# To run multiple quicktun instances, copy this file to /etc/quicktun/example.conf,
+# create a symlink /etc/init.d/quicktun.example -> quicktun
+# and initialize the tunnel by issuing: rc-service quicktun.example start
+
+# interface name
+#export INTERFACE=
+
+# set to 1 to operate in tun (IP), unset or 0 (recent versions only) for tap (Ethernet) mode
+#export TUN_MODE=0
+
+# set to 1 to include packet information header in wire packets, must be set on both sides if
+# used; set to 2 to automatically add the packet information header for cross-platform compatibility
+# (also compatible with USE_PI=0), some (BSD) kernels need USE_PI to be enabled for IPv6 support
+#export USE_PI=0
+
+# IP address or hostname of the remote end (use 0.0.0.0 for a floating/dynamic remote endpoint)
+#export REMOTE_ADDRESS=0.0.0.0
+
+# IP address or hostname of the local end, optional
+#export LOCAL_ADDRESS=
+
+# local UDP port, optional, defaults to 2998
+#export LOCAL_PORT=2998
+
+# remote UDP port, optional, defaults to LOCAL_PORT
+#export REMOTE_PORT=${LOCAL_PORT}
+
+# allows the remote address and port to change when properly encrypted packets are received
+#export REMOTE_FLOAT=
+
+# run specified command or script after the tunnel device has been opened
+#export TUN_UP_SCRIPT=
+
+# drop privileges and change user and group IDs to specified username after setting up the tunnel
+export SETUID=quicktun
+
+# nacl0, nacltai and salty (encrypted) protocols only:
+#export PRIVATE_KEY= # local secret key in hexadecimal form (not needed for raw protocol)
+#export PUBLIC_KEY= # remote public key in hexadecimal form (not needed for raw protocol)
+#export PRIVATE_KEY_FILE= # file containing local secret key in binary or hexadecimal form (not needed for raw protocol)
+
+# nacltai (encrypted) protocol only:
+# allowed time window for first received packet in seconds (positive number allows packets from history)
+#export TIME_WINDOW=
+
+# the protocol to use, one of "raw", "nacl0" and "nacltai"
+#export PROTOCOL=raw
diff --git a/testing/quicktun/quicktun.initd b/testing/quicktun/quicktun.initd
new file mode 100755
index 0000000..0ea4955
--- /dev/null
+++ b/testing/quicktun/quicktun.initd
@@ -0,0 +1,25 @@
+#!/sbin/runscript
+
+VPN=${SVCNAME#*.}
+if [ ${SVCNAME} != "quicktun" ]; then
+  pidfile="/var/run/quicktun.${VPN}.pid"
+else
+  pidfile="/var/run/quicktun.pid"
+fi
+
+command=/usr/bin/quicktun
+
+start() {
+  if [ -e "/etc/quicktun/${VPN}.conf" ]
+  then
+    source "/etc/quicktun/${VPN}.conf"
+  else
+    eerror "Config /etc/quicktun/${VPN}.conf not found"
+    exit 1
+  fi
+
+  ebegin "Starting ${SVCNAME}"
+  start-stop-daemon --start --exec ${command} --pidfile ${pidfile} \
+    --background --make-pidfile
+  eend $?
+}
diff --git a/testing/quicktun/quicktun.pre-install b/testing/quicktun/quicktun.pre-install
new file mode 100755
index 0000000..c17d220
--- /dev/null
+++ b/testing/quicktun/quicktun.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+addgroup -S quicktun
+adduser -S -h /var/run/quicktun -s /sbin/nologin -G quicktun -g "quicktun user" -H -D quicktun
+exit 0
+
-- 
2.2.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---