network/openntpd: Added (Network Time Protocol client/server).

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
LEVAI Daniel 2015-01-09 07:10:40 +07:00 committed by Willy Sudiarto Raharjo
parent 9ab32a1f29
commit 36f101a0eb
9 changed files with 351 additions and 0 deletions

13
network/openntpd/README Normal file
View File

@ -0,0 +1,13 @@
OpenNTPD is a FREE, easy to use implementation of the Network Time Protocol. It
provides the ability to sync the local clock to remote NTP servers and can act
as NTP server itself, redistributing the local clock.
OpenNTPD was primarily developed by Henning Brauer as part of the OpenBSD
Project and gets released as a base component of OpenBSD every six months.
The portable version is maintained by Brent Cook and is mirrored on Github and
available as periodic tarball releases. Contributions are welcome to both the
OpenNTPD core and the portable build framework.
This build script will try to create the user and group '_ntp', that is
necessary to run openntpd.

View File

@ -0,0 +1,26 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
preserve_perms() {
NEW="$1"
OLD="$(dirname ${NEW})/$(basename ${NEW} .new)"
if [ -e ${OLD} ]; then
cp -a ${OLD} ${NEW}.incoming
cat ${NEW} > ${NEW}.incoming
mv ${NEW}.incoming ${NEW}
fi
config ${NEW}
}
preserve_perms etc/rc.d/rc.openntpd.new
config etc/openntpd.conf.new

View File

@ -0,0 +1,142 @@
#!/bin/sh
# Slackware build script for openntpd
# Copyright (c) 2015 LEVAI Daniel
# All rights reserved.
#
# * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright notice
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS 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
# COPYRIGHT HOLDER 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.
PRGNAM=openntpd
VERSION=${VERSION:-5.7p1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
echo "You must have a user and group called '_ntp' to use this package. E.g.:
# groupadd -g 217 _ntp
# useradd -u 217 -m -d /var/empty/openntpd -s /bin/false -g _ntp _ntp"
# Check the user/group if they're present
egrep -q -e '^_ntp:' /etc/passwd
egrep -q -e '^_ntp:' /etc/group
# Create the _ntp user's home, and the daemon's chroot directory
mkdir -p $PKG/var/empty/openntpd
chown root:root $PKG/var/empty/openntpd
chmod 0755 $PKG/var/empty/openntpd
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
for diff in $CWD/patches/*.diff;do
patch -p1 < "${diff}"
done
# Prepare the source for renamings, later in the build script
sed -i -r -e 's,^(#define CONFFILE SYSCONFDIR "/)(ntpd)(\.conf")$,\1open\2\3,' ./ntpd.h
sed -i -r -e 's,^(#define DRIFTFILE LOCALSTATEDIR "/db/)(ntpd)(\.drift")$,\1open\2\3,' ./ntpd.h
sed -i -r -e 's,^(#define CTLSOCKET LOCALSTATEDIR "/run/)(ntpd)(\.sock")$,\1open\2\3,' ./ntpd.h
sed -i -r -e 's,ntpd,openntpd,;s,NTPD,OPENNTPD,;s,ntpctl,openntpctl,' \
./ntpd.8 ./ntpd.conf.5 ./ntpctl.8 ./ntpd.conf
sed -i -r -e 's,adjfreq,adjtime,' ./ntpd.8
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--build=$ARCH-slackware-linux
make
make install DESTDIR=$PKG
# Remove unnecessary directories created by `make install`
rmdir $PKG/var/run/
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
# Don't interfere with stock ntp package
mv $PKG/usr/sbin/ntpd $PKG/usr/sbin/openntpd
mv $PKG/usr/sbin/ntpctl $PKG/usr/sbin/openntpctl
mv $PKG/usr/man/man8/ntpd.8.gz $PKG/usr/man/man8/openntpd.8.gz
mv $PKG/usr/man/man8/ntpctl.8.gz $PKG/usr/man/man8/openntpctl.8.gz
mv $PKG/usr/man/man5/ntpd.conf.5.gz $PKG/usr/man/man5/openntpd.conf.5.gz
mv $PKG/etc/ntpd.conf $PKG/etc/openntpd.conf.new
# Add an init script
mkdir -p $PKG/etc/rc.d
install -m 0644 $CWD/rc.openntpd $PKG/etc/rc.d/rc.openntpd.new
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a INSTALL README $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View File

@ -0,0 +1,10 @@
PRGNAM="openntpd"
VERSION="5.7p1"
HOMEPAGE="http://www.openntpd.org/portable.html"
DOWNLOAD="http://ftp.OpenBSD.org/pub/OpenBSD/OpenNTPD/openntpd-5.7p1.tar.gz"
MD5SUM="800c5d3ef2b8e3ac403698fdf0c54c2a"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="LEVAI Daniel"
EMAIL="leva@ecentrum.hu"

View File

@ -0,0 +1,41 @@
--- a/ntpd.c.orig 2015-01-08 10:43:16.834158734 +0100
+++ b/ntpd.c 2015-01-08 10:46:24.943458619 +0100
@@ -100,8 +100,9 @@ usage(void)
{
extern char *__progname;
- if (strcmp(__progname, "ntpctl") == 0)
- fprintf(stderr, "usage: ntpctl [-s all | peers | Sensors | status]\n");
+ if (strcmp(__progname, "openntpctl") == 0)
+ fprintf(stderr, "usage: %s [-s all | peers | Sensors | status]\n",
+ __progname);
else
fprintf(stderr, "usage: %s [-dnSsv] [-f file] [-p file]\n",
__progname);
@@ -124,7 +125,7 @@ main(int argc, char *argv[])
extern char *__progname;
time_t start_time;
- if (strcmp(__progname, "ntpctl") == 0) {
+ if (strcmp(__progname, "openntpctl") == 0) {
ctl_main (argc, argv);
/* NOTREACHED */
}
@@ -605,7 +606,7 @@ ctl_main(int argc, char *argv[])
usage();
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
- err(1, "ntpctl: socket");
+ err(1, "openntpctl: socket");
bzero(&sa, sizeof(sa));
sa.sun_family = AF_UNIX;
@@ -650,7 +651,7 @@ ctl_main(int argc, char *argv[])
if ((n = imsg_read(ibuf_ctl)) == -1)
err(1, "ibuf_ctl: imsg_read error");
if (n == 0)
- errx(1, "ntpctl: pipe closed");
+ errx(1, "openntpctl: pipe closed");
while (!done) {
if ((n = imsg_get(ibuf_ctl, &imsg)) == -1)

View File

@ -0,0 +1,39 @@
--- a/ntpd.8.orig 2015-01-08 07:57:55.000000000 +0100
+++ b/ntpd.8 2015-01-08 11:35:04.889368624 +0100
@@ -1,7 +1,3 @@
-.\" $OpenBSD: ntpd.8,v 1.36 2013/10/04 14:28:16 phessler Exp $
-.\"
-.\" Copyright (c) 2003, 2004, 2006 Henning Brauer <henning@openbsd.org>
-.\"
.\" 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.
@@ -99,19 +95,6 @@ adjusts the clock frequency using the
.Xr adjfreq 2
system call to compensate for systematic drift.
.Pp
-.Nm
-is usually started at boot time, and can be enabled by
-setting
-.Va ntpd_flags
-in
-.Pa /etc/rc.conf.local .
-See
-.Xr rc 8
-and
-.Xr rc.conf 8
-for more information on the boot process
-and enabling daemons.
-.Pp
When
.Nm
starts up, it reads settings from its configuration file,
@@ -144,8 +127,6 @@ Socket file for communication with
.Xr adjtime 2 ,
.Xr ntpd.conf 5 ,
.Xr ntpctl 8 ,
-.Xr rc 8 ,
-.Xr rc.conf 8 ,
.Xr rdate 8
.Sh STANDARDS
.Rs

View File

@ -0,0 +1,18 @@
--- a/ntpd.conf.5.orig 2015-01-08 11:35:23.671118459 +0100
+++ b/ntpd.conf.5 2015-01-08 11:36:10.673989819 +0100
@@ -1,5 +1,3 @@
-.\" $OpenBSD: ntpd.conf.5,v 1.23 2011/09/21 15:41:30 phessler Exp $
-.\"
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -196,9 +194,3 @@ The
.Nm
file format first appeared in
.Ox 3.6 .
-.Sh CAVEATS
-When using different
-.Cm rtable
-options,
-.Xr ntpd 8
-must be started in rtable 0.

View File

@ -0,0 +1,43 @@
#!/bin/sh
# Start/stop/restart the network time protocol daemon
# Written for Slackware Linux by Robby Workman <http://rlworkman.net>
# (by modifying one of Pat's scripts)
# Add -s to the command to set the time at startup
openntpd_start() {
if [ -x ${BIN} ]; then
echo "Starting openntpd daemon: ${BIN}"
${BIN} -p /var/run/openntpd.pid
fi
}
openntpd_stop() {
echo "Stopping openntpd daemon..."
pkill -x $(basename ${BIN})
}
openntpd_restart() {
openntpd_stop
sleep 1
openntpd_start
}
BIN=/usr/sbin/openntpd
case "$1" in
'start')
openntpd_start
;;
'stop')
openntpd_stop
;;
'restart')
openntpd_restart
;;
*)
echo "usage $0 start|stop|restart"
;;
esac

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
openntpd: Openntpd (Network Time Protocol client/server)
openntpd:
openntpd: OpenNTPD is a FREE, easy to use implementation of the Network Time
openntpd: Protocol. It provides the ability to sync the local clock to remote
openntpd: NTP servers and can act as NTP server itself, redistributing the
openntpd: local clock. OpenNTPD is part of the OpenBSD Project, and this is the
openntpd: portable version.
openntpd:
openntpd: Homepage: http://www.openntpd.org/portable
openntpd:
openntpd: