Merge pull request #1360 from bergware/master

NTP: fix listening interfaces
This commit is contained in:
tom mortensen
2023-06-19 09:06:39 -07:00
committed by GitHub
3 changed files with 8 additions and 11 deletions

View File

@@ -17,16 +17,15 @@ $varroot = '/var/local/emhttp';
require_once "$docroot/webGui/include/publish.php";
while (true) {
unset($memory,$sys,$rpms,$lsof);
unset($memory,$sys,$zfs,$rpms,$lsof);
exec("grep -Po '^Mem(Total|Available):\s+\K\d+' /proc/meminfo",$memory);
exec("df /boot /var/log /var/lib/docker|grep -Po '\d+%'",$sys);
exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$rpms);
exec("awk '/^c_max|^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null",$zfs);
[$total,$free] = $memory;
$used = $total-$free;
$zfs = (exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0)/1024;
$info = max(round(100*(1-$free/$total)),0)."%\0".round(100*$zfs/$used)."%\0".implode("\0",$sys);
$info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]??0)/($zfs[0]??1))."%\0".implode("\0",$sys);
$rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : '';
$names = array_keys((array)parse_ini_file("$varroot/shares.ini"));
exec("LANG='en_US.UTF8' lsof -Owl /mnt/disk[0-9]* 2>/dev/null|awk '/^shfs/ && \$0!~/\.AppleD(B|ouble)/ && \$5==\"REG\"'|awk -F/ '{print \$4}'",$lsof);
$counts = array_count_values($lsof); $count = [];

View File

@@ -157,7 +157,7 @@ check() {
fi
done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}')
# add loopback interface
if [[ "smb nfs ntp" =~ $CALLER ]]; then
if [[ "smb nfs" =~ $CALLER ]]; then
[[ $ipv4 == yes ]] && bind+=(127.0.0.1)
[[ $ipv6 == yes ]] && bind+=(::1)
fi

View File

@@ -21,12 +21,10 @@ build_ntp() {
# ignore unused protocol
[[ $ipv4 == no ]] && echo "interface ignore ipv4" >>$CONF
[[ $ipv6 == no ]] && echo "interface ignore ipv6" >>$CONF
# for now do not bind interfaces
# it is not clear why NTP is started several times and fails to bind on occasion
# add listen interfaces
#for net in $bind; do
# echo "interface listen $net" >>$CONF
#done
for net in $bind; do
echo "interface listen $net" >>$CONF
done
fi
# add configured NTP servers
[[ -n $NTP_SERVER1 ]] && echo "server $NTP_SERVER1 iburst" >>$CONF
@@ -94,7 +92,7 @@ ntpd_reload() {
ntpd_update() {
[[ $(pgrep -cf $NTPD) -eq 0 ]] && exit 1 # not running
if check && [[ -z "$(this 'interface listen')" || "$(this 'interface listen')" == "$bind" ]]; then
if check && [[ "$(this 'interface listen')" == "$bind" ]]; then
# no action required
exit 1
else