#!/sbin/runscript # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-dns/pdns-recursor/files/precursor,v 1.5 2011/12/04 10:13:16 swegener Exp $ command="/usr/sbin/pdns_recursor" command_args="--daemon=yes &>/dev/null" rec_control="/usr/sbin/rec_control" pidfile="/run/powerdns/pdns_recursor.pid" configfile="/etc/powerdns/recursor.conf" extra_started_commands="ping reload_acls reload_zones top_remotes get_all" extra_stopped_commands="monitor" description="PowerDNS Recursor" description_ping="Check if server is alive." description_reload_acls="Reload access control lists." description_reload_zones="Reload data about all authoritative and forward zones." description_top_remotes="Shows the top-20 most active remote hosts." description_get_all="Retrieve all statistics in one go." description_monitor="Starts PowerDNS Recursor in foreground with logging enabled." _update_chroot_environment() { local piddir="$(dirname ${pidfile})" local chroot=`awk -F= '{ if (tolower($1) == "chroot") { print $2 } }' "${configfile}" | tr -d '"' 2> /dev/null` if [ ! -z "${chroot}" ]; then ebegin "Updating PowerDNS Recursor chroot environment in '${chroot}'" checkpath -d -m 0775 -o root:root "${chroot}/etc" if [ -r '/etc/localtime' ]; then cp --preserve --force /etc/localtime "${chroot}/etc" fi checkpath -d -m 0775 -o root:root "${chroot}/etc/powerdns" cp --preserve --force ${configfile} "${chroot}/etc/powerdns" # Create folder structure for pidfile/sockets local chroot_piddir="${chroot}${piddir}" checkpath -d -m 0775 -o root:root "${chroot}/run" checkpath -d -m 0775 -o root:root "${chroot_piddir}" # We need to delete any previous pidfile location or symlink creation # may fail. rm -rf "${piddir}" ln -s "${chroot_piddir}" "${piddir}" eend $? else einfo "Skipping update of chroot environment, because no 'chroot=' directive in '${chroot}' found!" checkpath -d -m 0775 -o root:root "${piddir}" fi } depend() { need net } start_pre() { _update_chroot_environment } ping() { ${rec_control} ping } reload_acls() { _update_chroot_environment ${rec_control} reload-acls } reload_zones() { ${rec_control} reload-zones } top_remotes() { ${rec_control} top-remotes } get_all() { ${rec_control} get-all } monitor() { _update_chroot_environment ${command} --daemon=no --quiet=no --log-common-errors=yes }