aboutsummaryrefslogtreecommitdiffstats
path: root/main/tinc/tincd.lo.initd
blob: 38adfb8399f534e34435c884933d891c83960e52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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.lo,v 1.5 2013/09/01 12:22:46 blueness Exp $

extra_started_commands="reload"

DAEMON="/usr/sbin/tincd"

depend() {
	use logger dns
	need net
}

start() {
	NETNAME="${RC_SVCNAME#*.}"
	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}"
		eend $?
	fi
}

stop() {
	NETNAME="${RC_SVCNAME#*.}"
	CONFIG="/etc/tinc/${NETNAME}/tinc.conf"
	PIDFILE="/var/run/tinc.${NETNAME}.pid"
	if [ -f "${PIDFILE}" ] ; then
		ebegin "Stopping tinc network ${NETNAME}"
		start-stop-daemon --stop --pidfile "${PIDFILE}"
		eend $?
	fi
}

reload() {
	NETNAME=${RC_SVCNAME#*.}
	CONFIG="/etc/tinc/${NETNAME}/tinc.conf"
	PIDFILE="/var/run/tinc.${NETNAME}.pid"
	if [ -f "${PIDFILE}" ] ; then
			ebegin "Reloading tinc network ${NETNAME}"
			start-stop-daemon --signal HUP --pidfile "${PIDFILE}"
			eend $?
	fi
}