From 4297e7c70f8ef77be386d7a7690f2a75c6b47eb6 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 12 Apr 2016 23:20:52 +0200 Subject: [PATCH] smart: final brush up, will be a plugin with 16.1.11 --- src/www/diag_smart.php | 217 +++++------------------------------------ 1 file changed, 25 insertions(+), 192 deletions(-) diff --git a/src/www/diag_smart.php b/src/www/diag_smart.php index d3cfd610a..e6a99d5d4 100644 --- a/src/www/diag_smart.php +++ b/src/www/diag_smart.php @@ -31,8 +31,6 @@ require_once("guiconfig.inc"); $smartctl = "/usr/local/sbin/smartctl"; -$smartd = "/usr/local/sbin/smartd"; -$start_script = "/usr/local/etc/rc.d/smartd.sh"; $valid_test_types = array("offline", "short", "long", "conveyance"); $valid_info_types = array("i", "H", "c", "A", "a"); @@ -71,25 +69,6 @@ function add_colors($string) return preg_replace($patterns, $replacements, $string); } -// Edits smartd.conf file, adds or removes email for failed disk reporting -function update_email($email) -{ - // Did they pass an email? - if (!empty($email)) { - // Put it in the smartd.conf file - shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN -H -m " . escapeshellarg($email) . "/' /usr/local/etc/smartd.conf"); - } else { - // Remove email flags in smartd.conf - shell_exec("/usr/bin/sed -i old 's/^DEVICESCAN.*/DEVICESCAN/' /usr/local/etc/smartd.conf"); - } -} - -function smartmonctl($action) -{ - global $start_script; - shell_exec($start_script . escapeshellarg($action)); -} - // What page, aka. action is being wanted // If they "get" a page but don't pass all arguments, smartctl will throw an error $action = (isset($_POST['action']) ? $_POST['action'] : $_GET['action']); @@ -152,114 +131,6 @@ switch($action) { break; } - // Config changes, users email in xml config and write changes to smartd.conf - case 'config': - { - if(isset($_POST['submit'])) - { - // DOES NOT WORK YET... - if($_POST['testemail']) - { -// FIXME shell_exec($smartd . " -M test -m " . $config['system']['smartmonemail']); - $savemsg = sprintf(gettext("Email sent to %s"), $config['system']['smartmonemail']); - smartmonctl("stop"); - smartmonctl("start"); - } - else - { - $config['system']['smartmonemail'] = $_POST['smartmonemail']; - write_config(); - - // Don't know what all this means, but it addes the config changed header when config is saved - $retval = 0; - if(stristr($retval, "error") <> true) - $savemsg = get_std_save_message(); - else - $savemsg = $retval; - - if($_POST['email']) - { - // Write the changes to the smartd.conf file - update_email($_POST['smartmonemail']); - } - - // Send sig HUP to smartd, rereads the config file - shell_exec("/usr/bin/killall -HUP smartd"); - } - } - // Was the config changed? if so , print the message - if (isset($savemsg)) print_info_box($savemsg); - // Get users email from the xml file - $pconfig['smartmonemail'] = $config['system']['smartmonemail']; - - ?> - - - - - -
- -
- -
- - - - - - - - - - - - - - -
- -
  - - - " class="formbtn" /> -
-
- - -
- - - - - - - - - - - - - - -
  - -
  - - - " class="formbtn" /> -
-
- - - - - 0) print_input_errors($input_errors); ?> - -
- -
-

-
- -
+
-
- + + + @@ -314,35 +176,27 @@ switch($action) { " /> -
- - - - +   +   +   +  
-
-
-
- -
-

-
- -
+
-
- + + + @@ -367,33 +221,24 @@ switch($action) { " /> - -
- - - +   +   +  
-
+
-
- -
- -
-

-
- -
+
-
- + + + @@ -418,28 +263,19 @@ switch($action) { " /> -
- +  
-
-
- -
- -
-

-
- -
+
-
- + + + -
@@ -460,12 +296,9 @@ switch($action) { " class="btn btn-primary" onclick="return confirm('')" />
-
-