[Main]
Type = classic
Version = %%VERSION%%
Description = "ntpclient daemon"
User = ( root )

[Start]
Execute=
(
    if
    {
        pipeline
        {
            s6-setuidgid ntp
            backtick -n NTPSERVERIP
            {
                pipeline { s6-dnsip4 -t 16000 ${Args} }
                s6-head -n 1
            }
            importas -u NTPSERVERIP NTPSERVERIP
            s6-sntpclock -v2 $NTPSERVERIP
        }
        s6-clockadd -f
    }
    s6-setuidgid nobody
    s6-sleep 14400
)

[Environment]
Args=!0.pool.ntp.org
