summaryrefslogtreecommitdiffstats
path: root/net/ptunnel/files/ptunnel.init
blob: 3b10d41d94d9a8ef90fda72751c5624137d11143 (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
#!/bin/sh /etc/rc.common
# Copyright (C) 2007-2012 OpenWrt.org

START=70

start_instance() {
	local section="$1"

	config_get interface "$section" interface
	network_get_device ifname "$interface" || {
		echo "${initscript}: Error: Interface '$interface' not found" 1>&2
		return 1
	}

	SERVICE_PID_FILE="/var/run/ptunnel.$ifname.pid"
	service_start /usr/sbin/ptunnel -c "$ifname" -daemon $SERVICE_PID_FILE
}

start() {
	. /lib/functions/network.sh

	config_load 'ptunnel'
	config_foreach start_instance 'ptunnel'
	iptables -I OUTPUT 1 -p icmp -j ACCEPT 2>/dev/null
}

stop() {
	service_stop /usr/sbin/ptunnel
	iptables -D OUTPUT -p icmp -j ACCEPT 2>/dev/null
}