From 1f55d5f6265e1d5499249494e89f59d193af019f Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Sun, 22 Oct 2006 00:48:50 +0000 Subject: package fixed by: rsw686 via forums --- packages/miniupnpd/miniupnpd.inc | 112 ++++++++++++++++++++++--------------- packages/miniupnpd/miniupnpd.xml | 9 +-- packages/miniupnpd/status_upnp.php | 10 +--- 3 files changed, 73 insertions(+), 58 deletions(-) (limited to 'packages') diff --git a/packages/miniupnpd/miniupnpd.inc b/packages/miniupnpd/miniupnpd.inc index d536253c..fb81fdbc 100644 --- a/packages/miniupnpd/miniupnpd.inc +++ b/packages/miniupnpd/miniupnpd.inc @@ -1,69 +1,91 @@ &1 >/dev/null\n"; - $start .= "/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null\n"; - $start .= "/usr/bin/killall miniupnpd\n"; - $start .= "while [ `ps -A | grep /usr/local/sbin/miniupnpd | grep -v grep | wc -l` != 0 ]; do sleep 1; done\n"; - $start .= "/usr/local/sbin/miniupnpd -p 2869{$ifaces_final}"; - /* override wan ip address, common for carp, etc */ - if($overridewanip) - $start .= " -o {$overridewanip}"; + if($ifaces_final) { + /* valid paramters lets create rc file and start miniupnpd */ + + $start = "/usr/bin/killall miniupnpd\n"; + $start .= "# Clear existing rules and rdr entries \n"; + $start .= "/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null\n"; + $start .= "/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null\n"; + $start .= "while [ `pgrep miniupnpd | wc -l` != 0 ]; do sleep 1; done\n"; + $start .= "/usr/local/sbin/miniupnpd -p 2869{$ifaces_final}"; + + /* override wan ip address, common for carp, etc */ + if($overridewanip) + $start .= " -o {$overridewanip}"; + + $stop = "/usr/bin/killall miniupnpd \n"; + $stop .= "# Clear existing rules and rdr entries \n"; + $stop .= "/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null\n"; + $stop .= "/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null"; + write_rcfile(array( + "file" => "miniupnpd.sh", + "start" => $start, + "stop" => $stop + ) + ); - $stop .= "/usr/bin/killall miniupnpd \n"; - $stop .= "# Clear existing rules and rdr entries \n"; - $stop .= "/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null\n"; - $stop .= "/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null\n"; - write_rcfile(array( - "file" => "miniupnpd.sh", - "start" => $start, - "stop" => $stop - ) - ); + /* if not ONE instance running lets start */ + /* or if $_POST data as user is changing settings */ + if((int)exec("pgrep miniupnpd | wc -l") != 1 || $_POST['iface_array']) { + upnp_notice("Starting service"); + start_service("miniupnpd"); + } + } } - /* if not ONE instance running lets start */ - /* or if $_POST data as user is changing settings */ - if((int)exec("ps -A | grep /usr/local/sbin/miniupnpd | grep -v grep | wc -l") != 1 || $_POST['interface_array']) { - start_service("miniupnpd"); - } + if(!$iface_array || !$ifaces_final) { + /* no parameters user does not want miniupnpd running */ + /* lets stop the service and remove the rc file */ + + stop_service("miniupnpd"); + upnp_warn("No interfaces stopping service"); + exec("rm -f /usr/local/etc/rc.d/miniupnpd*"); + } config_unlock(); conf_mount_ro(); } -?> \ No newline at end of file +?> diff --git a/packages/miniupnpd/miniupnpd.xml b/packages/miniupnpd/miniupnpd.xml index 2f310d62..5f46ad64 100644 --- a/packages/miniupnpd/miniupnpd.xml +++ b/packages/miniupnpd/miniupnpd.xml @@ -46,7 +46,7 @@ Interface (generally LAN) - interface_array + iface_array lan true 3 @@ -57,16 +57,13 @@ overridewanip input - + - sync_package_miniupnpd(); + sync_package_miniupnpd(); sync_package_miniupnpd(); - - sync_package_miniupnpd(); - exec("rm -f /usr/local/etc/rc.d/miniupnpd*"); diff --git a/packages/miniupnpd/status_upnp.php b/packages/miniupnpd/status_upnp.php index 23bcc8ea..d1928ee0 100644 --- a/packages/miniupnpd/status_upnp.php +++ b/packages/miniupnpd/status_upnp.php @@ -32,16 +32,12 @@ require("guiconfig.inc"); /* Defaults to this page but if no settings are present, redirect to setup page */ -if(!is_array($config['installedpackages']['miniupnpd']['config'][0]['interface_array'])) - Header("Location: /pkg_edit.php?xml=miniupnpd.xml&id=0"); +if(!$config['installedpackages']['miniupnpd']['config'][0]['iface_array']) + Header("Location: /pkg_edit.php?xml=miniupnpd.xml&id=0"); if ($_POST) { if ($_POST['clear'] == "Clear") { - // stop - mwexec("/bin/sh /usr/local/etc/rc.d/miniupnpd.sh stop"); - usleep(300); - // start - mwexec("/bin/sh /usr/local/etc/rc.d/miniupnpd.sh start"); + mwexec("/bin/sh /usr/local/etc/rc.d/miniupnpd.sh restart"); $savemsg = "Rules have been cleared and the daemon restarted"; } } -- cgit v1.2.3