1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils systemd user
8 DESCRIPTION="Lightweight NTP server ported from OpenBSD"
9 HOMEPAGE="http://www.openntpd.org/"
10 SRC_URI="mirror://openbsd/OpenNTPD/${MY_P}.tar.gz"
14 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86"
15 IUSE="libressl selinux"
17 DEPEND="!<=net-misc/ntp-4.2.0-r2
18 !net-misc/ntp[-openntpd]
19 libressl? ( >=dev-libs/libressl-2.3.2 )"
21 selinux? ( sec-policy/selinux-ntp )"
23 S="${WORKDIR}/${MY_P}"
26 export NTP_HOME="${NTP_HOME:=/var/lib/openntpd/chroot}"
28 enewuser ntp -1 -1 "${NTP_HOME}" ntp
30 # make sure user has correct HOME as flipping between the standard ntp pkg
31 # and this one was possible in the past
32 if [[ $(egethome ntp) != ${NTP_HOME} ]]; then
33 ewarn "From this version on, the homedir of the ntp user cannot be changed"
34 ewarn "dynamically after the installation. For homedir different from"
35 ewarn "/var/lib/openntpd/chroot set NTP_HOME in your make.conf and re-emerge."
36 esethome ntp "${NTP_HOME}"
42 sed -i 's:/var/run/ntpd:/run/ntpd:g' src/ntpctl.8 src/ntpd.8 || die
43 sed -i 's:LOCALSTATEDIR "/run/ntpd:"/run/ntpd:' src/ntpd.h || die
45 sed -i 's:/var/db/ntpd.drift:/var/lib/openntpd/ntpd.drift:g' src/ntpd.8 || die
46 sed -i 's:"/db/ntpd.drift":"/openntpd/ntpd.drift":' src/ntpd.h || die
47 # fix default config to use gentoo pool
48 sed -i 's:servers pool.ntp.org:#servers pool.ntp.org:' ntpd.conf || die
49 printf "\n# Choose servers announced from Gentoo NTP Pool\nservers 0.gentoo.pool.ntp.org\nservers 1.gentoo.pool.ntp.org\nservers 2.gentoo.pool.ntp.org\nservers 3.gentoo.pool.ntp.org\n" >> ntpd.conf || die
53 econf --with-privsep-user=ntp --with-privsep-path=${NTP_HOME} $(use_enable libressl https-constraint)
60 newinitd "${FILESDIR}/${PN}.init.d-20080406-r6" ntpd
61 newconfd "${FILESDIR}/${PN}.conf.d-20080406-r6" ntpd
64 systemd_newunit "${FILESDIR}/${PN}.service-20080406-r4" ntpd.service
68 # Clean up chroot localtime copy from older versions
69 if [ -d "${EROOT%/}${NTP_HOME}"/etc ] ; then
70 if [ -f "${EROOT%/}${NTP_HOME}"/etc/localtime ] ; then
71 rm -f "${EROOT%/}${NTP_HOME}"/etc/localtime
74 rmdir "${EROOT%/}${NTP_HOME}"/etc ||
75 ewarn "Unable to remove legacy ${EROOT%/}${NTP_HOME}/etc directory"
78 # Fix permissions on home directory
79 chown root:root "${EROOT%/}${NTP_HOME}" || die
81 [[ -f ${EROOT}var/log/ntpd.log ]] && \
82 ewarn "Logfile '${EROOT}var/log/ntpd.log' might be orphaned, please remove it if not in use via syslog."
84 if [[ -f ${EROOT}var/lib/ntpd.drift ]] ; then
85 einfo "Moving ntpd.drift file to new location."
86 mv "${EROOT}var/lib/ntpd.drift" "${EROOT}var/lib/openntpd/ntpd.drift"