Do the files from Arch Linux look ok? <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/openntpd> And what do we do about start_pre() from <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup> ExecStartPre?
I tried the unit from arch for openntpd. It works, with one exception. If I enable openntpd to be executed on boot, it fails with this error: Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm Jun 02 22:58:19 work ntpd[3717]: ntp engine ready Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime adjusted frequency by -500.000000ppm Jun 02 22:58:19 work ntpd[3618]: could not parse "pool.ntp.org": System error Jun 02 22:58:34 work systemd[1]: Started OpenNTP Daemon. Jun 02 23:03:19 work ntpd[3717]: 0 out of 1 peers valid Jun 02 23:03:19 work ntpd[3717]: bad peer from pool pool.ntp.org (not resolved) I guess that the network is not in a complete ready state - but I don't know how to debug this. What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
(In reply to Michael Hampicke from comment #1) > I tried the unit from arch for openntpd. It works, with one exception. If I > enable openntpd to be executed on boot, it fails with this error: > > Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm > Jun 02 22:58:19 work ntpd[3717]: ntp engine ready > Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm > Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime adjusted frequency by > -500.000000ppm > Jun 02 22:58:19 work ntpd[3618]: could not parse "pool.ntp.org": System error > Jun 02 22:58:34 work systemd[1]: Started OpenNTP Daemon. > Jun 02 23:03:19 work ntpd[3717]: 0 out of 1 peers valid > Jun 02 23:03:19 work ntpd[3717]: bad peer from pool pool.ntp.org (not > resolved) > > I guess that the network is not in a complete ready state - but I don't know > how to debug this. Seems like After=network.target is not enough, we need something like "have.connection". > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file? We could use EnvironmentFile for that.
I would guess that the network issue depends a lot on what network manager you are using and your specific network config. Is there any way to get openntpd to retry a few times? That would be better than trying to detect when usable network connection is ready.
(In reply to Christoph Junghans from comment #0) > Do the files from Arch Linux look ok? > <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/ > openntpd> I don't know. For example, why is it using Type=forking instead of just passing '-d'? > And what do we do about start_pre() from > <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/ > files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup> > > ExecStartPre? Drop it. Init scripts are not supposed to perform system modifications when starting a service. (In reply to Christoph Junghans from comment #2) > > I guess that the network is not in a complete ready state - but I don't know > > how to debug this. > Seems like After=network.target is not enough, we need something like > "have.connection". After=network-online.target But not all network providers support that. And daemon which requires network to be fully functional at startup seems broken to me. > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file? > We could use EnvironmentFile for that. Drop it.
(In reply to Michał Górny from comment #4) > (In reply to Christoph Junghans from comment #0) > > Do the files from Arch Linux look ok? > > <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/ > > openntpd> > > I don't know. For example, why is it using Type=forking instead of just > passing '-d'? ntpd is strange, -d means "Do not daemonize" > > And what do we do about start_pre() from > > <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/ > > files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup> > > > > ExecStartPre? > > Drop it. Init scripts are not supposed to perform system modifications when > starting a service. ntpd runs in a chroot and if you ever change your timezone ${NTPD_HOME}/etc/localtime needs update, too. > (In reply to Christoph Junghans from comment #2) > > > I guess that the network is not in a complete ready state - but I don't know > > > how to debug this. > > Seems like After=network.target is not enough, we need something like > > "have.connection". > > After=network-online.target > > But not all network providers support that. And daemon which requires > network to be fully functional at startup seems broken to me. I have never seen that error before, seems to be a problem with name resolution. > > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file? > > We could use EnvironmentFile for that. > Drop it. The "-s" options (set time on start-up) comes in handy for some users, but I don't want to make it the default.
(In reply to Christoph Junghans from comment #5) > (In reply to Michał Górny from comment #4) > > (In reply to Christoph Junghans from comment #0) > > > Do the files from Arch Linux look ok? > > > <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/ > > > openntpd> > > > > I don't know. For example, why is it using Type=forking instead of just > > passing '-d'? > ntpd is strange, -d means "Do not daemonize" Which is intended. There's no point in programs randomly forking and systemd having to track those forks. > > > And what do we do about start_pre() from > > > <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/ > > > files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup> > > > > > > ExecStartPre? > > > > Drop it. Init scripts are not supposed to perform system modifications when > > starting a service. > ntpd runs in a chroot and if you ever change your timezone > ${NTPD_HOME}/etc/localtime needs update, too. Then either: 1. you have to care about that yourself, 2. ntpd has to care about it. Adding some random kind of middleware which performs some of program's tasks is not good for anyone. > > (In reply to Christoph Junghans from comment #2) > > > > I guess that the network is not in a complete ready state - but I don't know > > > > how to debug this. > > > Seems like After=network.target is not enough, we need something like > > > "have.connection". > > > > After=network-online.target > > > > But not all network providers support that. And daemon which requires > > network to be fully functional at startup seems broken to me. > I have never seen that error before, seems to be a problem with name > resolution. Well, I don't know the program but it looks like it assumes that only hosts that are resolvable during startup are valid. That's a pretty poor assumption that needs to be fixed upstream. > > > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file? > > > We could use EnvironmentFile for that. > > Drop it. > The "-s" options (set time on start-up) comes in handy for some users, but I > don't want to make it the default. Then provide a configuration file for it. Upstream, so people wouldn't need to check where a particular distro keeps it.
(In reply to Michał Górny from comment #6) > Which is intended. There's no point in programs randomly forking and systemd > having to track those forks. To me, it seems like it might be better in some situations to use forking mode. For example, if the parent waits for the child to initialize itself before exiting, this can tell systemd that the service is "ready" without having to implement sd_notify(3). I'm not sure if that's the case with openntpd, but it is worth checking.
Hello there, thx for t he hint with net manager. Ater I enabled NetworkManager.service the problem was gone. Before that, I only had dhcpcd.service enabled.
(In reply to Michael Hampicke from comment #8) > Hello there, > > thx for t he hint with net manager. Ater I enabled NetworkManager.service > the problem was gone. Before that, I only had dhcpcd.service enabled. That is because NetworkManager is able to detect network being online or not. The problem is that I don't know how to handle the other issues :/ (the needing of ExecPre, the config issue...)
The start_pre() is something that the ebuild should ensure, not init.d. It's a mess.
(In reply to Michał Górny from comment #10) > The start_pre() is something that the ebuild should ensure, not init.d. It's > a mess. Well, that isn't that easy as the timezone might change. I don't want to re-emerge openntpd whenever I travel to the other side of the US. If have to check, but ln -s /etc/localtime "${NTPD_HOME}/etc/localtime" might do the job.
How about? $ cat ntpd.service [Unit] Description=OpenNTP Daemon After=network.target [Service] Type=simple ExecStart=/usr/bin/ntpd -s -d [Install] WantedBy=multi-user.target Combined with the symlink that should be a good start.
+*openntpd-20080406-r3 (25 Aug 2013) + + 25 Aug 2013; Christoph Junghans <ottxor@gentoo.org> + +files/openntpd.conf.d-20080406-r3, +files/openntpd.init.d-20080406-r3, + +files/openntpd.service-20080406-r3, +openntpd-20080406-r3.ebuild, + -files/openntpd.init.d-20080406-r1, -files/openntpd.init.d-20080406-r2, + -openntpd-20080406-r2.ebuild: + added systemd unit files (bug #471610) +