aboutsummaryrefslogtreecommitdiffstats
path: root/main/tinc/tincd.initd
blob: c302f4fe0c2dc06f5f3d7abd74f07a4ce3d96972 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
#!/sbin/runscript
# Copyright 1999-2004 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.5 2008/04/01 14:08:45 dragonheart Exp $

extra_started_commands="reload"
daemon=/usr/sbin/tincd

depend() {
	use logger dns
	need net
}

checkconfig() {
	if ! grep -q '^ *NETWORK:' /etc/conf.d/tinc.networks 
	then
		eerror "No VPN networks configured in /etc/conf.d/tinc.networks"
		return 1
	fi
}

start() {
	checkconfig || return 1
	ebegin "Starting tinc VPN networks"
	eend 0
	awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
	do
		if [ ! -f /etc/tinc/"$TINCNET"/tinc.conf ] 
		then
			eerror "Cannot start network $TINCNET, /etc/tinc/$TINCNET/tinc.conf does not exist !"
		else
			ebegin "Starting tinc network $TINCNET"
			$daemon --net="$TINCNET" --logfile=/var/log/tinc.$TINCNET.log --pidfile=/var/run/tinc.$TINCNET.pid
			eend $?
		fi
	done
}

stop() {
	ebegin "Stopping tinc VPN networks"
	eend 0
	awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
	do
		if [ -f /var/run/tinc."$TINCNET".pid ]
		then
			ebegin "Stopping tinc network $TINCNET"
			start-stop-daemon --stop --quiet --pidfile=/var/run/tinc.$TINCNET.pid --exec ${daemon}
			eend $?
		fi
	done
}

reload() {
	ebegin "Reloading configuration for tinc VPN networks"
	eend 0
	awk '/^ *NETWORK:/ { print $2 }' /etc/conf.d/tinc.networks | while read TINCNET
	do
		if [ -f /var/run/tinc."$TINCNET".pid ]
		then
			ebegin "Reloading tinc network $TINCNET"
			kill -1 $(awk '{ print $1 }' /var/run/tinc."$TINCNET".pid)
			eend $?
		fi
	done
}