Services: Network Time: PPS - remove stale symlink when pps is disabled, closes https://github.com/opnsense/core/pull/9969

This commit is contained in:
Ad Schellevis 2026-03-15 11:06:21 +01:00
parent 3069c25680
commit 770480715b

View file

@ -152,17 +152,17 @@ function ntpd_configure_gps($serialport)
return true;
}
function ntpd_configure_pps($serialport)
function ntpd_configure_pps($port)
{
$pps_device = '/dev/pps0';
$serialport = "/dev/{$serialport}";
$serialport = "/dev/{$port}";
if (!file_exists($serialport)) {
@unlink($pps_device);
if (empty($port)) {
return false
} elseif (!file_exists($serialport)) {
return false;
}
// Create symlink that ntpd requires
@unlink($pps_device);
@symlink($serialport, $pps_device);
return true;
@ -213,11 +213,7 @@ function ntpd_configure_do($verbose = false)
$ntpcfg .= "\n";
/* Add PPS configuration */
if (
!empty($config['ntpd']['pps'])
&& file_exists('/dev/' . $config['ntpd']['pps']['port'])
&& ntpd_configure_pps($config['ntpd']['pps']['port'])
) {
if (!empty($config['ntpd']['pps']) && ntpd_configure_pps($config['ntpd']['pps']['port'])) {
$ntpcfg .= "\n";
$ntpcfg .= "# PPS Setup\n";
$ntpcfg .= 'server 127.127.22.0';