Apply ptunnel patches from #2884
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 10 Jan 2008 18:25:04 +0000 (18:25 +0000)
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 10 Jan 2008 18:25:04 +0000 (18:25 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@10160 3c298f89-4303-0410-b956-a3cf2f4a3e73

net/ptunnel/Makefile
net/ptunnel/files/ptunnel.conf [new file with mode: 0644]
net/ptunnel/files/ptunnel.init

index d4aada5..91764bb 100644 (file)
@@ -49,6 +49,8 @@ define Package/ptunnel/install
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ptunnel $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/ptunnel.init $(1)/etc/init.d/ptunnel
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/ptunnel.conf $(1)/etc/config/ptunnel
 endef
 
 $(eval $(call BuildPackage,ptunnel))
diff --git a/net/ptunnel/files/ptunnel.conf b/net/ptunnel/files/ptunnel.conf
new file mode 100644 (file)
index 0000000..35781f9
--- /dev/null
@@ -0,0 +1,3 @@
+config ptunnel
+        option interface 'br-lan'
+       
\ No newline at end of file
index da3b143..f834bd4 100644 (file)
@@ -1,14 +1,27 @@
 #!/bin/sh /etc/rc.common
 # Copyright (C) 2007 OpenWrt.org
 START=70
-STOP=70
+BIN=ptunnel
 
 start() {
-        iptables -I OUTPUT 1 -p icmp -j ACCEPT
-       ptunnel -v 1 -c br-lan
+    config_load ptunnel
+    config_foreach start_ptunnel ptunnel
 }
-               
+
+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&
+}
+
 stop() {
-        killall ptunnel
+        ps aux | grep ptunnel |  awk '{print }' | \
+            xargs kill 2> /dev/null
 }
-                       
\ No newline at end of file
+                                                                       
\ No newline at end of file