summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2012-08-21 16:22:31 -0400
committerjim-p <jimp@pfsense.org>2012-08-21 16:23:33 -0400
commit5c8843d5fb080c196c0d9dfcfeb526afa3cba23d (patch)
tree8edd85eebfcb94574f0151eb6df45ffb5997df75 /usr/local
parent73815007a4bfa41d0e7225d59c450ec853024e29 (diff)
downloadpfsense-5c8843d5fb080c196c0d9dfcfeb526afa3cba23d.zip
pfsense-5c8843d5fb080c196c0d9dfcfeb526afa3cba23d.tar.gz
Teach ntpd how to get its time from a local GPS on serial.
Diffstat (limited to 'usr/local')
-rw-r--r--usr/local/www/services_ntpd.php35
-rw-r--r--usr/local/www/status_ntpd.php34
2 files changed, 66 insertions, 3 deletions
diff --git a/usr/local/www/services_ntpd.php b/usr/local/www/services_ntpd.php
index 0cbaf2a..1aa53fb 100644
--- a/usr/local/www/services_ntpd.php
+++ b/usr/local/www/services_ntpd.php
@@ -59,6 +59,11 @@ if ($_POST) {
elseif (isset($config['ntpd']['interface']))
unset($config['ntpd']['interface']);
+ if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
+ $config['ntpd']['gpsport'] = $_POST['gpsport'];
+ else
+ unset($config['ntpd']['gpsport']);
+
write_config("Updated NTP Server Settings");
$retval = 0;
@@ -110,12 +115,36 @@ include("head.inc");
echo ">{$ifacename}</option>\n";
} ?>
</select>
- <br/>Interfaces without an IP address will not be shown.
<br/>
- <br/>Selecting no interfaces will listen on all interfaces with a wildcard.
- <br/>Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.
+ <br/><?php echo gettext("Interfaces without an IP address will not be shown."); ?>
+ <br/>
+ <br/><?php echo gettext("Selecting no interfaces will listen on all interfaces with a wildcard."); ?>
+ <br/><?php echo gettext("Selecting all interfaces will explicitly listen on only the interfaces/IPs specified."); ?>
+ </td>
+</tr>
+<?php /* Probing would be nice, but much more complex. Would need to listen to each port for 1s+ and watch for strings. */ ?>
+<?php $serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE); ?>
+<?php if (!empty($serialports)): ?>
+<tr>
+ <td width="22%" valign="top" class="vncellreq">Serial GPS</td>
+ <td width="78%" class="vtable">
+ <select name="gpsport">
+ <option value="">none</option>
+ <?php foreach ($serialports as $port):
+ $shortport = substr($port,5);
+ $selected = ($shortport == $config['ntpd']['gpsport']) ? " selected" : "";?>
+ <option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
+ <?php endforeach; ?>
+ </select>
+ <br/>
+ <br/><?php echo gettext("The GPS must provide NEMA format output!"); ?>
+ <br/>
+ <br/><?php echo gettext("All serial ports are listed, be sure to pick only the port with the GPS attached."); ?>
+ <br/>
+ <br/><?php echo gettext("It is best to configure at least 2 servers under"); ?> <a href="system.php"><?php echo gettext("System > General"); ?></a> <?php echo gettext("to avoid loss of sync if the GPS data is not valid over time. Otherwise ntpd may only use values from the unsynchronized local clock when proving time to clients."); ?>
</td>
</tr>
+<?php endif; ?>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
diff --git a/usr/local/www/status_ntpd.php b/usr/local/www/status_ntpd.php
index 9aa6039..2b9ac72 100644
--- a/usr/local/www/status_ntpd.php
+++ b/usr/local/www/status_ntpd.php
@@ -43,6 +43,7 @@
require_once("guiconfig.inc");
exec("/usr/local/bin/ntpq -pn | /usr/bin/tail +3", $ntpq_output);
+
$ntpq_servers = array();
foreach ($ntpq_output as $line) {
$server = array();
@@ -91,6 +92,20 @@ foreach ($ntpq_output as $line) {
$ntpq_servers[] = $server;
}
+exec("/usr/local/bin/ntpq -c clockvar", $ntpq_clockvar_output);
+foreach ($ntpq_clockvar_output as $line) {
+ if (substr($line, 0, 9) == "timecode=") {
+ $tmp = explode('"', $line);
+ $tmp = $tmp[1];
+ if (substr($tmp, 0, 6) == '$GPRMC') {
+ $gps_vars = explode(",", $tmp);
+ $gps_ok = ($gps_vars[2] == "A");
+ $gps_lat = $gps_vars[3] / 100.0 . $gps_vars[4];
+ $gps_lon = $gps_vars[5] / 100.0 . $gps_vars[6];
+ }
+ }
+}
+
$pgtitle = array(gettext("Status"),gettext("NTP"));
$shortcut_section = "ntp";
include("head.inc");
@@ -163,6 +178,25 @@ include("head.inc");
<?php $i++; endforeach; endif; ?>
</tbody>
</table>
+<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)): ?>
+ <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <thead>
+ <tr>
+ <th class="listhdrr"><?=gettext("Clock Latitude"); ?></th>
+ <th class="listhdrr"><?=gettext("Clock Longitude"); ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="listlr" align="center"><?php echo $gps_lat; ?></td>
+ <td class="listlr" align="center"><?php echo $gps_lon; ?></td>
+ </tr>
+ <tr>
+ <td class="listlr" colspan="2" align="center"><a href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">Google Maps Link</a></td>
+ </tr>
+ </tbody>
+ </table>
+<?php endif; ?>
</div></td></tr>
</table>
<?php include("fend.inc"); ?>
OpenPOWER on IntegriCloud