]> git.pld-linux.org Git - packages/ntp.git/commitdiff
- run ntpdate under ntp uid, ntpdate service also can sync hwclock after service...
authorElan Ruusamäe <glen@pld-linux.org>
Fri, 22 Jan 2010 19:22:24 +0000 (19:22 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    ntp-client.init -> 1.8
    ntp-client.sysconfig -> 1.7
    ntp.spec -> 1.118

ntp-client.init
ntp-client.sysconfig
ntp.spec

index f269de81c7bcb6c473659b9afc8ea27a5f685da7..99211d75f812be2681942d5307023667b2875142 100644 (file)
@@ -17,7 +17,7 @@
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-               msg_network_down ntp
+               msg_network_down "ntpdate"
                exit 1
        fi
 else
@@ -25,10 +25,16 @@ else
 fi
 
 start() {
-       show "Syncing time with ntpdate (backgrounding)"
-       daemon --fork /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS
+       show "Syncing time with ntpdate"
+       daemon /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS
        RETVAL=$?
-       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpdate
+       if [ $RETVAL -eq 0 ]; then
+               touch /var/lock/subsys/ntpdate
+               if is_yes "$SYNC_HWCLOCK"; then
+                       show "Syncing hardware clock to system time"
+                   /sbin/hwclock --systohc && ok || fail
+               fi
+       fi
 }
 
 stop() {
index 62f6b99f13bc041abe0459f9db60bbe481da5f88..0bc6ec6396b1c0a445636dc244928553637b8acd 100644 (file)
@@ -1,8 +1,12 @@
 # Sync time at startup
-NTPDATE_OPTIONS="-o 1 -u"
+NTPDATE_OPTIONS="-o 1 -u -U ntp"
+
 #NTPDATE_SERVERS="ntp.nasa.gov clock.isc.org"
 #NTPDATE_SERVERS="ntp.certum.pl vega.cbk.poznan.pl"
 NTPDATE_SERVERS="pool.ntp.org"
 
+# Set to 'yes' to sync hw clock after successful ntpdate
+SYNC_HWCLOCK="no"
+
 # also run ntpdate from cron
 NTPDATE_CRON="yes"
index 369e3f29c10295773458d79cee55b3dd44c13299..188ac5d3864734694f122fbb7d606b28afa5060c 100644 (file)
--- a/ntp.spec
+++ b/ntp.spec
@@ -1,13 +1,13 @@
 # TODO
-# - run as ntp/ntp (fc patches)
-# - default config is too restrictive (ntpq -p should work locally)
+# - see if ntpd can be droproot too as ntpdate is patched
+# - ntpd default config is too restrictive (ntpq -p should work locally)
 %include       /usr/lib/rpm/macros.perl
 Summary:       Network Time Protocol utilities
 Summary(pl.UTF-8):     Narzędzia do synchronizacji czasu (Network Time Protocol)
 Summary(pt_BR.UTF-8):  Network Time Protocol versão 4
 Name:          ntp
 Version:       4.2.4p8
-Release:       3.2
+Release:       3.3
 License:       distributable
 Group:         Daemons
 Source0:       http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/%{name}-%{version}.tar.gz
@@ -134,12 +134,15 @@ Summary:  Utility to set the date and time via NTP
 Summary(pl.UTF-8):     Klient do synchronizacji czasu po NTP (Network Time Protocol)
 Group:         Applications/Networking
 Requires(post,preun):  /sbin/chkconfig
-Provides:      ntpclient
-Obsoletes:     ntpclient
+Provides:      group(ntp)
+Provides:      user(ntp)
 Conflicts:     ntp < 4.2.0-3
 # for upgrades
 Provides:      ntp-client = %{version}-%{release}
 Obsoletes:     ntp-client < 4.2.4p8-4
+# virtual
+Provides:      ntpclient
+Obsoletes:     ntpclient
 
 %description -n ntpdate
 ntpdate is a program for retrieving the date and time from NTP
@@ -266,9 +269,13 @@ rm -rf $RPM_BUILD_ROOT
 if [ "$1" = "0" ]; then
        %service ntpd stop
        /sbin/chkconfig --del ntpd
-       rm -f /etc/ntp/drift
+       rm -f %{_sysconfdir}/drift
 fi
 
+%pre -n ntpdate
+%groupadd -g 246 ntp
+%useradd -u 246 -d %{_sysconfdir} -g ntp -c "NTP Daemon" ntp
+
 %post -n ntpdate
 /sbin/chkconfig --add ntpdate
 %service ntpdate restart "NTP Date"
@@ -279,6 +286,12 @@ if [ "$1" = "0" ]; then
        /sbin/chkconfig --del ntpdate
 fi
 
+%postun -n ntpdate
+if [ "$1" = "0" ]; then
+       %userremove ntp
+       %groupremove ntp
+fi
+
 %triggerpostun -n ntpd -- ntp < 4.2.4p8-3.1
 %triggerpostun -n ntpdate -- ntp-client < 4.2.4p8-3.2
 if [ -f /etc/sysconfig/ntp.rpmsave ]; then
This page took 0.107119 seconds and 4 git commands to generate.