packages: ntp/ntp-client.init, ntp/ntp-client.sysconfig, ntp/ntp.spec - run...

glen glen at pld-linux.org
Fri Jan 22 20:22:29 CET 2010


Author: glen                         Date: Fri Jan 22 19:22:29 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- run ntpdate under ntp uid, ntpdate service also can sync hwclock after service start

---- Files affected:
packages/ntp:
   ntp-client.init (1.7 -> 1.8) , ntp-client.sysconfig (1.6 -> 1.7) , ntp.spec (1.117 -> 1.118) 

---- Diffs:

================================================================
Index: packages/ntp/ntp-client.init
diff -u packages/ntp/ntp-client.init:1.7 packages/ntp/ntp-client.init:1.8
--- packages/ntp/ntp-client.init:1.7	Fri Jan 22 20:01:14 2010
+++ packages/ntp/ntp-client.init	Fri Jan 22 20:22:24 2010
@@ -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 @@
 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: packages/ntp/ntp-client.sysconfig
diff -u packages/ntp/ntp-client.sysconfig:1.6 packages/ntp/ntp-client.sysconfig:1.7
--- packages/ntp/ntp-client.sysconfig:1.6	Wed Apr  6 14:06:20 2005
+++ packages/ntp/ntp-client.sysconfig	Fri Jan 22 20:22:24 2010
@@ -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: packages/ntp/ntp.spec
diff -u packages/ntp/ntp.spec:1.117 packages/ntp/ntp.spec:1.118
--- packages/ntp/ntp.spec:1.117	Fri Jan 22 20:04:26 2010
+++ packages/ntp/ntp.spec	Fri Jan 22 20:22:24 2010
@@ -1,14 +1,14 @@
 # $Revision$, $Date$
 # 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
@@ -135,12 +135,15 @@
 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
@@ -267,9 +270,13 @@
 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"
@@ -280,6 +287,12 @@
 	/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
@@ -334,6 +347,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.118  2010/01/22 19:22:24  glen
+- run ntpdate under ntp uid, ntpdate service also can sync hwclock after service start
+
 Revision 1.117  2010/01/22 19:04:26  glen
 - order cosmetics
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/ntp/ntp-client.init?r1=1.7&r2=1.8&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/ntp/ntp-client.sysconfig?r1=1.6&r2=1.7&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/ntp/ntp.spec?r1=1.117&r2=1.118&f=u



More information about the pld-cvs-commit mailing list