3 changed files with 254 additions and 0 deletions
@ -0,0 +1,15 @@
|
||||
## |
||||
## chrony.conf -- Chrony Configuration |
||||
## |
||||
|
||||
keyfile @l_prefix@/etc/chrony/chrony.keys |
||||
driftfile @l_prefix@/var/chrony/run/chrony.drift |
||||
logdir @l_prefix@/var/chrony/log/ |
||||
|
||||
pool pool.ntp.org iburst |
||||
makestep 1.0 3 |
||||
rtcsync |
||||
|
||||
allow 192.168.0.0/16 10.0.0.0/8 |
||||
log measurements statistics tracking |
||||
|
@ -0,0 +1,138 @@
|
||||
## |
||||
## chrony.spec -- OpenPKG RPM Package Specification |
||||
## Copyright (c) 2000-2017 OpenPKG Foundation e.V. <http://openpkg.net/> |
||||
## |
||||
## Permission to use, copy, modify, and distribute this software for |
||||
## any purpose with or without fee is hereby granted, provided that |
||||
## the above copyright notice and this permission notice appear in all |
||||
## copies. |
||||
## |
||||
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
||||
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
||||
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
||||
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
## SUCH DAMAGE. |
||||
## |
||||
|
||||
# package information |
||||
Name: chrony |
||||
Summary: Network Time Protocol (NTP) Server |
||||
URL: https://chrony.tuxfamily.org/ |
||||
Vendor: Richard P. Curnow, Miroslav Lichva |
||||
Packager: OpenPKG Foundation e.V. |
||||
Distribution: OpenPKG Community |
||||
Class: EVAL |
||||
Group: Networking |
||||
License: GPL |
||||
Version: 3.2 |
||||
Release: 20170924 |
||||
|
||||
# list of sources |
||||
Source0: https://download.tuxfamily.org/chrony/chrony-%{version}.tar.gz |
||||
Source1: rc.chrony |
||||
Source2: chrony.conf |
||||
|
||||
# build information |
||||
BuildPreReq: OpenPKG, openpkg >= 20160101 |
||||
PreReq: OpenPKG, openpkg >= 20160101 |
||||
BuildPreReq: ncurses, readline |
||||
PreReq: ncurses, readline |
||||
|
||||
%description |
||||
Chrony is a versatile implementation of the Network Time Protocol |
||||
(NTP). It can synchronise the system clock with NTP servers, |
||||
reference clocks (e.g. GPS receiver), and manual input using |
||||
wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) |
||||
server and peer to provide a time service to other computers in the |
||||
network. |
||||
|
||||
%track |
||||
prog chrony = { |
||||
version = %{version} |
||||
url = https://chrony.tuxfamily.org/download.html |
||||
regex = chrony-(__VER__)\.tar\.gz |
||||
} |
||||
|
||||
%prep |
||||
%setup -q |
||||
|
||||
%build |
||||
# configure program |
||||
CC="%{l_cc}" \ |
||||
CFLAGS="%{l_cflags -O}" \ |
||||
CPPFLAGS="%{l_cppflags}" \ |
||||
LDFLAGS="%{l_ldflags}" \ |
||||
./configure \ |
||||
--prefix=%{l_prefix} \ |
||||
--mandir=%{l_prefix}/man \ |
||||
--sysconfdir=%{l_prefix}/etc/chrony \ |
||||
--localstatedir=%{l_prefix}/var/chrony \ |
||||
--chronyrundir=%{l_prefix}/var/chrony/run \ |
||||
--chronyvardir=%{l_prefix}/var/chrony/run \ |
||||
--with-pidfile=%{l_prefix}/var/chrony/run/chrony.pid \ |
||||
--with-sendmail=%{l_prefix}/sbin/sendmail \ |
||||
--enable-readline \ |
||||
--with-readline \ |
||||
--without-editline \ |
||||
--with-readline-includes=%{l_prefix}/include \ |
||||
--with-readline-library=%{l_prefix}/lib \ |
||||
--with-ncurses-library=%{l_prefix}/lib |
||||
|
||||
# build program |
||||
%{l_make} %{l_mflags -O} |
||||
|
||||
%install |
||||
# install program |
||||
%{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT |
||||
|
||||
# strip down installation |
||||
strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true |
||||
|
||||
# install default configuration |
||||
%{l_shtool} mkdir -f -p -m 755 \ |
||||
$RPM_BUILD_ROOT%{l_prefix}/etc/chrony |
||||
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
||||
%{SOURCE chrony.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/chrony/ |
||||
|
||||
# install run-command script |
||||
%{l_shtool} mkdir -f -p -m 755 \ |
||||
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d |
||||
%{l_shtool} install -c -m 755 %{l_value -s -a} \ |
||||
%{SOURCE rc.chrony} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
||||
|
||||
# create run-time directories |
||||
%{l_shtool} mkdir -f -p -m 755 \ |
||||
$RPM_BUILD_ROOT%{l_prefix}/var/chrony/run \ |
||||
$RPM_BUILD_ROOT%{l_prefix}/var/chrony/log |
||||
|
||||
# determine installation files |
||||
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
||||
%{l_files_std} \ |
||||
'%config %{l_prefix}/etc/chrony/chrony.conf' \ |
||||
'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/chrony/*' |
||||
|
||||
%files -f files |
||||
|
||||
%clean |
||||
|
||||
%post |
||||
# after upgrade, restart service |
||||
[ $1 -eq 2 ] || exit 0 |
||||
eval `%{l_rc} chrony status 2>/dev/null` |
||||
[ ".$chrony_active" = .yes ] && %{l_rc} chrony restart |
||||
exit 0 |
||||
|
||||
%preun |
||||
# before erase, stop service and remove log files |
||||
[ $1 -eq 0 ] || exit 0 |
||||
%{l_rc} chrony stop 2>/dev/null |
||||
rm -f $RPM_INSTALL_PREFIX/var/chrony/* >/dev/null 2>&1 || true |
||||
exit 0 |
||||
|
@ -0,0 +1,101 @@
|
||||
#!@l_prefix@/bin/openpkg rc |
||||
## |
||||
## rc.chrony -- Run-Commands |
||||
## |
||||
|
||||
%config |
||||
chrony_enable="$openpkg_rc_def" |
||||
chrony_mode="daemon" |
||||
chrony_daemon_flags="" |
||||
chrony_log_prolog="true" |
||||
chrony_log_epilog="true" |
||||
chrony_log_numfiles="10" |
||||
chrony_log_minsize="1M" |
||||
chrony_log_complevel="9" |
||||
|
||||
%common |
||||
chrony_pidfile="@l_prefix@/var/chrony/run/chrony.pid" |
||||
chrony_signal () { |
||||
[ -f $chrony_pidfile ] && kill -$1 `cat $chrony_pidfile` |
||||
} |
||||
chrony_once () { |
||||
[ ".$1" != . ] && sleep $1 |
||||
@l_prefix@/sbin/chronyd -q |
||||
} |
||||
|
||||
%status -u @l_susr@ -o |
||||
chrony_usable="unknown" |
||||
chrony_active="no" |
||||
rcService chrony enable yes && \ |
||||
[ ".$chrony_mode" = ".daemon" ] && \ |
||||
chrony_signal 0 && chrony_active="yes" |
||||
echo "chrony_enable=\"$chrony_enable\"" |
||||
echo "chrony_usable=\"$chrony_usable\"" |
||||
echo "chrony_active=\"$chrony_active\"" |
||||
|
||||
%start -p 200 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
rcService chrony active yes && exit 0 |
||||
|
||||
# under both periodical and daemon mode, synchronize local machine |
||||
# once manually -- either to fill the gap between startup time and |
||||
# the first run of the cron jobs (periodical mode) or to perform |
||||
# a possible large time offset which chronyd does not perform itself |
||||
# (daemon mode). |
||||
case "$chrony_mode" in |
||||
once | \ |
||||
daemon | \ |
||||
quarterly | hourly | daily | weekly | monthly ) |
||||
chrony_once |
||||
;; |
||||
esac |
||||
|
||||
# run the NTP daemon for continued synchronization |
||||
if [ ".$chrony_mode" = .daemon ]; then |
||||
@l_prefix@/sbin/chronyd \ |
||||
-u @l_nusr@ \ |
||||
${chrony_daemon_flags} |
||||
fi |
||||
|
||||
%stop -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
rcService chrony active no && exit 0 |
||||
chrony_signal TERM |
||||
rm -f $chrony_pidfile 2>/dev/null || true |
||||
|
||||
%restart -p 200 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
rcService chrony active no && exit 0 |
||||
rc chrony stop start |
||||
|
||||
%quarterly -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
[ ".$chrony_mode" = .quarterly ] && chrony_once 30 |
||||
exit 0 |
||||
|
||||
%hourly -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
[ ".$chrony_mode" = .hourly ] && chrony_once 30 |
||||
exit 0 |
||||
|
||||
%daily -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
[ ".$chrony_mode" = .daily ] && chrony_once 30 |
||||
shtool rotate -f \ |
||||
-n ${chrony_log_numfiles} -s ${chrony_log_minsize} -d \ |
||||
-z ${chrony_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \ |
||||
-P "${chrony_log_prolog}" \ |
||||
-E "${chrony_log_epilog}; rc chrony restart" \ |
||||
@l_prefix@/var/chrony/log/chrony.log |
||||
exit 0 |
||||
|
||||
%weekly -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
[ ".$chrony_mode" = .weekly ] && chrony_once 30 |
||||
exit 0 |
||||
|
||||
%monthly -p 800 -u @l_susr@ |
||||
rcService chrony enable yes || exit 0 |
||||
[ ".$chrony_mode" = .monthly ] && chrony_once 30 |
||||
exit 0 |
||||
|
Loading…
Reference in new issue