From 20b90e0ae919718fbe88e6f5cd974a1c59f1d08a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 2 Oct 2006 21:12:58 +0000 Subject: Switch to OpenNTPD. --- etc/inc/system.inc | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'etc/inc/system.inc') diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 3810d75..dff60da 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -882,40 +882,37 @@ function system_timezone_configure() { function system_ntp_configure() { global $config, $g; - if(isset($config['system']['developerspew'])) { - $mt = microtime(); - echo "system_ntp_configure() being called $mt\n"; - } $syscfg = $config['system']; - if ($g['booting']) - echo "Starting NTP client..."; - else { - killbypid("{$g['varrun_path']}/runmsntp.pid"); - killbypid("{$g['varrun_path']}/msntp.pid"); + /* open configuration for wrting or bail */ + $fd = fopen("{$g['varetc_path']}/ntpd.conf","w"); + if(!$fd) { + log_error("Could not open {$g['varetc_path']}/ntpd.conf"); + return; } - /* start ntp client if needed - needs to be forced into background */ - $updateinterval = $syscfg['time-update-interval']; + fwrite($fd, "# \n"); + fwrite($fd, "# pfSense OpenNTPD configuration file \n"); + fwrite($fd, "# \n\n"); - if ($updateinterval > 0) { - if ($updateinterval < 6) - $updateinterval = 6; + /* foreach through servers and write out to ntpd.conf */ + $timeservers = ""; + foreach (explode(' ', $syscfg['timeservers']) as $ts) + fwrite($fd, "servers {$ts}\n"); - $timeservers = ""; - foreach (explode(' ', $syscfg['timeservers']) as $ts) - $timeservers .= " " . gethostbyname($ts); + fwrite($fd, "\n"); - mwexec_bg("/usr/local/bin/runmsntp.sh " . - escapeshellarg("{$g['varrun_path']}/runmsntp.pid") . " " . - escapeshellarg("{$g['varrun_path']}/msntp.pid") . " " . - escapeshellarg($updateinterval) . " " . - escapeshellarg($timeservers)); - } + /* slurp! */ + fclose($fd); + + /* if openntpd is running, kill it */ + if(is_process_running("ntpd")) + exec("/usr/bin/killall ntpd"); + + /* start opentpd, set time now and use /var/etc/ntpd.conf */ + exec("/usr/local/sbin/ntpd -s -f {$g['varetc_path']}/ntpd.conf"); - if ($g['booting']) - echo "done.\n"; } function system_halt() { -- cgit v1.1