diff --git a/src/etc/inc/plugins.inc.d/ntpd.inc b/src/etc/inc/plugins.inc.d/ntpd.inc index 1fb8c0c30..a85272291 100644 --- a/src/etc/inc/plugins.inc.d/ntpd.inc +++ b/src/etc/inc/plugins.inc.d/ntpd.inc @@ -417,6 +417,10 @@ function ntpd_configure_do($start_ntpd = true, $verbose = false) } } + if (!empty($config['ntpd']['custom_options'])) { + $ntpcfg .= "\n# custom options\n{$config['ntpd']['custom_options']}\n"; + } + file_put_contents('/var/etc/ntpd.conf', $ntpcfg); if (!$start_ntpd) { diff --git a/src/www/services_ntpd.php b/src/www/services_ntpd.php index 4859cfa6a..84828580e 100644 --- a/src/www/services_ntpd.php +++ b/src/www/services_ntpd.php @@ -54,6 +54,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // array types $pconfig['interface'] = !empty($pconfig['interface']) ? explode(",", $pconfig['interface']) : array(); + // text types + $pconfig['custom_options'] = !empty($a_ntpd['custom_options']) ? $a_ntpd['custom_options'] : ''; + // parse timeservers $pconfig['timeservers_host'] = array(); $pconfig['timeservers_noselect'] = array(); @@ -97,21 +100,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { unset($a_ntpd[$fieldname]); } } + if (empty($config['system']['timeservers'])) { unset($config['system']['timeservers']); } - if (!empty($a_ntpd['leapsec'])) { + if (!empty($pconfig['leapsec'])) { $a_ntpd['leapsec'] = base64_encode($a_ntpd['leapsec']); - } elseif(isset($config['ntpd']['leapsec'])) { - unset($config['ntpd']['leapsec']); + } elseif(isset($a_ntpd['leapsec'])) { + unset($a_ntpd['leapsec']); + } + + if (!empty($pconfig['custom_options'])) { + $a_ntpd['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']); + } elseif (isset($a_ntpd['custom_options'])) { + unset($a_ntpd['custom_options']); } if (is_uploaded_file($_FILES['leapfile']['tmp_name'])) { $a_ntpd['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name'])); } + write_config("Updated NTP Server Settings"); ntpd_configure_start(); + header(url_safe('Location: /services_ntpd.php')); exit; } @@ -119,7 +131,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $service_hook = 'ntpd'; legacy_html_escape_form_data($pconfig); + include("head.inc"); + ?> @@ -137,6 +151,13 @@ include("head.inc"); $("#showleapsecbox").parent().hide(); $("#showleapsec").show(); }); + $("#show_advanced_ntpd").click(function(event){ + $("#showadvbox").hide(); + $("#showadv").show(); + }); + if ($("#custom_options").val() != "") { + $("#show_advanced_ntpd").click(); + } /** * Aliases @@ -381,6 +402,19 @@ include("head.inc"); + + + +
> + " /> - +
+
> +
+
+ +
+ +