--- /dev/null
+#!/bin/bash
+#
+# pdns-recursor This shell script controls the PowerDNS Recursor
+#
+# Author: Ruben Kerkhof <ruben@rubenkerkhof.com>
+#
+# chkconfig: - 49 51
+#
+# description: PowerDNS Recursor is a non authoritative/recursing DNS server
+# processname: pdns-recursor
+# config: /etc/pdns-recursor/recursor.conf
+# pidfile: /var/run/pdns_recursor.pid
+#
+
+# . function library
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+PIDDIR=$(awk -F= '/^socket-dir=/ {print $2}' /etc/pdns-recursor/recursor.conf)
+if [ -z "$PIDDIR" ]; then PIDDIR=/var/run; fi
+mkdir -p "$PIDDIR"
+
+start() {
+ echo -n $"Starting pdns-recursor: "
+ daemon /usr/sbin/pdns_recursor --daemon 2>/dev/null
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdns-recursor
+}
+
+stop() {
+ echo -n $"Stopping pdns-recursor: "
+ killproc pdns_recursor
+ echo
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pdns-recursor && rm -f $PIDDIR/pdns_recursor.controlsocket
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|force-reload|reload)
+ restart
+ ;;
+ condrestart)
+ [ -f /var/lock/subsys/pdns-recursor ] && restart
+ ;;
+ status)
+ status pdns_recursor
+ RETVAL=$?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+ exit 1
+esac
+
+exit $RETVAL
--- /dev/null
+Name: pdns-recursor
+Version: %{getenv:BUILDER_VERSION}
+Release: %{getenv:BUILDER_RELEASE}%{?dist}
+Summary: Modern, advanced and high performance recursing/non authoritative name server
+Group: System Environment/Daemons
+License: GPLv2
+URL: https://powerdns.com
+Source0: %{name}-%{version}.tar.bz2
+%if 0%{?rhel} == 6
+Source1: pdns-recursor.init
+%endif
+
+Provides: powerdns-recursor = %{version}-%{release}
+%if 0%{?rhel} == 6
+BuildRequires: boost148-devel
+BuildRequires: lua-devel
+%else
+BuildRequires: boost-devel
+BuildRequires: luajit-devel
+BuildRequires: systemd
+BuildRequires: systemd-devel
+%endif
+
+# Note: The ifarch for luajit is removed becuae of EL6 not having luajit
+
+%ifarch ppc64 ppc64le
+BuildRequires: libatomic
+%endif
+
+BuildRequires: openssl-devel
+BuildRequires: net-snmp-devel
+BuildRequires: protobuf-compiler
+BuildRequires: protobuf-devel
+BuildRequires: libsodium-devel
+
+Requires(pre): shadow-utils
+%if 0%{?rhel} == 6
+Requires(post): /sbin/chkconfig
+Requires(preun): /sbin/service, /sbin/chkconfig
+Requires(postun): /sbin/service
+%else
+%systemd_requires
+%endif
+
+%description
+PowerDNS Recursor is a non authoritative/recursing DNS server. Use this
+package if you need a dns cache for your network.
+
+
+%prep
+%if 0%{?rhel} == 6
+%setup -q -n %{name}-%{version}
+%else
+%autosetup -p1
+%endif
+
+%build
+%configure \
+ --sysconfdir=%{_sysconfdir}/%{name} \
+ --enable-libsodium \
+ --with-protobuf \
+ --with-netsnmp \
+ --disable-silent-rules \
+ --disable-static \
+ --enable-unit-tests \
+%if 0%{?rhel} == 6
+ --with-boost=/usr/include/boost148 LIBRARY_PATH=/usr/lib64/boost148
+
+make %{?_smp_mflags} LIBRARY_PATH=/usr/lib64/boost148
+%else
+ --with-luajit \
+ --enable-systemd --with-systemd=%{_unitdir}
+
+make %{?_smp_mflags}
+%endif
+
+%check
+make %{?_smp_mflags} check || (cat test-suite.log && false)
+
+%install
+make install DESTDIR=%{buildroot}
+
+%{__mv} %{buildroot}%{_sysconfdir}/%{name}/recursor.conf{-dist,}
+
+%if 0%{?rhel} == 6
+%{__install} -D -p %{SOURCE1} %{buildroot}%{_initrddir}/pdns-recursor
+%endif
+
+# change user and group to pdns-recursor
+sed -i \
+ -e 's/# setuid=/setuid=pdns-recursor/' \
+ -e 's/# setgid=/setgid=pdns-recursor/' \
+ %{buildroot}%{_sysconfdir}/%{name}/recursor.conf
+
+%pre
+getent group pdns-recursor > /dev/null || groupadd -r pdns-recursor
+getent passwd pdns-recursor > /dev/null || \
+ useradd -r -g pdns-recursor -d / -s /sbin/nologin \
+ -c "PowerDNS Recursor user" pdns-recursor
+exit 0
+
+%post
+%if 0%{?rhel} == 6
+chkconfig --add %{name}
+%else
+%systemd_post %{name}.service
+%endif
+
+%preun
+%if 0%{?rhel} == 6
+if [ $1 -eq 0 ]; then
+ service %{name} stop >/dev/null 2>&1 || :
+ chkconfig --del %{name}
+fi
+%else
+%systemd_preun %{name}.service
+%endif
+
+%if 0%{?rhel} == 6
+%postun
+if [ $1 -ge 1 ]; then
+ service %{name} condrestart >/dev/null 2>&1 || :
+fi
+%else
+%postun
+%systemd_postun_with_restart pdns-recursor.service
+%endif
+
+%files
+%{_bindir}/rec_control
+%{_sbindir}/pdns_recursor
+%{_mandir}/man1/pdns_recursor.1.gz
+%{_mandir}/man1/rec_control.1.gz
+%if 0%{?rhel} == 6
+%{_initrddir}/pdns-recursor
+%else
+%{_unitdir}/pdns-recursor.service
+%{_unitdir}/pdns-recursor@.service
+%endif
+%dir %{_sysconfdir}/%{name}
+%config(noreplace) %{_sysconfdir}/%{name}/recursor.conf
+%doc README