diff --git a/hostname.changes b/hostname.changes index 3e523ff..86ffac1 100644 --- a/hostname.changes +++ b/hostname.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sun Apr 12 14:06:27 UTC 2020 - Neal Gompa + +- Add nis-domainname.service for FreeIPA + ------------------------------------------------------------------- Thu Oct 18 03:10:44 UTC 2018 - sean@suspend.net diff --git a/hostname.spec b/hostname.spec index 5f76d18..7918458 100644 --- a/hostname.spec +++ b/hostname.spec @@ -23,7 +23,11 @@ Summary: Utility to Set/Show the Host Name or Domain Name License: GPL-2.0-or-later Group: Productivity/Networking/Other Url: https://tracker.debian.org/pkg/hostname -Source: http://http.debian.net/debian/pool/main/h/%{name}/%{name}_%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source0: http://http.debian.net/debian/pool/main/h/%{name}/%{name}_%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1: nis-domainname +Source2: nis-domainname.service.in +BuildRequires: gcc +BuildRequires: systemd-rpm-macros # net-tools requires hostname, but we know we do not rely on ourselves to build #!BuildIgnore: hostname @@ -33,6 +37,7 @@ name, and to display or set its hostname or NIS domain name. %prep %setup -q -n %{name} +cp %{SOURCE1} %{SOURCE2} . %build make %{?_smp_mflags} CFLAGS="%{optflags} -D_GNU_SOURCE" @@ -47,6 +52,17 @@ for prog in dnsdomainname domainname ypdomainname nisdomainname; do ln -sf %{_bindir}/%{name} %{buildroot}%{_bindir}/$prog ln -sf hostname.1 %{buildroot}%{_mandir}/man1/${prog}.1 done +sed -e "s|@LIBEXECDIR|%{_libexecdir}|g" nis-domainname.service.in > nis-domainname.service +install -m 0755 -d %{buildroot}%{_libexecdir}/%{name} +install -m 0755 -d %{buildroot}%{_unitdir} +install -p -m 0755 nis-domainname %{buildroot}%{_libexecdir}/%{name} +install -p -m 0644 nis-domainname.service %{buildroot}%{_unitdir} + +%post +%systemd_post nis-domainname.service + +%preun +%systemd_preun nis-domainname.service %files %license COPYRIGHT @@ -66,5 +82,7 @@ done %{_mandir}/man1/dnsdomainname.1%{ext_man} %{_mandir}/man1/nisdomainname.1%{ext_man} %{_mandir}/man1/ypdomainname.1%{ext_man} +%{_unitdir}/nis-domainname.service +%{_libexecdir}/%{name}/ %changelog diff --git a/nis-domainname b/nis-domainname new file mode 100644 index 0000000..0686be0 --- /dev/null +++ b/nis-domainname @@ -0,0 +1,10 @@ +#!/bin/bash + +source /etc/sysconfig/network/config + +if [ -n "${NETCONFIG_NIS_STATIC_DOMAIN}" ] && [ "${NETCONFIG_NIS_SETDOMAINNAME}" = "yes" ] && [ -x /usr/bin/nisdomainname ]; then + nisdomainname ${NETCONFIG_NIS_STATIC_DOMAIN} + exit $? +fi + +exit 0 diff --git a/nis-domainname.service.in b/nis-domainname.service.in new file mode 100644 index 0000000..7e2a76e --- /dev/null +++ b/nis-domainname.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=Read and set NIS domainname from /etc/sysconfig/network/config +Before=ypbind.service yppasswdd.service ypserv.service ypxfrd.service sysinit.target +DefaultDependencies=no +Conflicts=shutdown.target +ConditionPathExists=/etc/sysconfig/network/config + +[Service] +ExecStart=@LIBEXECDIR@/hostname/nis-domainname +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=sysinit.target