Files
webgui/plugins/dynamix/include/update.parity.php
2018-09-15 09:09:32 +02:00

44 lines
1.5 KiB
PHP

<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
$memory = '/tmp/memory.tmp';
if (isset($_POST['#apply'])) {
$cron = "";
if ($_POST['mode']>0) {
$time = $_POST['hour'] ?: '* *';
$dotm = $_POST['dotm'] ?: '*';
$month = $_POST['month'] ?: '*';
$day = $_POST['day'] ?: '*';
$write = $_POST['write'] ?: '';
$term = '';
switch ($dotm) {
case '28-31': $term = '[[ $(date +%e -d +1day) -eq 1 ]] && '; break;
case 'W1' : $dotm = '1-7'; break;
case 'W2' : $dotm = '8-14'; break;
case 'W3' : $dotm = '15-21'; break;
case 'W4' : $dotm = '22-28'; break;
case 'WL' : $dotm = '22-31'; $term = '[[ $(date +%e -d +7days) -le 7 ]] && '; break;
}
$cron = "# Generated parity check schedule:\n$time $dotm $month $day $term/usr/local/sbin/mdcmd check $write &> /dev/null || :\n\n";
}
parse_cron_cfg("dynamix", "parity-check", $cron);
@unlink($memory);
} else {
file_put_contents($memory, http_build_query($_POST));
$save = false;
}
?>