diff --git a/src/etc/inc/miniupnpd.inc b/src/etc/inc/miniupnpd.inc index e092e51b3..cbc151a2f 100644 --- a/src/etc/inc/miniupnpd.inc +++ b/src/etc/inc/miniupnpd.inc @@ -139,12 +139,13 @@ function sync_package_miniupnpd() { /* if miniupnpd not running start it */ if(!upnp_running()) { upnp_notice("Starting service on interface: {$ifaces_active}"); - upnp_action('start'); + upnp_start(); } /* or restart miniupnpd if settings were changed */ else { upnp_notice("Restarting service on interface: {$ifaces_active}"); - upnp_action('restart'); + upnp_stop(); + upnp_start(); } } } else { @@ -157,7 +158,7 @@ function sync_package_miniupnpd() { else upnp_notice('Stopping service: no interfaces selected'); - upnp_action('stop'); + upnp_stop(); @unlink($config_file); } } diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index ac9edc16a..f48cbaa02 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -1,9 +1,10 @@ - Copyright (C) 2005-2006 Colin Smith + Copyright (C) 2014-2016 Franco Fichtner Copyright (C) 2010 Ermal Luci + Copyright (C) 2005-2006 Colin Smith + Copyright (C) 2003-2004 Manuel Kasper All rights reserved. Redistribution and use in source and binary forms, with or without @@ -2430,33 +2431,25 @@ function configure_cron() killbypid('/var/run/cron.pid', 'HUP'); } -function upnp_action($action) +function upnp_start() { - global $config; - - switch($action) { - case "start": - if (file_exists('/var/etc/miniupnpd.conf')) { - @unlink('/var/run/miniupnpd.pid'); - mwexec_bg('/usr/local/sbin/miniupnpd -f /var/etc/miniupnpd.conf -P /var/run/miniupnpd.pid'); - } - break; - case "stop": - killbypid('/var/run/miniupnpd.pid'); - while((int)exec("/bin/pgrep -a miniupnpd | wc -l") > 0) { - mwexec('killall miniupnpd 2>/dev/null', true); - } - mwexec('/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null'); - mwexec('/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null'); - break; - case "restart": - upnp_action('stop'); - upnp_action('start'); - break; + if (file_exists('/var/etc/miniupnpd.conf')) { + @unlink('/var/run/miniupnpd.pid'); + mwexec_bg('/usr/local/sbin/miniupnpd -f /var/etc/miniupnpd.conf -P /var/run/miniupnpd.pid'); } } -function upnp_start() +function upnp_stop() +{ + killbypid('/var/run/miniupnpd.pid'); + while((int)exec("/bin/pgrep -a miniupnpd | wc -l") > 0) { + mwexec('killall miniupnpd 2>/dev/null', true); + } + mwexec('/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null'); + mwexec('/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null'); +} + +function upnp_configure() { global $config; @@ -2467,7 +2460,6 @@ function upnp_start() } } - function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") { global $config; @@ -2644,6 +2636,11 @@ function services_get() $pconfig = array(); $pconfig['name'] = "miniupnpd"; $pconfig['description'] = gettext("UPnP Service"); + $pconfig['description'] = gettext("UPnP Service"); + $pconfig['php']['restart'] = array('upnp_stop', 'upnp_start'); + $pconfig['php']['start'] = array('upnp_start'); + $pconfig['php']['stop'] = array('upnp_stop'); + $pconfig['pidfile'] = '/var/run/miniupnpd.pid'; $services[] = $pconfig; } diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 39faca620..47d7e16be 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -341,7 +341,7 @@ if ($kern_hz == '1000') { services_igmpproxy_configure(); /* start the upnp daemon if it is enabled */ -upnp_start(); +upnp_configure(); /* If powerd is enabled, lets launch it */ activate_powerd(); diff --git a/src/www/status_services.php b/src/www/status_services.php index e7756d62a..865d25b49 100644 --- a/src/www/status_services.php +++ b/src/www/status_services.php @@ -84,10 +84,6 @@ function service_control_start($name, $extras) } } return $msg; - /* XXX extra argument is extra tricky */ - } elseif ($name == 'miniupnpd') { - upnp_action('start'); - return $msg; } $service = find_service_by_name($name); @@ -119,12 +115,6 @@ function service_control_stop($name, $extras) $msg = sprintf(gettext("%s has been stopped."), htmlspecialchars($name)); $filter = array(); - /* XXX extra argument is extra tricky */ - if ($name == 'miniupnpd') { - upnp_action('stop'); - return $msg; - } - if ($name == 'openvpn') { $filter['mode'] = $extras['vpnmode']; /* XXX I think mode is spurious */ $filter['vpnid'] = $extras['id']; @@ -192,7 +182,8 @@ function service_control_restart($name, $extras) { services_igmpproxy_configure(); break; case 'miniupnpd': - upnp_action('restart'); + upnp_stop(); + upnp_start(); break; case 'ipsec': vpn_ipsec_force_reload(); diff --git a/src/www/status_upnp.php b/src/www/status_upnp.php index 538a9655c..85afabc81 100644 --- a/src/www/status_upnp.php +++ b/src/www/status_upnp.php @@ -33,7 +33,8 @@ require_once("interfaces.inc"); if ($_POST) { if ($_POST['clear'] == "Clear") { - upnp_action('restart'); + upnp_stop(); + upnp_start(); $savemsg = gettext("Rules have been cleared and the daemon restarted"); } } @@ -111,7 +112,7 @@ include("head.inc");
- " /> . + .