ntp: switch to OpenRC. Create ntpd user/group for chroot.

--HG--
extra : convert_revision : 5ecbdd2f519c0605978a7a2e3e503dae5bb7e99f
This commit is contained in:
Juan RP 2009-05-10 17:52:04 +02:00
parent a0875fe90c
commit b1f0282c6a
8 changed files with 88 additions and 60 deletions

24
templates/ntp/INSTALL Normal file
View file

@ -0,0 +1,24 @@
#
# This script creates the ntpd system user/group.
#
case "${ACTION}" in
pre)
;;
post)
echo "Running ${PKGNAME}-${VERSION} post installation hooks..."
if ! getent group ntpd >/dev/null; then
groupadd -r ntpd 2>&1 >/dev/null
[ $? -ne 0 ] && exit $?
echo "Created ntpd system group."
fi
if ! getent passwd ntpd >/dev/null; then
useradd -c "Network Time Protocol Daemon" \
-d /var/chroot/ntpd \
-s /sbin/nologin -g ntpd -r ntpd && \
passwd -l ntpd 2>&1 >/dev/null
[ $? -ne 0 ] && exit $?
echo "Created ntpd system user."
fi
;;
esac

11
templates/ntp/REMOVE Normal file
View file

@ -0,0 +1,11 @@
#
# This script removes the ntpd user/group.
#
case "${ACTION}" in
pre)
userdel ntpd 2>&1 >/dev/null
[ $? -eq 0 ] && echo "Removed ntpd system user/group."
;;
post)
;;
esac

View file

@ -17,7 +17,7 @@ pidfile /var/run/ntpd.pid
# The correction calculated by ntpd(8) for the local system clock's # The correction calculated by ntpd(8) for the local system clock's
# drift is stored here. # drift is stored here.
driftfile /var/db/ntp.drift driftfile /var/db/ntpd.drift
# Suppress the syslog(3) message for each peer synchronization change. # Suppress the syslog(3) message for each peer synchronization change.

View file

@ -1,19 +0,0 @@
#!/bin/sh
#
# $NetBSD: ntpd,v 1.13 2004/08/13 18:08:03 mycroft Exp $
#
# PROVIDE: ntpd
# REQUIRE: DAEMON
# BEFORE: LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="ntpd"
rcvar=$name
command="/usr/bin/${name}"
pidfile="/var/run/${name}.pid"
required_files="/etc/ntp.conf"
load_rc_config $name
run_rc_command "$1"

View file

@ -0,0 +1,6 @@
# Configuration file for ntp.
#
# Uncomment the following to run ntpd(8) enjailed in
# a chroot directory.
#
#ntpd_chroot=/var/chroot/ntpd

View file

@ -0,0 +1,37 @@
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
: ${ntpd_config:=/etc/ntp.conf}
: ${ntpd_drift:=/var/db/ntpd.drift}
command=/usr/bin/ntpd
required_files=$ntpd_config
pidfile=/var/run/ntpd.pid
command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile"
name="Network Time Protocol Daemon"
depend()
{
use dns
need localmount
after bootmisc ntp-client
}
start_pre()
{
if [ -n "$ntpd_chroot" ]; then
case "$RC_UNAME" in
*BSD|DragonFly)
if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then
rm -f "$ntpd_chroot/dev/clockctl"
(cd /dev; /bin/pax -rw -pe clockctl \
"$ntpd_chroot/dev")
fi
;;
esac
ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift"
command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot"
fi
}

View file

@ -1,36 +0,0 @@
#!/bin/sh
#
# $NetBSD: ntpdate,v 1.18 2005/03/15 12:06:12 lukem Exp $
#
# PROVIDE: ntpdate
# REQUIRE: NETWORKING LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="ntpdate"
rcvar=$name
command="/usr/bin/${name}"
start_cmd="ntpdate_start"
stop_cmd=":"
ntpdate_start()
{
if [ -z "$ntpdate_hosts" ]; then
ntpdate_hosts=$(awk '
/^#/ { next }
/^(server|peer)[ \t]*127.127/ { next }
/^(server|peer)/ { if ($2 ~ /^-[46]/)
print $3
else
print $2 }
' </etc/ntp.conf)
fi
if [ -n "$ntpdate_hosts" ]; then
echo "Setting date via ntp."
$command $rc_flags $ntpdate_hosts 2>&1 >/dev/null &
fi
}
load_rc_config $name
run_rc_command "$1"

View file

@ -2,7 +2,7 @@
pkgname=ntp pkgname=ntp
sourcepkg=$pkgname sourcepkg=$pkgname
version=4.2.4p6 version=4.2.4p6
revision=1 revision=2
distfiles="http://archive.ntp.org/ntp4/$pkgname-$version.tar.gz" distfiles="http://archive.ntp.org/ntp4/$pkgname-$version.tar.gz"
build_style=gnu_configure build_style=gnu_configure
configure_args="--enable-linuxcaps --enable-getifaddrs=glibc configure_args="--enable-linuxcaps --enable-getifaddrs=glibc
@ -19,17 +19,22 @@ long_desc="
subpackages="perl" subpackages="perl"
conf_files="/etc/ntp.conf" conf_files="/etc/ntp.conf"
openrc_services="ntpd default"
triggers="openrc-service"
Add_dependency full glibc Add_dependency full glibc
Add_dependency full openssl Add_dependency full openssl
Add_dependency run ncurses-libs
Add_dependency run OpenRC
post_install() post_install()
{ {
install -d ${DESTDIR}/etc/rc.d install -d ${DESTDIR}/var/chroot/ntpd
install -d ${DESTDIR}/etc/init.d ${DESTDIR}/etc/conf.d
install -d ${DESTDIR}/usr/share/ntp install -d ${DESTDIR}/usr/share/ntp
install -d ${DESTDIR}/usr/share/doc/ntp install -d ${DESTDIR}/usr/share/doc/ntp
install -m 755 ${FILESDIR}/ntpd ${DESTDIR}/etc/rc.d/ntpd install -m 644 ${FILESDIR}/ntpd.confd ${DESTDIR}/etc/conf.d/ntpd
install -m 755 ${FILESDIR}/ntpdate ${DESTDIR}/etc/rc.d/ntpdate install -m 755 ${FILESDIR}/ntpd.rc ${DESTDIR}/etc/init.d/ntpd
install -m 644 ${FILESDIR}/ntp.conf ${DESTDIR}/etc/ntp.conf install -m 644 ${FILESDIR}/ntp.conf ${DESTDIR}/etc/ntp.conf
cp -a ${wrksrc}/html ${DESTDIR}/usr/share/doc/ntp cp -a ${wrksrc}/html ${DESTDIR}/usr/share/doc/ntp
cp -a ${wrksrc}/conf ${DESTDIR}/usr/share/ntp cp -a ${wrksrc}/conf ${DESTDIR}/usr/share/ntp