You are not logged in.
I'm trying to improve openntpd pkgbuild. This is a testing version. Unfortunatelly I don't have time (how ironic :-)) to maintain this in AUR so if anyone wants to do it or just test it please don't hesitate. I would also like to leave the patched version running for some time on my server to check if everything is ok.
History:
There were many discussions about ntp/openntpd setups for example:
http://bbs.archlinux.org/viewtopic.php?t=5709
and a recent one:
http://bbs.archlinux.org/viewtopic.php?t=12303
I have borrowed a lot from:
http://bbs.archlinux.org/viewtopic.php?t=7996
Some problems and solutions (?) from gentoo forums:
http://forums.gentoo.org/viewtopic-t-41 … rt-75.html
http://forums.gentoo.org/viewtopic-t-28 … rt-25.html
http://forums.gentoo.org/viewtopic-t-30 … nntpd.html
Some complaints and answers by the ntp experts:
http://web.archive.org/web/200411040738 … nntpd.html
http://bradknowles.typepad.com/consider … nntpd.html
http://www.advogato.org/person/dtucker/
If you want to know (almost) everything about hardware and kernel clocks and how it all works with ntp I'd suggest reading hwclock manpage - it's an excellent description of the whole thing (hwclock is used in arch in /etc/rc.sysinit and /etc/rc.shutdown and the location of the adjtime file is /var/lib/hwclock not /etc)
Now some fresh meat :-) (note: if you copy / paste the below pkgbuilds don't forget to delete and regenerate md5sums with pacman -g >>PKGBUILD)
openntpd patched PKGBUILD:
pkgname=openntpd
pkgver=3.6.1p1
pkgrel=2
pkgdesc="Free and easy to use implementation of the Network Time Protocol"
url="http://www.openntpd.org"
depends=('openssl')
conflicts=('ntp')
provides=('ntp')
backup=('etc/ntpd.conf')
install=$pkgname.install
source=(ftp://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/$pkgname-$pkgver.tar.gz $pkgname
http://www.zip.com.au/~dtucker/openntpd/patches/openntpd-3.6.1p1-linux-adjtimex.patch)
md5sums=('4584f226523776a3cdd2fb6f8212ba8d' '4952a5570c57d4365198c31986774f6d'
'282ffe9c6e13826fea82c90c8af7dfa8')
build() {
cd $startdir/src/$pkgname-$pkgver
patch -p0 <../openntpd-3.6.1p1-linux-adjtimex.patch
sed -i "s#& POLLOUT#& (POLLOUT|POLLERR)#g" ./ntp.c
sed -i "s#& POLLIN#& (POLLIN|POLLERR)#g" ./ntp.c
autoconf
./configure --prefix=/usr --sysconfdir=/etc --with-privsep-user=${pkgname} --with-privsep-path=/var/${pkgname} --with-adjtimex
make || return 1
make DESTDIR=$startdir/pkg install
install -D -m755 $startdir/src/${pkgname} $startdir/pkg/etc/rc.d/${pkgname}
}
openntpd (for /etc/rc.d)
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
PID=`pidof -o %PPID /usr/sbin/ntpd`
case "$1" in
start)
stat_busy "Starting OpenNTPD"
if [ -z "$PID" ]; then
/usr/sbin/ntpd -s &
fi
if [ ! -z "$PID" -o $? -gt 0 ]; then
stat_fail
else
add_daemon openntpd
stat_done
fi
;;
stop)
stat_busy "Stopping OpenNTPD"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon openntpd
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
openntpd.install
# arg 1: the new package version
pre_install() {
/bin/true
}
# arg 1: the new package version
post_install() {
groupadd -g 123 openntpd &>/dev/null
useradd -u 123 -g openntpd -d /var/openntpd -s /bin/false -c 'OpenNTP daemon' openntpd &>/dev/null
chown openntpd.openntpd /var/openntpd &>/dev/null
chmod 770 /var/openntpd &>/dev/null
}
# arg 1: the new package version
# arg 2: the old package version
pre_upgrade() {
/bin/true
}
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
/bin/true
}
# arg 1: the old package version
pre_remove() {
/bin/true
}
# arg 1: the old package version
post_remove() {
userdel openntpd &>/dev/null
groupdel openntpd &>/dev/null
}
op=$1
shift
$op $*
The next utility is separate (it has nothing to do with the adjtimex.patch) and not required by openntpd but it can be very useful if you want to tweak system time:
adjtimex
pkgname=adjtimex
pkgver=1.20
pkgrel=1
pkgdesc="Displays or sets the kernel time variable"
url="http://directory.fsf.org/sysadmin/adjtimex.html"
depends=(glibc)
source=(http://www.ibiblio.org/pub/Linux/system/admin/time/$pkgname-$pkgver.tar.gz)
md5sums=('00b56c266e707b8c753dfe1d33745226')
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
make || return 1
install -D -m755 $startdir/src/$pkgname-$pkgver/$pkgname $startdir/pkg/usr/sbin/$pkgname
install -D -m644 $startdir/src/$pkgname-$pkgver/$pkgname.8 $startdir/pkg/usr/man/man8/$pkgname.8
}
My openntpd config on the server (which is also a router for my home network) looks like this:
/etc/ntpd.conf
listen on 127.0.0.1
listen on my_server_local_ip
listen on my_server_public_ip
server 153.19.0.141
server 193.219.28.149
Last two IPs are public ntp servers (aka stratum 2). You can use as many as you like (read man ntpd.conf).
My config for the destkop machine is very simple:
/etc/ntpd.conf
server my_server_local_ip
These configs seem to work fine but I have to test it in a longer period of time to be sure.
Before running /etc/rc.d/openntpd start first check if there are no errors on the server with (openntpd logs only big corrections):
ntpd -s -d -f /etc/ntpd.conf
It should print IPs on which it's going to listen, "ntp engine ready" message and a series of synchronization attempts like this:
reply from 193.219.28.149: offset 0.049961 delay 0.022013, next query 5s
reply from 153.19.0.141: offset 0.047900 delay 0.030753, next query 5s
reply from 193.219.28.149: offset 0.049457 delay 0.021991, next query 5s
reply from 153.19.0.141: offset 0.048330 delay 0.030133, next query 5s
reply from 193.219.28.149: offset 0.050135 delay 0.022212, next query 5s
reply from 153.19.0.141: offset 0.044207 delay 0.038257, next query 5s
peer 193.219.28.149 now valid
reply from 193.219.28.149: offset 0.053954 delay 0.029666, next query 5s
peer 153.19.0.141 now valid
reply from 153.19.0.141: offset 0.048218 delay 0.030279, next query 5s
reply from 193.219.28.149: offset 0.049872 delay 0.021974, next query 5s
reply from 153.19.0.141: offset 0.048815 delay 0.030122, next query 5s
reply from 193.219.28.149: offset 0.050430 delay 0.023893, next query 5s
reply from 153.19.0.141: offset 0.048642 delay 0.029660, next query 5s
reply from 193.219.28.149: offset 0.050291 delay 0.021621, next query 298s
reply from 153.19.0.141: offset 0.048816 delay 0.029980, next query 300s
Now you can also check your system with adjtimex like this:
adjtimex --print
mode: 0
offset: 0
frequency: 0
maxerror: 16384000
esterror: 16384000
status: 64
time_constant: 2
precision: 1
tolerance: 33554432
tick: 10000
raw time: 1115944646s 586836us = 1115944646.586836
return value = 5
The important values are "status" and "tick".
This short doc describes what you can do with adjtimex (also read hwclock and adjtimex man pages and forum posts mentioned at the begining):
http://www.togaware.com/linux/survivor/ … imex.shtml
That's it for now :-)
Offline
AUR? It isn't that much work...
BTW, your package needs to create a new user.
Offline
It's not about adding it but maitaining later in AUR :-)
On the other hand there shoudn't be many upgrades because it does all what it was designed for (simple ntp not full implementation)
BTW it does create a new user in openntpd.install script and changes permissions for /var/openntpd directory etc. (though I don't know if this is _the_ best way to do it).
Offline
worked great for me. thanks
took me a few minutes (or more precisely errors) though to figure out I had to copy openntpd and openntpd.install to the build directory (shows how professional tester I am )
pozdro...
w.
Offline