Thursday, September 12, 2013

Systemd and NTP on Gentoo

Gentoo currently doesn't have systemd support for the NTP package. So I built some to tide me over until it's officially available.

It's not perfect, but at least it's functional!

Here's the main long-running service:
[Unit]
Description=NTP Daemon
After=network-online.target ntp-oneshot.service

[Service]
ExecStart=/usr/sbin/ntpd -n -x -g -u ntp:ntp -c /etc/ntp.conf
Type=simple

[Install]
WantedBy=multi-user.target
In case your system doesn't have a hardware clock, here's a one-shot service that will override the systemclock to match the value of the network time.
 [Unit]
Description=NTP Daemon
After=network-online.target

[Service]
ExecStart=/usr/sbin/ntpd -q -g -x -u ntp:ntp -c /etc/ntp.conf
Type=oneshot

[Install]
WantedBy=multi-user.target

Don't forget to tell systemd-timedated about your ntp service
#echo "ntpd.service" > /usr/lib/systemd/ntp-units.d/60-ntpd.list
#systemctl enable ntpd.service && systemctl start ntpd.service

No comments:

Post a Comment