2007-12-21 09:34:01 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2009-09-19 12:11:46 +00:00
|
|
|
# Copyright (C) 2007-2009 OpenWrt.org
|
2009-09-19 13:23:26 +00:00
|
|
|
|
2007-12-21 09:34:01 +00:00
|
|
|
START=70
|
2008-01-10 18:25:04 +00:00
|
|
|
BIN=ptunnel
|
2009-09-19 13:23:26 +00:00
|
|
|
PIDCOUNT=0
|
2007-12-21 09:34:01 +00:00
|
|
|
|
|
|
|
start() {
|
2009-09-19 13:23:26 +00:00
|
|
|
include /lib/network
|
|
|
|
scan_interfaces
|
|
|
|
|
|
|
|
config_load ptunnel
|
|
|
|
config_foreach start_ptunnel ptunnel
|
|
|
|
iptables -I OUTPUT 1 -p icmp -j ACCEPT 2> /dev/null
|
2007-12-21 09:34:01 +00:00
|
|
|
}
|
2008-01-10 18:25:04 +00:00
|
|
|
|
|
|
|
start_ptunnel() {
|
2009-09-19 13:23:26 +00:00
|
|
|
local section="$1"
|
|
|
|
|
|
|
|
config_get interface "$section" interface
|
|
|
|
config_get ifname "$interface" ifname
|
|
|
|
|
|
|
|
[ -z "$ifname" ] && {
|
|
|
|
echo "Error: Interface '$interface' not found" 1>&2
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
PIDCOUNT="$(( ${PIDCOUNT} + 1))"
|
|
|
|
${BIN} -c "$ifname" -daemon /var/run/ptunnel."$PIDCOUNT".pid> /dev/null
|
2008-01-10 18:25:04 +00:00
|
|
|
}
|
|
|
|
|
2007-12-21 09:34:01 +00:00
|
|
|
stop() {
|
2009-09-19 13:23:26 +00:00
|
|
|
local pidfile
|
|
|
|
|
|
|
|
for pidfile in `ls /var/run/${BIN}.*.pid`
|
|
|
|
do
|
|
|
|
start-stop-daemon -K -s KILL -p "${pidfile}" -n "${BIN}" >/dev/null
|
|
|
|
rm -f "${pidfile}"
|
|
|
|
done
|
2007-12-21 09:34:01 +00:00
|
|
|
}
|