Bug 617328 - Providing native systemd file for upcoming F14 Feature Systemd
Summary: Providing native systemd file for upcoming F14 Feature Systemd
Alias: None
Product: Fedora
Classification: Fedora
Component: ntp
Version: 14
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2010-07-22 19:10 UTC by Jóhann B. Guðmundsson
Modified: 2010-09-08 04:38 UTC (History)
5 users (show)

Fixed In Version: ntp-4.2.6p2-4.fc14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-08-23 13:32:31 UTC

Attachments (Terms of Use)
Native systemd file for ntpd (137 bytes, application/octet-stream)
2010-07-22 19:10 UTC, Jóhann B. Guðmundsson
no flags Details

Description Jóhann B. Guðmundsson 2010-07-22 19:10:32 UTC
Created attachment 433784 [details]
Native systemd file for ntpd

Description of problem:

The attached file is a native systemd file for upcoming F14 Feature [1]

Please read [2] on how to installing systemd Service files.


If you have any question dont hesitate to ask them on this bug report.

Thank you.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:

Comment 1 Miroslav Lichvar 2010-07-23 12:03:43 UTC
Two questions:

Are the options in the service file supposed to be configurable by user? The current service starts ntpd with "-u ntp:ntp -g" options by default (set in /etc/sysconfig/ntpd).

How does this work with ntpdate service, will it be started after ntpdate has finished? Currently it doesn't work without NETWORKWAIT=yes, see bug #445229.

Comment 2 Bug Zapper 2010-07-30 12:45:27 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:

Comment 3 Lennart Poettering 2010-08-10 13:42:43 UTC
Miroslav, it is relatively easy to support /etc/sysconfig/ntpd. Simply add "EnvironmentFile=/etc/sysconfig/ntpd" to the .service file. This will merge the sysconfig variables from that file into the normal environment.

Then, you may use $OPTIONS in the command line in the .service file to refer to this variable.

That said I don't think that -u or -p or -g is anything the user should be able to configure, and hence I'd actually suggest removing the sysconfig file altogether.

It would be easy to wirte a service for ntpdate too. You could then simply add an "After=network.target" which will make sure it is run only after either NetworkManager or some other network script is configured.

BTW, the ntpd.service file could use one more addition: It should have WantedBy=rtc-set.target too, for better coapat with LSB init scripts requesting $time.

So, the resulting .service file could look something like this:

Description=Network Time Service

ExecStart=/usr/sbin/ntpd -n -u ntp:ntp -p /var/run/ntpd.pid -g $OPTIONS

WantedBy=multi-user.target rtc-set.target

Comment 4 Miroslav Lichvar 2010-08-10 14:00:35 UTC
Ok, thanks.

ntpdate and ntpd must not run at the same time, so I need to add an After to the ntpd service file?

Will be then ntpd started even when there is no network configured? (this is useful to load the drift file and to have refclocks working)

Comment 5 Miroslav Lichvar 2010-08-11 12:43:25 UTC
Also, the current ntpdate script does more than just run ntpdate, it also sets hwclock if configured to do so and looks for NTP servers in various file, this requires a bit of shell scripting.

Can this be done in native systemd script or does it need to be wrapped in another shell script?

Pointer to a similar script would be helpful.

Comment 6 Lennart Poettering 2010-08-11 13:46:18 UTC
If it doesn't make sense to run both ntpdate and ntpd at the same boot then a "Conflicts=ntpdate.service" in ntp.service sounds appropriate. If it does make sense to run them both, but not at the same instant, then an After= or Before= would make sense.

By hooking ntp into "multi-user.target" it is started on boot, regardless whether there is network. If you want to make sure that ntp is normally started after the network is around if it enabled you probably should add an "After=network.target" here though.

Regarding shell scripts: it is fine to run a shell script instead of an actual binary from the service files. In fact, we already do this for rc.sysinit itself which is started from sysinit.service.

Comment 7 Lennart Poettering 2010-08-11 13:50:16 UTC
BTW, it is not sufficient to just drop the .service files into /lib/systemd/system. It is also necessary to enable it when upgrading from an old sysv-only rpm. How to implement that in the spec file with minimal work is documented in daemon(7):


Comment 8 Miroslav Lichvar 2010-08-20 10:10:53 UTC
I'm trying to boot with this ntpdate.service:

Description=Set time via NTP
After=syslog.target network.target

ExecStart=/etc/init.d/ntpdate start


But it fails as it's started before NetworkManager has configured a network interface. I was hoping with a native unit file we could finally fix bug #445229, and now it seems it doesn't work even with the NETWORKWAIT=yes workaround.

Any hints?

Comment 9 Miroslav Lichvar 2010-08-23 13:32:31 UTC
The systemd support is now in ntp-4.2.6p2-2.fc14.

The ntpdate script will retry few times in increasing intervals before giving up. Please let me know if there is a better solution for this.

Comment 10 Fedora Update System 2010-08-23 13:35:50 UTC
ntp-4.2.6p2-2.fc14 has been submitted as an update for Fedora 14.

Comment 11 Fedora Update System 2010-08-26 10:35:51 UTC
ntp-4.2.6p2-3.fc14 has been submitted as an update for Fedora 14.

Comment 12 Fedora Update System 2010-08-27 17:32:18 UTC
ntp-4.2.6p2-4.fc14 has been submitted as an update for Fedora 14.

Comment 13 Lennart Poettering 2010-09-06 09:20:25 UTC
(In reply to comment #8)

> But it fails as it's started before NetworkManager has configured a network
> interface. I was hoping with a native unit file we could finally fix bug
> #445229, and now it seems it doesn't work even with the NETWORKWAIT=yes
> workaround.
> Any hints?

Hmm, if it has After=network.target is added there, and NETWORKWAIT=yes is set too, then it should actually be synchronized properly and ntpdate should be run only after thenetwork is up. Not sure why that is wrong. Could you open a new bug abaout that and attach the "systemctl dump" output of yours?

Comment 14 Miroslav Lichvar 2010-09-06 10:39:32 UTC
I think the problem is that the NetworkManager systemd service doesn't support the NETWORKWAIT option.

Maybe a new oneshot service could be added to the NM package that would run the nm-online command and which could be specified in other services' After?

Comment 15 Fedora Update System 2010-09-08 04:38:27 UTC
ntp-4.2.6p2-4.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.