diff --git a/src/etc/inc/plugins.inc.d/ntpd.inc b/src/etc/inc/plugins.inc.d/ntpd.inc index d2a03374d9..f696b613b6 100644 --- a/src/etc/inc/plugins.inc.d/ntpd.inc +++ b/src/etc/inc/plugins.inc.d/ntpd.inc @@ -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';