[ntp/f18] add sntp service
Miroslav Lichvar
mlichvar at fedoraproject.org
Fri Nov 23 16:45:13 UTC 2012
commit 93d001421504cc7e59908f58175193ca97d5b36e
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date: Fri Nov 23 17:17:49 2012 +0100
add sntp service
ntp.spec | 38 ++++++++++++++++++++++++++++++++++++++
ntpd.service | 2 +-
sntp.service | 14 ++++++++++++++
sntp.sysconfig | 2 ++
4 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/ntp.spec b/ntp.spec
index e727c69..d9e3b18 100644
--- a/ntp.spec
+++ b/ntp.spec
@@ -44,6 +44,8 @@ Source10: ntp.dhclient
Source12: ntpd.service
Source13: ntpdate.service
Source14: ntp-wait.service
+Source15: sntp.service
+Source16: sntp.sysconfig
# ntpbz #802
Patch1: ntp-4.2.6p1-sleep.patch
@@ -115,6 +117,7 @@ Group: Applications/System
Requires: %{name} = %{version}-%{release}
Requires(post): systemd-units
Requires(preun): systemd-units
+Requires(postun): systemd-units
# perl introduced in 4.2.4p4-7
Obsoletes: %{name} < 4.2.4p4-7
%description perl
@@ -126,6 +129,7 @@ Group: Applications/System
Requires(pre): shadow-utils
Requires(post): systemd-units
Requires(preun): systemd-units
+Requires(postun): systemd-units
%description -n ntpdate
ntpdate is a program for retrieving the date and time from
@@ -134,6 +138,9 @@ NTP servers.
%package -n sntp
Summary: Standard Simple Network Time Protocol program
Group: Applications/System
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
%description -n sntp
sntp can be used as a SNTP client to query a NTP or SNTP server and either
@@ -268,11 +275,15 @@ install -p -m644 %{SOURCE9} .%{_sysconfdir}/sysconfig/ntpdate
sed -e 's|VENDORZONE\.|%{vendorzone}|' \
< %{SOURCE6} > .%{_sysconfdir}/ntp/step-tickers
touch -r %{SOURCE6} .%{_sysconfdir}/ntp/step-tickers
+sed -e 's|VENDORZONE\.|%{vendorzone}|' \
+ < %{SOURCE16} > .%{_sysconfdir}/sysconfig/sntp
+touch -r %{SOURCE16} .%{_sysconfdir}/sysconfig/sntp
install -p -m600 %{SOURCE8} .%{_sysconfdir}/ntp/crypto/pw
install -p -m755 %{SOURCE10} .%{_sysconfdir}/dhcp/dhclient.d/ntp.sh
install -p -m644 %{SOURCE12} ./lib/systemd/system/ntpd.service
install -p -m644 %{SOURCE13} ./lib/systemd/system/ntpdate.service
install -p -m644 %{SOURCE14} ./lib/systemd/system/ntp-wait.service
+install -p -m644 %{SOURCE15} ./lib/systemd/system/sntp.service
mkdir ./lib/systemd/ntp-units.d
echo 'ntpd.service' > ./lib/systemd/ntp-units.d/60-ntpd.list
@@ -297,6 +308,13 @@ popd
/bin/systemctl daemon-reload &> /dev/null || :
%endif
+%post -n sntp
+%if 0%{?systemd_post:1}
+%systemd_post sntp.service
+%else
+/bin/systemctl daemon-reload &> /dev/null || :
+%endif
+
%post perl
%if 0%{?systemd_post:1}
%systemd_post ntp-wait.service
@@ -326,6 +344,17 @@ fi
:
%endif
+%preun -n sntp
+%if 0%{?systemd_preun:1}
+%systemd_preun sntp.service
+%else
+if [ "$1" -eq 0 ]; then
+ /bin/systemctl --no-reload disable sntp.service &> /dev/null
+ /bin/systemctl stop sntp.service &> /dev/null
+fi
+:
+%endif
+
%preun perl
%if 0%{?systemd_preun:1}
%systemd_preun ntp-wait.service
@@ -355,6 +384,13 @@ fi
/bin/systemctl daemon-reload &> /dev/null || :
%endif
+%postun -n sntp
+%if 0%{?systemd_postun:1}
+%systemd_postun
+%else
+/bin/systemctl daemon-reload &> /dev/null || :
+%endif
+
%postun perl
%if 0%{?systemd_postun:1}
%systemd_postun
@@ -414,9 +450,11 @@ fi
%files -n sntp
%doc sntp/COPYRIGHT
+%config(noreplace) %{_sysconfdir}/sysconfig/sntp
%{_sbindir}/sntp
%{_mandir}/man8/sntp.8*
%ghost %{_localstatedir}/lib/sntp-kod
+/lib/systemd/system/sntp.service
%files doc
%{ntpdocdir}/html
diff --git a/ntpd.service b/ntpd.service
index dc2e598..74069b1 100644
--- a/ntpd.service
+++ b/ntpd.service
@@ -1,6 +1,6 @@
[Unit]
Description=Network Time Service
-After=syslog.target ntpdate.service
+After=syslog.target ntpdate.service sntp.service
Wants=ntp-wait.service
[Service]
diff --git a/sntp.service b/sntp.service
new file mode 100644
index 0000000..70ff227
--- /dev/null
+++ b/sntp.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Set time via SNTP
+After=syslog.target network.target NetworkManager-wait-online.service nss-lookup.target
+Before=time-sync.target
+Wants=time-sync.target
+
+[Service]
+Type=oneshot
+EnvironmentFile=/etc/sysconfig/sntp
+ExecStart=/usr/sbin/sntp $OPTIONS
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sntp.sysconfig b/sntp.sysconfig
new file mode 100644
index 0000000..1bf1c01
--- /dev/null
+++ b/sntp.sysconfig
@@ -0,0 +1,2 @@
+# Options for sntp
+OPTIONS="-s 0.VENDORZONE.pool.ntp.org"
More information about the scm-commits
mailing list