aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/servicewatchdog/services_servicewatchdog_add.php2
-rw-r--r--config/servicewatchdog/servicewatchdog.inc44
-rw-r--r--config/servicewatchdog/servicewatchdog.xml2
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
5 files changed, 48 insertions, 4 deletions
diff --git a/config/servicewatchdog/services_servicewatchdog_add.php b/config/servicewatchdog/services_servicewatchdog_add.php
index 791b973d..11e5e284 100644
--- a/config/servicewatchdog/services_servicewatchdog_add.php
+++ b/config/servicewatchdog/services_servicewatchdog_add.php
@@ -95,7 +95,7 @@ include("head.inc");
<select name="svcid" class="formselect" id="svcid">
<?php $i=0;
foreach ($system_services as $svc): ?>
- <?php if (!empty($svc['name']) && !in_array($svc['name'], $a_pwservice_names)): ?>
+ <?php if (!servicewatchdog_is_service_watched($svc)): ?>
<?php $svc['description'] = empty($svc['description']) ? get_pkg_descr($svc['name']) : $svc['description']; ?>
<option value="<?= $i ?>"><?=$svc['name'];?>: <?= strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description'];?></option>
<?php endif;
diff --git a/config/servicewatchdog/servicewatchdog.inc b/config/servicewatchdog/servicewatchdog.inc
index 6e5f1f55..1bdb1ce9 100644
--- a/config/servicewatchdog/servicewatchdog.inc
+++ b/config/servicewatchdog/servicewatchdog.inc
@@ -4,6 +4,50 @@ require_once("services.inc");
require_once("service-utils.inc");
require_once("util.inc");
+function servicewatchdog_service_matches($svc1, $svc2) {
+ /* If the arrays are equal, it must be the same service. */
+ if ($svc1 == $svc2)
+ return true;
+ /* If the names are different, they must not be the same. */
+ if ($svc1['name'] != $svc2['name'])
+ return false;
+ switch ($svc1['name']) {
+ case "openvpn":
+ if (($svc1['mode'] == $svc2['mode']) && ($svc1['vpnid'] == $svc2['vpnid']))
+ return true;
+ else
+ return false;
+ break;
+ case "captiveportal":
+ if ($svc1['zone'] == $svc2['zone'])
+ return true;
+ else
+ return false;
+ break;
+ default:
+ /* Other services must be the same if the name matches. */
+ return true;
+ }
+}
+
+function servicewatchdog_is_service_watched($svc) {
+ global $config;
+ if (!is_array($config['installedpackages']['servicewatchdog']['item'])) {
+ $config['installedpackages']['servicewatchdog']['item'] = array();
+ }
+ $a_pwservices = &$config['installedpackages']['servicewatchdog']['item'];
+ $blacklisted_services = array("cron");
+
+ if (empty($svc['name']) || in_array($svc['name'], $blacklisted_services))
+ return true;
+
+ foreach ($a_pwservices as $a_svc) {
+ if (servicewatchdog_service_matches($svc, $a_svc))
+ return true;
+ }
+ return false;
+}
+
function servicewatchdog_cron_job() {
global $config;
if (!is_array($config['installedpackages']['servicewatchdog']['item'])) {
diff --git a/config/servicewatchdog/servicewatchdog.xml b/config/servicewatchdog/servicewatchdog.xml
index 3b2e1320..5e1ce309 100644
--- a/config/servicewatchdog/servicewatchdog.xml
+++ b/config/servicewatchdog/servicewatchdog.xml
@@ -40,7 +40,7 @@
<requirements>None</requirements>
<faq>Monitors for stopped services and restarts them.</faq>
<name>Service Watchdog</name>
- <version>1.3</version>
+ <version>1.4</version>
<title>Services: Service Watchdog</title>
<include_file>/usr/local/pkg/servicewatchdog.inc</include_file>
<menu>
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 6fbef650..c5feebc4 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -1954,7 +1954,7 @@
<name>Service Watchdog</name>
<descr>Monitors for stopped services and restarts them.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>1.3</version>
+ <version>1.4</version>
<category>Services</category>
<status>BETA</status>
<config_file>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml</config_file>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index a11684d8..3bad6e86 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -1941,7 +1941,7 @@
<name>Service Watchdog</name>
<descr>Monitors for stopped services and restarts them.</descr>
<maintainer>jimp@pfsense.org</maintainer>
- <version>1.3</version>
+ <version>1.4</version>
<category>Services</category>
<status>BETA</status>
<config_file>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml</config_file>