From 3346eed1c7bdc472d061e30b30d26c5fcad5538c Mon Sep 17 00:00:00 2001 From: f Date: Sun, 19 Jun 2022 14:22:58 -0300 Subject: [PATCH] make tincd log to syslog there's an undocumented SYSLOG env var on tincd's rc --- tasks/post_install.yml | 1 + templates/etc/init.d/tincd.j2 | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 templates/etc/init.d/tincd.j2 diff --git a/tasks/post_install.yml b/tasks/post_install.yml index 5ecaa52..9005ac5 100644 --- a/tasks/post_install.yml +++ b/tasks/post_install.yml @@ -73,6 +73,7 @@ mode: "750" loop: - /etc/init.d/ntpd + - /etc/init.d/tincd - name: "Create NTP directories." file: state: "directory" diff --git a/templates/etc/init.d/tincd.j2 b/templates/etc/init.d/tincd.j2 new file mode 100755 index 0000000..a20978a --- /dev/null +++ b/templates/etc/init.d/tincd.j2 @@ -0,0 +1,65 @@ +#!/sbin/openrc-run +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/tinc/files/tincd,v 1.9 2013/09/01 12:22:46 blueness Exp $ + +extra_started_commands="reload" + +NETS="/etc/conf.d/tinc.networks" +DAEMON="/usr/sbin/tincd" + +depend() { + use logger dns + need net +} + +checkconfig() { + if ! grep -q '^ *NETWORK:' "${NETS}" ; then + eerror "No VPN networks configured in ${NETS}" + return 1 + fi +} + +start() { + checkconfig || return 1 + ebegin "Starting tinc VPN networks" + awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read 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}" + start-stop-daemon --start --exec "${DAEMON}" --pidfile "${PIDFILE}" -- --net="${NETNAME}" --pidfile "${PIDFILE}" + eend $? + fi + done +} + +stop() { + ebegin "Stopping tinc VPN networks" + awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read 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" + awk '/^ *NETWORK:/ { print $2 }' "${NETS}" | while read 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 +}