%global dhcpconfdir %{_sysconfdir}/dhcp Name: dhcp-isc-stable Version: 4.4.1 Release: 1%{?dist} Summary: Vanila version of stable dhcp server License: MIT URL: http://isc.org/products/DHCP/ Source0: ftp://ftp.isc.org/isc/dhcp/%{version}/dhcp-%{version}.tar.gz Source1: dhclient-script Source2: README.dhclient.d Source3: 11-dhclient Source4: 12-dhcpd Source5: 56dhclient Source6: dhcpd.service Source7: dhcpd6.service Source8: dhcrelay.service Conflicts: dhcp Conflicts: bind99-license Conflicts: bind-export-libs Provides: dhcp BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool BuildRequires: openldap-devel # --with-ldap-gssapi BuildRequires: krb5-devel BuildRequires: libcap-ng-devel BuildRequires: systemd systemd-devel %description DHCP (Dynamic Host Configuration Protocol) without downstream patches %package server Summary: Provides the ISC DHCP server Requires: %{name}-common = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires(pre): shadow-utils Requires(post): coreutils grep sed Requires(post): systemd Requires(preun): systemd Requires(postun): systemd Conflicts: dhcp-server Provides: dhcp-server %description server DHCP (Dynamic Host Configuration Protocol) is a protocol which allows individual devices on an IP network to get their own network configuration information (IP address, subnetmask, broadcast address, etc.) from a DHCP server. The overall purpose of DHCP is to make it easier to administer a large network. This package provides the ISC DHCP server. %package relay Summary: Provides the ISC DHCP relay agent Requires: %{name}-common = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires(post): grep sed Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %description relay DHCP (Dynamic Host Configuration Protocol) is a protocol which allows individual devices on an IP network to get their own network configuration information (IP address, subnetmask, broadcast address, etc.) from a DHCP server. The overall purpose of DHCP is to make it easier to administer a large network. This package provides the ISC DHCP relay agent. %package compat Summary: Utility package to help transition Provides: dhcp = %{version}-%{release} Obsoletes: dhcp < %{version}-%{release} Requires: %{name}-server = %{version}-%{release} Requires: %{name}-relay = %{version}-%{release} %description compat This package only exists to help transition dhcp users to the new package split (dhcp -> dhcp & dhcrelay). It will be removed after one distribution release cycle, please do not reference it or depend on it in any way. %package client Summary: Provides the ISC DHCP client daemon and dhclient-script Provides: dhclient = %{version}-%{release} Obsoletes: dhclient < %{version}-%{release} # dhclient-script requires: Requires: coreutils gawk grep ipcalc iproute iputils sed systemd Requires: %{name}-common = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release} Conflicts: dhcp-client Conflicts: dhclient %description client DHCP (Dynamic Host Configuration Protocol) is a protocol which allows individual devices on an IP network to get their own network configuration information (IP address, subnetmask, broadcast address, etc.) from a DHCP server. The overall purpose of DHCP is to make it easier to administer a large network. This package provides the ISC DHCP client. %package common Summary: Common files used by ISC dhcp client, server and relay agent BuildArch: noarch Conflicts: dhcp-common Provides: dhcp-common %description common DHCP (Dynamic Host Configuration Protocol) is a protocol which allows individual devices on an IP network to get their own network configuration information (IP address, subnetmask, broadcast address, etc.) from a DHCP server. The overall purpose of DHCP is to make it easier to administer a large network. This package provides common files used by dhcp and dhclient package. %package libs Summary: Shared libraries used by ISC dhcp client and server Conflicts: dhcp-libs Provides: dhcp-libs %description libs This package contains shared libraries used by ISC dhcp client and server %package devel Summary: Development headers and libraries for interfacing to the DHCP server Requires: %{name}-libs%{?_isa} = %{version}-%{release} %description devel Header files and API documentation for using the ISC DHCP libraries. The libdhcpctl and libomapi static libraries are also included in this package. %if ! 0%{?_module_build} %package devel-doc Summary: Developer's Guide for ISC DHCP Requires: %{name}-libs = %{version}-%{release} BuildArch: noarch %description devel-doc This documentation is intended for developers, contributors and other programmers that are interested in internal operation of the code. This package contains doxygen-generated documentation. %endif %prep %setup -q -n dhcp-%{version} %build %configure make -j1 %install make DESTDIR=%{buildroot} install -j1 # dhclient-script install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_sbindir}/dhclient-script # README.dhclient.d install -p -m 0644 %{SOURCE2} . # Empty directory for dhclient.d scripts mkdir -p %{buildroot}%{dhcpconfdir}/dhclient.d # systemd unit files mkdir -p %{buildroot}%{_unitdir} install -m 644 %{SOURCE6} %{buildroot}%{_unitdir} install -m 644 %{SOURCE7} %{buildroot}%{_unitdir} install -m 644 %{SOURCE8} %{buildroot}%{_unitdir} # Start empty lease databases mkdir -p %{buildroot}%{_localstatedir}/lib/dhcpd/ touch %{buildroot}%{_localstatedir}/lib/dhcpd/dhcpd.leases touch %{buildroot}%{_localstatedir}/lib/dhcpd/dhcpd6.leases mkdir -p %{buildroot}%{_localstatedir}/lib/dhclient/ # default sysconfig file for dhcpd mkdir -p %{buildroot}%{_sysconfdir}/sysconfig cat < %{buildroot}%{_sysconfdir}/sysconfig/dhcpd # WARNING: This file is NOT used anymore. # If you are here to restrict what interfaces should dhcpd listen on, # be aware that dhcpd listens *only* on interfaces for which it finds subnet # declaration in dhcpd.conf. It means that explicitly enumerating interfaces # also on command line should not be required in most cases. # If you still insist on adding some command line options, # copy dhcpd.service from /lib/systemd/system to /etc/systemd/system and modify # it there. # https://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F # example: # $ cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/ # $ vi /etc/systemd/system/dhcpd.service # $ ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid # $ systemctl --system daemon-reload # $ systemctl restart dhcpd.service EOF cat << EOF > client/dhclient-enter-hooks #!/bin/bash # For dhclient/dhclient-script debugging. # Copy this into /etc/dhcp/ and make it executable. # Run 'dhclient -d ' to see info passed from dhclient to dhclient-script. # See also HOOKS section in dhclient-script(8) man page. echo "interface: ${interface}" echo "reason: ${reason}" ( set -o posix ; set ) | grep "old_" ( set -o posix ; set ) | grep "new_" ( set -o posix ; set ) | grep "alias_" ( set -o posix ; set ) | grep "requested_" EOF # Install default (empty) dhcpd.conf: mkdir -p %{buildroot}%{dhcpconfdir} cat << EOF > %{buildroot}%{dhcpconfdir}/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp-server/dhcpd.conf.example # see dhcpd.conf(5) man page # EOF # Install default (empty) dhcpd6.conf: cat << EOF > %{buildroot}%{dhcpconfdir}/dhcpd6.conf # # DHCPv6 Server Configuration file. # see /usr/share/doc/dhcp-server/dhcpd6.conf.example # see dhcpd.conf(5) man page # EOF rm -f %{buildroot}/%{_sysconfdir}/*example %pre server # /usr/share/doc/setup/uidgid %global gid_uid 177 getent group dhcpd >/dev/null || groupadd --force --gid %{gid_uid} --system dhcpd if ! getent passwd dhcpd >/dev/null ; then if ! getent passwd %{gid_uid} >/dev/null ; then useradd --system --uid %{gid_uid} --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd else useradd --system --gid dhcpd --home / --shell /sbin/nologin --comment "DHCP server" dhcpd fi fi exit 0 %post server # Initial installation %systemd_post dhcpd.service dhcpd6.service for servicename in dhcpd dhcpd6; do etcservicefile=%{_sysconfdir}/systemd/system/${servicename}.service if [ -f ${etcservicefile} ]; then grep -q Type= ${etcservicefile} || sed -i '/\[Service\]/a Type=notify' ${etcservicefile} sed -i 's/After=network.target/Wants=network-online.target\nAfter=network-online.target/' ${etcservicefile} fi done exit 0 %post relay # Initial installation %systemd_post dhcrelay.service for servicename in dhcrelay; do etcservicefile=%{_sysconfdir}/systemd/system/${servicename}.service if [ -f ${etcservicefile} ]; then grep -q Type= ${etcservicefile} || sed -i '/\[Service\]/a Type=notify' ${etcservicefile} sed -i 's/After=network.target/Wants=network-online.target\nAfter=network-online.target/' ${etcservicefile} fi done exit 0 %preun server # Package removal, not upgrade %systemd_preun dhcpd.service dhcpd6.service %preun relay # Package removal, not upgrade %systemd_preun dhcrelay.service %postun server # Package upgrade, not uninstall %systemd_postun_with_restart dhcpd.service dhcpd6.service %postun relay # Package upgrade, not uninstall %systemd_postun_with_restart dhcrelay.service %ldconfig_scriptlets libs %triggerun -- dhcp # convert DHC*ARGS from /etc/sysconfig/dhc* to /etc/systemd/system/dhc*.service for servicename in dhcpd dhcpd6 dhcrelay; do if [ -f %{_sysconfdir}/sysconfig/${servicename} ]; then # get DHCPDARGS/DHCRELAYARGS value from /etc/sysconfig/${servicename} source %{_sysconfdir}/sysconfig/${servicename} if [ "${servicename}" == "dhcrelay" ]; then args=$DHCRELAYARGS else args=$DHCPDARGS fi # value is non-empty (i.e. user modified) and there isn't a service unit yet if [ -n "${args}" -a ! -f %{_sysconfdir}/systemd/system/${servicename}.service ]; then # in $args replace / with \/ otherwise the next sed won't take it args=$(echo $args | sed 's/\//\\\//'g) # add $args to the end of ExecStart line sed -r -e "/ExecStart=/ s/$/ ${args}/" \ < %{_unitdir}/${servicename}.service \ > %{_sysconfdir}/systemd/system/${servicename}.service fi fi done %files server %doc contrib/ldap/ contrib/dhcp-lease-list.pl %attr(0750,root,root) %dir %{dhcpconfdir} %attr(0755,dhcpd,dhcpd) %dir %{_localstatedir}/lib/dhcpd %attr(0644,dhcpd,dhcpd) %verify(mode) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd.leases %attr(0644,dhcpd,dhcpd) %verify(mode) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd6.leases %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd %config(noreplace) %{dhcpconfdir}/dhcpd.conf %config(noreplace) %{dhcpconfdir}/dhcpd6.conf %attr(0644,root,root) %{_unitdir}/dhcpd.service %attr(0644,root,root) %{_unitdir}/dhcpd6.service %{_sbindir}/dhcpd %{_bindir}/omshell %attr(0644,root,root) %{_mandir}/man1/omshell.1.gz %attr(0644,root,root) %{_mandir}/man5/dhcpd.conf.5.gz %attr(0644,root,root) %{_mandir}/man5/dhcpd.leases.5.gz %attr(0644,root,root) %{_mandir}/man8/dhcpd.8.gz %files relay %{_sbindir}/dhcrelay %attr(0644,root,root) %{_unitdir}/dhcrelay.service %attr(0644,root,root) %{_mandir}/man8/dhcrelay.8.gz %files compat %files client %doc README.dhclient.d %attr(0750,root,root) %dir %{dhcpconfdir} %dir %{dhcpconfdir}/dhclient.d %dir %{_localstatedir}/lib/dhclient %{_sbindir}/dhclient %{_sbindir}/dhclient-script %attr(0644,root,root) %{_mandir}/man5/dhclient.conf.5.gz %attr(0644,root,root) %{_mandir}/man5/dhclient.leases.5.gz %attr(0644,root,root) %{_mandir}/man8/dhclient.8.gz %attr(0644,root,root) %{_mandir}/man8/dhclient-script.8.gz %files common %{!?_licensedir:%global license %%doc} %{license} LICENSE %doc README RELNOTES doc/References.txt %attr(0644,root,root) %{_mandir}/man5/dhcp-options.5.gz %attr(0644,root,root) %{_mandir}/man5/dhcp-eval.5.gz %files libs %{_libdir}/libdhcpctl.a %{_libdir}/libomapi.a %{_libdir}/libdhcp.a %files devel %doc doc/IANA-arp-parameters doc/api+protocol %{_includedir}/dhcpctl %{_includedir}/omapip %attr(0644,root,root) %{_mandir}/man3/dhcpctl.3.gz %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %changelog * Wed Mar 14 2018 Pavel Zhukov - 4.4.1-1 - Initial commit