branch Attitude Adjustment packages
[12.09/packages.git] / net / ptunnel / files / ptunnel.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007-2012 OpenWrt.org
3
4 START=70
5
6 start_instance() {
7         local section="$1"
8
9         config_get interface "$section" interface
10         network_get_device ifname "$interface" || {
11                 echo "${initscript}: Error: Interface '$interface' not found" 1>&2
12                 return 1
13         }
14
15         SERVICE_PID_FILE="/var/run/ptunnel.$ifname.pid"
16         service_start /usr/sbin/ptunnel -c "$ifname" -daemon $SERVICE_PID_FILE
17 }
18
19 start() {
20         . /lib/functions/network.sh
21
22         config_load 'ptunnel'
23         config_foreach start_instance 'ptunnel'
24         iptables -I OUTPUT 1 -p icmp -j ACCEPT 2>/dev/null
25 }
26
27 stop() {
28         service_stop /usr/sbin/ptunnel
29         iptables -D OUTPUT -p icmp -j ACCEPT 2>/dev/null
30 }