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. 1.http://fedoraproject.org/wiki/Features/systemd 2.https://fedoraproject.org/wiki/User:Johannbg/QA/Systemd/Daemon#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: 1. 2. 3. Actual results: Expected results: Additional info:
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.
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: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
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: <snip> [Unit] Description=Network Time Service After=syslog.target [Service] EnvironmentFile=/etc/sysconfig/ntpd ExecStart=/usr/sbin/ntpd -n -u ntp:ntp -p /var/run/ntpd.pid -g $OPTIONS [Install] WantedBy=multi-user.target rtc-set.target </snip>
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)
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.
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.
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): http://0pointer.de/public/systemd-man/daemon.html#id2562029
I'm trying to boot with this ntpdate.service: [Unit] Description=Set time via NTP After=syslog.target network.target [Service] Type=finish ExecStart=/etc/init.d/ntpdate start ValidNoProcess=yes [Install] WantedBy=multi-user.target 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?
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.
ntp-4.2.6p2-2.fc14 has been submitted as an update for Fedora 14. http://admin.fedoraproject.org/updates/ntp-4.2.6p2-2.fc14
ntp-4.2.6p2-3.fc14 has been submitted as an update for Fedora 14. http://admin.fedoraproject.org/updates/ntp-4.2.6p2-3.fc14
ntp-4.2.6p2-4.fc14 has been submitted as an update for Fedora 14. https://admin.fedoraproject.org/updates/ntp-4.2.6p2-4.fc14
(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?
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?
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.