]> git.pld-linux.org Git - packages/chrony.git/commitdiff
- new, based on fc package
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 7 Feb 2010 18:28:29 +0000 (18:28 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    chrony.conf -> 1.1
    chrony.keys -> 1.1
    chrony.logrotate -> 1.1
    chrony.spec -> 1.1
    chronyd.init -> 1.1
    chronyd.sysconfig -> 1.1

chrony.conf [new file with mode: 0644]
chrony.keys [new file with mode: 0644]
chrony.logrotate [new file with mode: 0644]
chrony.spec [new file with mode: 0644]
chronyd.init [new file with mode: 0644]
chronyd.sysconfig [new file with mode: 0644]

diff --git a/chrony.conf b/chrony.conf
new file mode 100644 (file)
index 0000000..0b5c8f4
--- /dev/null
@@ -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
diff --git a/chrony.keys b/chrony.keys
new file mode 100644 (file)
index 0000000..6bed03a
--- /dev/null
@@ -0,0 +1 @@
+#1 a_key
diff --git a/chrony.logrotate b/chrony.logrotate
new file mode 100644 (file)
index 0000000..88ca825
--- /dev/null
@@ -0,0 +1,8 @@
+/var/log/chrony/*.log {
+    missingok
+    nocreate
+    sharedscripts
+    postrotate
+        /sbin/service chronyd cyclelogs > /dev/null
+    endscript
+}
diff --git a/chrony.spec b/chrony.spec
new file mode 100644 (file)
index 0000000..57c15bf
--- /dev/null
@@ -0,0 +1,123 @@
+%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
diff --git a/chronyd.init b/chronyd.init
new file mode 100644 (file)
index 0000000..bdf0a4f
--- /dev/null
@@ -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
diff --git a/chronyd.sysconfig b/chronyd.sysconfig
new file mode 100644 (file)
index 0000000..8b0293e
--- /dev/null
@@ -0,0 +1 @@
+OPTIONS="-u ntp"
This page took 0.18203 seconds and 4 git commands to generate.