From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- net-vpn/tinc/files/tinc-1.1-fix-paths.patch | 44 ++++++++++++++++ net-vpn/tinc/files/tinc.networks | 13 +++++ net-vpn/tinc/files/tincd-r1 | 78 +++++++++++++++++++++++++++++ net-vpn/tinc/files/tincd-r2 | 78 +++++++++++++++++++++++++++++ net-vpn/tinc/files/tincd.conf | 20 ++++++++ net-vpn/tinc/files/tincd_at.service | 10 ++++ 6 files changed, 243 insertions(+) create mode 100644 net-vpn/tinc/files/tinc-1.1-fix-paths.patch create mode 100644 net-vpn/tinc/files/tinc.networks create mode 100644 net-vpn/tinc/files/tincd-r1 create mode 100644 net-vpn/tinc/files/tincd-r2 create mode 100644 net-vpn/tinc/files/tincd.conf create mode 100644 net-vpn/tinc/files/tincd_at.service (limited to 'net-vpn/tinc/files') diff --git a/net-vpn/tinc/files/tinc-1.1-fix-paths.patch b/net-vpn/tinc/files/tinc-1.1-fix-paths.patch new file mode 100644 index 000000000000..519677dd5034 --- /dev/null +++ b/net-vpn/tinc/files/tinc-1.1-fix-paths.patch @@ -0,0 +1,44 @@ +diff -Naur tinc-1.1pre14.orig/src/names.c tinc-1.1pre14/src/names.c +--- tinc-1.1pre14.orig/src/names.c 2016-04-17 12:08:41.000000000 -0400 ++++ tinc-1.1pre14/src/names.c 2016-10-15 07:37:51.147064396 -0400 +@@ -86,36 +86,11 @@ + if(!pidfilename) + xasprintf(&pidfilename, "%s" SLASH "pid", confbase); + #else +- bool fallback = false; +- if(daemon) { +- if(access(LOCALSTATEDIR, R_OK | W_OK | X_OK)) +- fallback = true; +- } else { +- char fname[PATH_MAX]; +- snprintf(fname, sizeof fname, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); +- if(access(fname, R_OK)) { +- snprintf(fname, sizeof fname, "%s" SLASH "pid", confbase); +- if(!access(fname, R_OK)) +- fallback = true; +- } +- } ++ if(!logfilename) ++ xasprintf(&logfilename, "/var/log" SLASH "%s.log", identname); + +- if(!fallback) { +- if(!logfilename) +- xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname); +- +- if(!pidfilename) +- xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); +- } else { +- if(!logfilename) +- xasprintf(&logfilename, "%s" SLASH "log", confbase); +- +- if(!pidfilename) { +- if(daemon) +- logger(DEBUG_ALWAYS, LOG_WARNING, "Could not access " LOCALSTATEDIR SLASH " (%s), storing pid and socket files in %s" SLASH, strerror(errno), confbase); +- xasprintf(&pidfilename, "%s" SLASH "pid", confbase); +- } +- } ++ if(!pidfilename) ++ xasprintf(&pidfilename, "/run" SLASH "%s.pid", identname); + #endif + + if(!unixsocketname) { diff --git a/net-vpn/tinc/files/tinc.networks b/net-vpn/tinc/files/tinc.networks new file mode 100644 index 000000000000..e1844ce2ba24 --- /dev/null +++ b/net-vpn/tinc/files/tinc.networks @@ -0,0 +1,13 @@ +# file: /etc/conf.d/tinc.networks for /etc/init.d/tincd + +# In this file you define the tinc networks you want to connect to + +# USAGE: +# you add a network to the init script by defining: +# NETWORK: your_network_name +# +# if you want to connect to multiple VPN's just set them behind each other. e.g. +# NETWORK: foo +# NETWORK: bar +# +# this would join the network foo and the network bar. diff --git a/net-vpn/tinc/files/tincd-r1 b/net-vpn/tinc/files/tincd-r1 new file mode 100644 index 000000000000..ecfb24a6a64f --- /dev/null +++ b/net-vpn/tinc/files/tincd-r1 @@ -0,0 +1,78 @@ +#!/sbin/openrc-run +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_started_commands="reload" + +NETS="/etc/conf.d/tinc.networks" +DAEMON="/usr/sbin/tincd" + +depend() { + use logger dns + need net +} + +checkconfig() { + if [ "${RC_SVCNAME}" = "tincd" ] ; then + ALL_NETNAME="$(awk '/^ *NETWORK:/ { print $2 }' "${NETS}")" + else + ALL_NETNAME="${RC_SVCNAME#*.}" + fi + # warn this if still not found + if [ -z "${ALL_NETNAME}" ] ; then + eerror "No VPN networks configured in ${NETS}" + return 1 + fi + return 0 +} + +start() { + ebegin "Starting tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + CONFIG="/etc/tinc/${NETNAME}/tinc.conf" + PIDFILE="/var/run/tinc.${NETNAME}.pid" + if [ ! -f "${CONFIG}" ]; then + eerror "Cannot start network ${NETNAME}." + eerror "Please set up ${CONFIG} !" + else + ebegin "Starting tinc network ${NETNAME}" + if [ "${SYSLOG}" = "yes" ]; then + LOG="" + else + LOG="--logfile=/var/log/tinc.${NETNAME}.log" + fi + start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}" -- --net="${NETNAME}" ${LOG} --pidfile "${PIDFILE}" --debug="${DEBUG_LEVEL}" ${EXTRA_OPTS} + eend $? + fi + done +} + +stop() { + ebegin "Stopping tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/var/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Stopping tinc network ${NETNAME}" + start-stop-daemon --stop --pidfile "${PIDFILE}" + eend $? + fi + done +} + +reload() { + ebegin "Reloading configuration for tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/var/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Reloading tinc network ${NETNAME}" + start-stop-daemon --signal HUP --pidfile ${PIDFILE} + eend $? + fi + done +} diff --git a/net-vpn/tinc/files/tincd-r2 b/net-vpn/tinc/files/tincd-r2 new file mode 100644 index 000000000000..55728bec2c78 --- /dev/null +++ b/net-vpn/tinc/files/tincd-r2 @@ -0,0 +1,78 @@ +#!/sbin/openrc-run +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_started_commands="reload" + +NETS="/etc/conf.d/tinc.networks" +DAEMON="/usr/sbin/tincd" + +depend() { + use logger dns + need net +} + +checkconfig() { + if [ "${RC_SVCNAME}" = "tincd" ] ; then + ALL_NETNAME="$(awk '/^ *NETWORK:/ { print $2 }' "${NETS}")" + else + ALL_NETNAME="${RC_SVCNAME#*.}" + fi + # warn this if still not found + if [ -z "${ALL_NETNAME}" ] ; then + eerror "No VPN networks configured in ${NETS}" + return 1 + fi + return 0 +} + +start() { + ebegin "Starting tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + CONFIG="/etc/tinc/${NETNAME}/tinc.conf" + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ ! -f "${CONFIG}" ]; then + eerror "Cannot start network ${NETNAME}." + eerror "Please set up ${CONFIG} !" + else + ebegin "Starting tinc network ${NETNAME}" + if [ "${SYSLOG}" = "yes" ]; then + LOG="" + else + LOG="--logfile=/var/log/tinc.${NETNAME}.log" + fi + start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}" -- --net="${NETNAME}" ${LOG} --pidfile "${PIDFILE}" --debug="${DEBUG_LEVEL}" ${EXTRA_OPTS} + eend $? + fi + done +} + +stop() { + ebegin "Stopping tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Stopping tinc network ${NETNAME}" + start-stop-daemon --stop --pidfile "${PIDFILE}" + eend $? + fi + done +} + +reload() { + ebegin "Reloading configuration for tinc VPN networks" + checkconfig || return 1 + for NETNAME in ${ALL_NETNAME} + do + PIDFILE="/run/tinc.${NETNAME}.pid" + if [ -f "${PIDFILE}" ]; then + ebegin "Reloading tinc network ${NETNAME}" + start-stop-daemon --signal HUP --pidfile ${PIDFILE} + eend $? + fi + done +} diff --git a/net-vpn/tinc/files/tincd.conf b/net-vpn/tinc/files/tincd.conf new file mode 100644 index 000000000000..cedca60c42ad --- /dev/null +++ b/net-vpn/tinc/files/tincd.conf @@ -0,0 +1,20 @@ +#rc_need="net.net" + +#If you want tincd to log to syslog, then set this to "yes" +#Anything else and tincd will log to /var/log/tinc.NETNAME.log. +SYSLOG="yes" + +#Set debug level, useful for error probe +# 0 Quiet mode, only show starting/stopping of the daemon +# 1 Show (dis)connects of other tinc daemons via TCP +# 2 Show error messages received from other hosts +# 2 Show status messages received from other hosts +# 3 Show the requests that are sent/received +# 4 Show contents of every request that is sent/received +# 5 Show network traffic information +# 6 Show contents of each packet that is being sent/received +# 10 You have been warned +DEBUG_LEVEL="0" + +#Extra Options, if you want addtional customization +EXTRA_OPTS="" diff --git a/net-vpn/tinc/files/tincd_at.service b/net-vpn/tinc/files/tincd_at.service new file mode 100644 index 000000000000..71f358a39d95 --- /dev/null +++ b/net-vpn/tinc/files/tincd_at.service @@ -0,0 +1,10 @@ +[Unit] +Description=Tinc daemon for network %i +After=network.target + +[Service] +ExecStart=/usr/sbin/tincd -D --pidfile /run/tinc.%i.pid -n %i +Restart=on-failure + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3