From b2d015b0125122b8245224fa87ceb4668e12bea6 Mon Sep 17 00:00:00 2001 From: acinonyx Date: Sat, 19 Sep 2009 13:23:26 +0000 Subject: [PATCH] [packages] ptunnel: Fix 'interface' option, handle multiple instances git-svn-id: svn://svn.openwrt.org/openwrt/packages@17608 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/ptunnel/files/ptunnel.conf | 2 +- net/ptunnel/files/ptunnel.init | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/net/ptunnel/files/ptunnel.conf b/net/ptunnel/files/ptunnel.conf index ca645ff68..bfc74959e 100644 --- a/net/ptunnel/files/ptunnel.conf +++ b/net/ptunnel/files/ptunnel.conf @@ -1,2 +1,2 @@ config ptunnel - option interface 'br-lan' + option interface 'lan' diff --git a/net/ptunnel/files/ptunnel.init b/net/ptunnel/files/ptunnel.init index b3aabb9e1..99252d500 100644 --- a/net/ptunnel/files/ptunnel.init +++ b/net/ptunnel/files/ptunnel.init @@ -1,26 +1,40 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2007-2009 OpenWrt.org + START=70 BIN=ptunnel +PIDCOUNT=0 start() { - config_load ptunnel - config_foreach start_ptunnel ptunnel + 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" - - include /lib/network - scan_interfaces - - iptables -I OUTPUT 1 -p icmp -j ACCEPT - config_get interface "$section" interface - - $BIN -c "$interface" > /dev/null& + 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() { - ps aux | grep ptunnel | awk '{print }' | \ - xargs kill 2> /dev/null + 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 } -- 2.11.0