Artix Linux Forum

Artix Linux => System => Topic started by: replabrobin on 07 June 2024, 13:18:00

Title: [SOLVED BUG]: ntpd startup fails after update today
Post by: replabrobin on 07 June 2024, 13:18:00
I updated everything on an x86_64 machine today. After restart I find one daemon fails to start properly.

I use runit and ntp-runit looks like
Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check!
[ "$(ip route | awk '/^default/{print ($3!="")+($5!="")}')" = "2" ] || exit 1
exec ntpd -g -u ntp:ntp -n >/dev/null 2>&1

It seems like I have new behaviour from the network check.  If I have both eth0 and wlan0 connected then the route awk combo gives two lines of output and the check fails. I suspect that previously a timing difference allowed the guard to succeed ie perhaps eth0 was faster. To accommodate multiple default routes I changed my run command to
Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check!
[ "$(ip route | awk '/^default/{if(($3!="")+($5!="")==2){print "2";exit 0;}}')" = "2" ] || exit 1
exec ntpd -g -u ntp:ntp -n >/dev/null 2>&1

the guard exits after the first default that is good.
Title: Re: ntpd startup fails after update today
Post by: replabrobin on 09 June 2024, 11:02:34
I changed the network check again to be slightly simpler so /etc/runit/sv/ntpd/run now looks like

Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check
ip route | awk '/^default/{if($3!=""&&$5!=""){v=1;exit 0}}END{exit v!=1}' || exit 1
exec ntpd -g -u ntp:ntp -n >/dev/null 2>&1