From 0b2c3440efef324c771681bbd32d7c6b73c0a9fe Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 28 Aug 2013 00:45:23 -0400 Subject: Rename to avoid potential confusion with existing utility. --- config/procwatch/procwatch.inc | 39 ---- config/procwatch/procwatch.xml | 72 ------- config/procwatch/procwatch_cron.php | 6 - config/procwatch/services_procwatch.php | 211 --------------------- config/procwatch/services_procwatch_add.php | 115 ----------- .../servicewatchdog/services_servicewatchdog.php | 211 +++++++++++++++++++++ .../services_servicewatchdog_add.php | 115 +++++++++++ config/servicewatchdog/servicewatchdog.inc | 39 ++++ config/servicewatchdog/servicewatchdog.xml | 72 +++++++ config/servicewatchdog/servicewatchdog_cron.php | 6 + pkg_config.8.xml | 6 +- pkg_config.8.xml.amd64 | 6 +- 12 files changed, 449 insertions(+), 449 deletions(-) delete mode 100644 config/procwatch/procwatch.inc delete mode 100644 config/procwatch/procwatch.xml delete mode 100644 config/procwatch/procwatch_cron.php delete mode 100644 config/procwatch/services_procwatch.php delete mode 100644 config/procwatch/services_procwatch_add.php create mode 100644 config/servicewatchdog/services_servicewatchdog.php create mode 100644 config/servicewatchdog/services_servicewatchdog_add.php create mode 100644 config/servicewatchdog/servicewatchdog.inc create mode 100644 config/servicewatchdog/servicewatchdog.xml create mode 100644 config/servicewatchdog/servicewatchdog_cron.php diff --git a/config/procwatch/procwatch.inc b/config/procwatch/procwatch.inc deleted file mode 100644 index b2210e03..00000000 --- a/config/procwatch/procwatch.inc +++ /dev/null @@ -1,39 +0,0 @@ - 0) { - // Add the cron job if it doesn't exist. - install_cron_job("/usr/local/pkg/procwatch_cron.php", true, "*/1"); - } else { - // Remove the cron job - install_cron_job("/usr/local/pkg/procwatch_cron.php", false, "*/1"); - } -} - -function procwatch_check_services() { - global $config; - if (!is_array($config['installedpackages']['procwatch']['item'])) { - $config['installedpackages']['procwatch']['item'] = array(); - } - $a_pwservices = &$config['installedpackages']['procwatch']['item']; - - foreach ($a_pwservices as $svc) { - if (!is_service_running($svc['name'])) { - $descr = strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description']; - log_error("ProcWatch detected service {$svc['name']} stopped. Restarting {$svc['name']} ({$descr})"); - service_control_start($svc['name'], $svc); - } - } -} - -?> \ No newline at end of file diff --git a/config/procwatch/procwatch.xml b/config/procwatch/procwatch.xml deleted file mode 100644 index 9db6d40d..00000000 --- a/config/procwatch/procwatch.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - ProcWatch - None - Monitors for stopped services and restarts them. - ProcWatch - 1.0 - Services: Procwatch - /usr/local/pkg/procwatch.inc - - ProcWatch - -
Services
- /services_procwatch.php -
- - /usr/local/www/ - 644 - http://www.pfsense.com/packages/config/procwatch/services_procwatch.php - - - /usr/local/www/ - 644 - http://www.pfsense.com/packages/config/procwatch/services_procwatch_add.php - - - /usr/local/pkg/ - 755 - http://www.pfsense.com/packages/config/procwatch/procwatch_cron.php - - - /usr/local/pkg/ - 644 - http://www.pfsense.com/packages/config/procwatch/procwatch.inc - -
\ No newline at end of file diff --git a/config/procwatch/procwatch_cron.php b/config/procwatch/procwatch_cron.php deleted file mode 100644 index f4cc7608..00000000 --- a/config/procwatch/procwatch_cron.php +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/local/bin/php -f - \ No newline at end of file diff --git a/config/procwatch/services_procwatch.php b/config/procwatch/services_procwatch.php deleted file mode 100644 index c8a16b07..00000000 --- a/config/procwatch/services_procwatch.php +++ /dev/null @@ -1,211 +0,0 @@ - $pd) { - if (preg_match("/move_(\d+)_x/", $pn, $matches)) { - $movebtn = $matches[1]; - break; - } - } - /* move selected services before this service */ - if (isset($movebtn) && is_array($_POST['pwservices']) && count($_POST['pwservices'])) { - $a_pwservices_new = array(); - - /* copy all services < $movebtn and not selected */ - for ($i = 0; $i < $movebtn; $i++) { - if (!in_array($i, $_POST['pwservices'])) - $a_pwservices_new[] = $a_pwservices[$i]; - } - - /* copy all selected services */ - for ($i = 0; $i < count($a_pwservices); $i++) { - if ($i == $movebtn) - continue; - if (in_array($i, $_POST['pwservices'])) - $a_pwservices_new[] = $a_pwservices[$i]; - } - - /* copy $movebtn service */ - if ($movebtn < count($a_pwservices)) - $a_pwservices_new[] = $a_pwservices[$movebtn]; - - /* copy all services > $movebtn and not selected */ - for ($i = $movebtn+1; $i < count($a_pwservices); $i++) { - if (!in_array($i, $_POST['pwservices'])) - $a_pwservices_new[] = $a_pwservices[$i]; - } - $a_pwservices = $a_pwservices_new; - procwatch_cron_job(); - write_config(); - header("Location: services_procwatch.php"); - return; - } -} - -$closehead = false; -$pgtitle = array(gettext("Services"),gettext("ProcWatch")); -include("head.inc"); - -?> - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - -
- -

-
  - - - - -
- - " border="0" alt="delete" /> - - " onclick="return confirm('')" /> - - " alt="add" />
-
- - - - - - - - - -
" height="17" type="image" width="17" border="0" />')">" alt="delete" />
-
- - - - - - - - -
" border="0" alt="move" />" border="0" alt="move" />
- - " border="0" alt="delete" /> - - " onclick="return confirm('')" /> - - " alt="add" />
-
- -
-
-
- - - diff --git a/config/procwatch/services_procwatch_add.php b/config/procwatch/services_procwatch_add.php deleted file mode 100644 index 457a93a4..00000000 --- a/config/procwatch/services_procwatch_add.php +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - -
- - - - - - - - - - - - -
- -
  - " /> " onclick="history.back()" /> -
-
- - - diff --git a/config/servicewatchdog/services_servicewatchdog.php b/config/servicewatchdog/services_servicewatchdog.php new file mode 100644 index 00000000..920fd1bb --- /dev/null +++ b/config/servicewatchdog/services_servicewatchdog.php @@ -0,0 +1,211 @@ + $pd) { + if (preg_match("/move_(\d+)_x/", $pn, $matches)) { + $movebtn = $matches[1]; + break; + } + } + /* move selected services before this service */ + if (isset($movebtn) && is_array($_POST['pwservices']) && count($_POST['pwservices'])) { + $a_pwservices_new = array(); + + /* copy all services < $movebtn and not selected */ + for ($i = 0; $i < $movebtn; $i++) { + if (!in_array($i, $_POST['pwservices'])) + $a_pwservices_new[] = $a_pwservices[$i]; + } + + /* copy all selected services */ + for ($i = 0; $i < count($a_pwservices); $i++) { + if ($i == $movebtn) + continue; + if (in_array($i, $_POST['pwservices'])) + $a_pwservices_new[] = $a_pwservices[$i]; + } + + /* copy $movebtn service */ + if ($movebtn < count($a_pwservices)) + $a_pwservices_new[] = $a_pwservices[$movebtn]; + + /* copy all services > $movebtn and not selected */ + for ($i = $movebtn+1; $i < count($a_pwservices); $i++) { + if (!in_array($i, $_POST['pwservices'])) + $a_pwservices_new[] = $a_pwservices[$i]; + } + $a_pwservices = $a_pwservices_new; + servicewatchdog_cron_job(); + write_config(); + header("Location: services_servicewatchdog.php"); + return; + } +} + +$closehead = false; +$pgtitle = array(gettext("Services"),gettext("Service Watchdog")); +include("head.inc"); + +?> + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +

+
  + + + + +
+ + " border="0" alt="delete" /> + + " onclick="return confirm('')" /> + + " alt="add" />
+
+ + + + + + + + + +
" height="17" type="image" width="17" border="0" />')">" alt="delete" />
+
+ + + + + + + + +
" border="0" alt="move" />" border="0" alt="move" />
+ + " border="0" alt="delete" /> + + " onclick="return confirm('')" /> + + " alt="add" />
+
+ +
+
+
+ + + diff --git a/config/servicewatchdog/services_servicewatchdog_add.php b/config/servicewatchdog/services_servicewatchdog_add.php new file mode 100644 index 00000000..e5335540 --- /dev/null +++ b/config/servicewatchdog/services_servicewatchdog_add.php @@ -0,0 +1,115 @@ + + + + + + + + + +
+ + + + + + + + + + + + +
+ +
  + " /> " onclick="history.back()" /> +
+
+ + + diff --git a/config/servicewatchdog/servicewatchdog.inc b/config/servicewatchdog/servicewatchdog.inc new file mode 100644 index 00000000..d96a0f75 --- /dev/null +++ b/config/servicewatchdog/servicewatchdog.inc @@ -0,0 +1,39 @@ + 0) { + // Add the cron job if it doesn't exist. + install_cron_job("/usr/local/pkg/servicewatchdog_cron.php", true, "*/1"); + } else { + // Remove the cron job + install_cron_job("/usr/local/pkg/servicewatchdog_cron.php", false, "*/1"); + } +} + +function servicewatchdog_check_services() { + global $config; + if (!is_array($config['installedpackages']['servicewatchdog']['item'])) { + $config['installedpackages']['servicewatchdog']['item'] = array(); + } + $a_pwservices = &$config['installedpackages']['servicewatchdog']['item']; + + foreach ($a_pwservices as $svc) { + if (!is_service_running($svc['name'])) { + $descr = strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description']; + log_error("Service Watchdog detected service {$svc['name']} stopped. Restarting {$svc['name']} ({$descr})"); + service_control_start($svc['name'], $svc); + } + } +} + +?> \ No newline at end of file diff --git a/config/servicewatchdog/servicewatchdog.xml b/config/servicewatchdog/servicewatchdog.xml new file mode 100644 index 00000000..70ecffe8 --- /dev/null +++ b/config/servicewatchdog/servicewatchdog.xml @@ -0,0 +1,72 @@ + + + + + + + + Service Watchdog + None + Monitors for stopped services and restarts them. + Service Watchdog + 1.0 + Services: Service Watchdog + /usr/local/pkg/servicewatchdog.inc + + Service Watchdog + +
Services
+ /services_servicewatchdog.php +
+ + /usr/local/www/ + 644 + http://www.pfsense.com/packages/config/servicewatchdog/services_servicewatchdog.php + + + /usr/local/www/ + 644 + http://www.pfsense.com/packages/config/servicewatchdog/services_servicewatchdog_add.php + + + /usr/local/pkg/ + 755 + http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog_cron.php + + + /usr/local/pkg/ + 644 + http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.inc + +
\ No newline at end of file diff --git a/config/servicewatchdog/servicewatchdog_cron.php b/config/servicewatchdog/servicewatchdog_cron.php new file mode 100644 index 00000000..5031ab0b --- /dev/null +++ b/config/servicewatchdog/servicewatchdog_cron.php @@ -0,0 +1,6 @@ +#!/usr/local/bin/php -f + \ No newline at end of file diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 6cf0d4b5..a6521070 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1951,16 +1951,16 @@ sudo-1.8.6p8-i386.pbi - ProcWatch + Service Watchdog Monitors for stopped services and restarts them. jimp@pfsense.org 1.0 Services BETA - http://www.pfsense.com/packages/config/procwatch/procwatch.xml + http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml 2.1 - procwatch.xml + servicewatchdog.xml diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 9d390583..15ff2856 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -1938,16 +1938,16 @@ sudo-1.8.6p8-amd64.pbi - ProcWatch + Service Watchdog Monitors for stopped services and restarts them. jimp@pfsense.org 1.0 Services BETA - http://www.pfsense.com/packages/config/procwatch/procwatch.xml + http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml 2.1 - procwatch.xml + servicewatchdog.xml -- cgit v1.2.3