packages: chrony/chrony.conf (NEW), chrony/chrony.keys (NEW), chrony/chrony...

glen glen at pld-linux.org
Sun Feb 7 19:28:35 CET 2010


Author: glen                         Date: Sun Feb  7 18:28:35 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- new, based on fc package

---- Files affected:
packages/chrony:
   chrony.conf (NONE -> 1.1)  (NEW), chrony.keys (NONE -> 1.1)  (NEW), chrony.logrotate (NONE -> 1.1)  (NEW), chrony.spec (NONE -> 1.1)  (NEW), chronyd.init (NONE -> 1.1)  (NEW), chronyd.sysconfig (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/chrony/chrony.conf
diff -u /dev/null packages/chrony/chrony.conf:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chrony.conf	Sun Feb  7 19:28:29 2010
@@ -0,0 +1,25 @@
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+server 0.pool.ntp.org
+server 1.pool.ntp.org
+server 2.pool.ntp.org
+ 
+driftfile /var/lib/ntp/drift
+
+# Allow client access from local network.
+#allow 192.168/16
+
+# Serve time even if not synchronized to any NTP server.
+#local stratum 10
+
+keyfile /etc/ntp/keys
+
+# Specify the key used as password for chronyc.
+commandkey 1
+
+# Send a message to syslog when chronyd has to correct
+# an error larger than 0.5 seconds.
+logchange 0.5
+
+logdir /var/log/chrony
+#log measurements statistics tracking

================================================================
Index: packages/chrony/chrony.keys
diff -u /dev/null packages/chrony/chrony.keys:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chrony.keys	Sun Feb  7 19:28:29 2010
@@ -0,0 +1 @@
+#1 a_key

================================================================
Index: packages/chrony/chrony.logrotate
diff -u /dev/null packages/chrony/chrony.logrotate:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chrony.logrotate	Sun Feb  7 19:28:29 2010
@@ -0,0 +1,8 @@
+/var/log/chrony/*.log {
+    missingok
+    nocreate
+    sharedscripts
+    postrotate
+        /sbin/service chronyd cyclelogs > /dev/null
+    endscript
+}

================================================================
Index: packages/chrony/chrony.spec
diff -u /dev/null packages/chrony/chrony.spec:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chrony.spec	Sun Feb  7 19:28:29 2010
@@ -0,0 +1,133 @@
+# $Revision$, $Date$
+%define		subver	pre1
+%define		rel 	1
+Summary:	An NTP client/server
+Name:		chrony
+Version:	1.24
+Release:	0.%{subver}.%{rel}
+License:	GPL v2
+Group:		Daemons
+URL:		http://chrony.tuxfamily.org/
+Source0:	http://download.tuxfamily.org/chrony/%{name}-%{version}-%{subver}.tar.gz
+# Source0-md5:	e1f0d15bc0830f5f6bf80da2d72eb16a
+Source1:	%{name}.conf
+Source2:	%{name}.keys
+Source3:	%{name}d.sysconfig
+Source4:	%{name}d.init
+Source5:	%{name}.logrotate
+BuildRequires:	bison
+BuildRequires:	libcap-devel
+BuildRequires:	readline-devel
+BuildRequires:	rpmbuild(macros) >= 1.202
+BuildRequires:	texinfo
+Requires(postun):	/usr/sbin/groupdel
+Requires(postun):	/usr/sbin/userdel
+Requires(pre):	/bin/id
+Requires(pre):	/usr/bin/getgid
+Requires(pre):	/usr/sbin/groupadd
+Requires(pre):	/usr/sbin/useradd
+Provides:	group(ntp)
+Provides:	ntpdaemon
+Provides:	user(ntp)
+Obsoletes:	ntpdaemon
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define		_sysconfdir	/etc/ntp
+
+%description
+A client/server for the Network Time Protocol, this program keeps your
+computer's clock accurate. It was specially designed to support
+systems with dial-up Internet connections, and also supports computers
+in permanently connected environments.
+
+%prep
+%setup -q -n %{name}-%{version}-%{subver}
+
+%build
+# NOTE: It is not autoconf generated configre
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags} -pie -fpie -Wmissing-prototypes -Wall" \
+CPPFLAGS="%{rpmcppflags}" \
+./configure \
+	--prefix=%{_prefix} \
+	--sysconfdir=%{_sysconfdir} \
+	--docdir=%{_docdir} \
+	--with-readline \
+	--without-editline \
+
+%{__make} getdate all docs
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT/etc/{sysconfig,logrotate.d,rc.d/init.d} \
+	$RPM_BUILD_ROOT{%{_sysconfdir},/var/{lib/ntp,log/chrony}}
+
+%{__make} install install-docs \
+	DESTDIR=$RPM_BUILD_ROOT
+
+rm -rf $RPM_BUILD_ROOT%{_docdir}
+
+cp -a %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/chrony.conf
+cp -a %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/chrony.keys
+cp -a %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/chronyd
+cp -a %{SOURCE5} $RPM_BUILD_ROOT/etc/logrotate.d/chrony
+install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/chronyd
+
+touch $RPM_BUILD_ROOT%{_localstatedir}/lib/ntp/{drift,rtc}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+%groupadd -g 246 ntp
+%useradd -u 246 -d %{_localstatedir}/lib/ntp -g ntp -c "NTP Daemon" ntp
+
+%post
+/usr/sbin/fix-info-dir -c %{_infodir}
+/sbin/chkconfig --add chronyd
+%service chronyd restart
+
+%preun
+if [ "$1" = "0" ]; then
+	%service chronyd stop
+	/sbin/chkconfig --del chronyd
+	/usr/sbin/fix-info-dir -c %{_infodir}
+fi
+
+%postun
+if [ "$1" = "0" ]; then
+	%userremove ntp
+	%groupremove ntp
+fi
+
+%files
+%defattr(644,root,root,755)
+%doc NEWS README chrony.txt faq.txt examples/*
+%dir %{_sysconfdir}
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/chrony.conf
+%attr(640,root,ntp) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/chrony.keys
+%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/chronyd
+%config(noreplace) /etc/logrotate.d/chrony
+%attr(754,root,root) /etc/rc.d/init.d/chronyd
+%attr(755,root,root) %{_bindir}/chronyc
+%attr(755,root,root) %{_sbindir}/chronyd
+%{_mandir}/man1/chrony.1*
+%{_mandir}/man1/chronyc.1*
+%{_mandir}/man5/chrony.conf.5*
+%{_mandir}/man8/chronyd.8*
+%{_infodir}/chrony.info*
+
+%dir %attr(770,root,ntp) /var/lib/ntp
+%attr(640,ntp,ntp) %ghost /var/lib/ntp/drift
+%attr(640,ntp,ntp) %ghost /var/lib/ntp/rtc
+
+%dir %attr(770,ntp,ntp) /var/log/chrony
+
+%define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%changelog
+* %{date} PLD Team <feedback at pld-linux.org>
+All persons listed below can be reached at <cvs_login>@pld-linux.org
+
+$Log$
+Revision 1.1  2010/02/07 18:28:29  glen
+- new, based on fc package

================================================================
Index: packages/chrony/chronyd.init
diff -u /dev/null packages/chrony/chronyd.init:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chronyd.init	Sun Feb  7 19:28:29 2010
@@ -0,0 +1,151 @@
+#!/bin/sh
+#
+# chronyd	chronyd short service description
+#
+# chkconfig:   2345 58 74
+# description: Client/server for the Network Time Protocol, \
+#              this program keeps your computer's clock accurate.
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/chronyd ] && . /etc/sysconfig/chronyd
+
+# 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 "Chronyd NTPD"
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+config=/etc/ntp/chrony.conf
+keyfile=/etc/ntp/keys
+chronyc=/usr/bin/chronyc
+
+get_key() {
+    awk '/^[ \t]*'$1'\>/ { print $2; exit }' < $keyfile
+}
+
+get_commandkeyid() {
+    awk '/^[ \t]*commandkey\>/ { keyid=$2 } END { print keyid }' < $config
+}
+
+chrony_command() {
+    commandkeyid=$(get_commandkeyid)
+    [ -z "$commandkeyid" ] && return 1
+    commandkey=$(get_key $commandkeyid)
+    [ -z "$commandkey" ] && return 2
+
+    ! (
+        $chronyc <<EOF &
+password $commandkey
+$1
+EOF
+        chronycpid=$!
+
+        # chronyc will hang if the daemon doesn't respond, kill it after 3 s 
+        (sleep 3; kill $chronycpid) < /dev/null &> /dev/null &
+        killerpid=$!
+
+        wait $chronycpid &> /dev/null
+        kill $killerpid &> /dev/null || echo "chronyd not responding"
+    ) | grep -v '200 OK'
+}
+
+generate_commandkey() {
+    commandkeyid=$(get_commandkeyid)
+    [ -z "$commandkeyid" ] && return 1
+    commandkey=$(get_key $commandkeyid)
+    [ -z "$commandkey" ] || return 0
+
+    echo -n $"Generating chrony command key: "
+    commandkey=$(tr -c -d '[\041-\176]' < /dev/urandom | head -c 8)
+    [ -n "$commandkey" ] && echo "$commandkeyid $commandkey" >> $keyfile &&
+        success || failure
+    echo
+}
+
+start() {
+	# Check if the service is already running?
+	if [ -f /var/lock/subsys/chronyd ]; then
+		msg_already_running "Chronyd NTPD"
+		return
+	fi
+
+    generate_commandkey
+
+	msg_starting "Chronyd NTPD"
+	daemon /usr/sbin/chronyd $OPTIONS
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/chronyd
+}
+
+stop() {
+	if [ ! -f /var/lock/subsys/chronyd ]; then
+		msg_not_running "Chronyd NTPD"
+		return
+	fi
+
+	# Stop daemons.
+	msg_stopping "Chronyd NTPD"
+	killproc chronyd
+	rm -f /var/lock/subsys/chronyd
+}
+
+condrestart() {
+	if [ ! -f /var/lock/subsys/chronyd ]; then
+		msg_not_running "Chronyd NTPD"
+		RETVAL=$1
+		return
+	fi
+
+	stop
+	start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
+	;;
+  stop)
+  	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  force-reload)
+	condrestart 7
+	;;
+  online|offline|cyclelogs) 
+   	status chronyd >/dev/null 2>&1 || exit 7
+	chrony_command $1
+	;;
+  command)
+   	status chronyd >/dev/null 2>&1 || exit 7
+	chrony_command "$2"
+	;;
+  status)
+	status chronyd
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload||online|offline|cyclelogs|command|status}"
+	exit 3
+esac
+
+exit $RETVAL

================================================================
Index: packages/chrony/chronyd.sysconfig
diff -u /dev/null packages/chrony/chronyd.sysconfig:1.1
--- /dev/null	Sun Feb  7 19:28:35 2010
+++ packages/chrony/chronyd.sysconfig	Sun Feb  7 19:28:29 2010
@@ -0,0 +1 @@
+OPTIONS="-u ntp"
================================================================


More information about the pld-cvs-commit mailing list