packages/net/ptunnel/files/ptunnel.init
acinonyx b2d015b012 [packages] ptunnel: Fix 'interface' option, handle multiple instances
git-svn-id: svn://svn.openwrt.org/openwrt/packages@17608 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-09-19 13:23:26 +00:00

41 lines
757 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2007-2009 OpenWrt.org
START=70
BIN=ptunnel
PIDCOUNT=0
start() {
include /lib/network
scan_interfaces
config_load ptunnel
config_foreach start_ptunnel ptunnel
iptables -I OUTPUT 1 -p icmp -j ACCEPT 2> /dev/null
}
start_ptunnel() {
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
}
stop() {
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
}