From 5686855e5287dc7985cb12d3cad0b4400a5d9d24 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 21:45:41 +0100 Subject: [PATCH] dhclient.conf: use gethostname() as default send hostname server: remove initscript; add systemd service file [release 4.3.1-2mamba;Tue Dec 23 2014] --- dhcp.spec | 48 +++++++++++++++++++++++++---------------------- dhcpd-initscript | 49 ------------------------------------------------ dhcpd@.service | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 71 deletions(-) delete mode 100644 dhcpd-initscript create mode 100644 dhcpd@.service diff --git a/dhcp.spec b/dhcp.spec index 5e16267..9c2b7b4 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -2,7 +2,7 @@ %define releasever %(echo %version | cut -d. -f1-3) Name: dhcp Version: 4.3.1 -Release: 1mamba +Release: 2mamba Summary: The ISC DHCP (Dynamic Host Configuration Protocol) client Group: System/Servers Vendor: openmamba @@ -11,7 +11,7 @@ Packager: Silvan Calarco URL: http://www.isc.org/software/dhcp Source0: ftp://ftp.isc.org/isc/dhcp/%{releasever}/%{name}-%{releasever}.tar.gz #Source0: ftp://ftp.freenet.de/pub/ftp.isc.org/isc/dhcp/%{name}-%{releasever}%{?patchver:-%patchver}.tar.gz -Source1: dhcpd-initscript +Source1: dhcpd@.service Source2: dhcpd-conf Source3: dhcpd-sysconfig Source4: dhcp-Makefile.conf @@ -125,7 +125,7 @@ _EOF %makeinstall DESTDIR=%{buildroot} install -m0700 client/scripts/linux %{buildroot}/sbin/dhclient-script -install -D %{S:1} %{buildroot}%{_initrddir}/dhcpd +install -D %{S:1} %{buildroot}%{_unitdir}/dhcpd@.service install -D %{S:2} %{buildroot}%{_sysconfdir}/dhcpd.conf install -D %{S:3} %{buildroot}%{_sysconfdir}/sysconfig/dhcpd install -D %{S:5} %{buildroot}%{_sysconfdir}/dhclient.conf @@ -138,28 +138,28 @@ touch %{buildroot}%{_localstatedir}/lib/dhcp/dhcpd.leases %clean [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" -%preun server -# erase -if [ $1 -eq 0 ]; then - service dhcpd stop - /sbin/chkconfig --del dhcpd -fi -: +#%preun server +## erase +#if [ $1 -eq 0 ]; then +# service dhcpd stop +# /sbin/chkconfig --del dhcpd +#fi +#: -%postun server -# update -if [ $1 -eq 1 ]; then - /sbin/chkconfig dhcpd - [ $? -eq 0 ] && service dhcpd restart -fi -: +#%postun server +## update +#if [ $1 -eq 1 ]; then +# /sbin/chkconfig dhcpd +# [ $? -eq 0 ] && service dhcpd restart +#fi +#: %post client # Remove "tao" send hostname to fix bug from installations pre <20090705 -RANDOM_PASSWORD=`dd if=/dev/urandom count=128 bs=1 2>&1 | md5sum | cut -b-8` sed -i "/^send host-name \"tao\"/d" %{_sysconfdir}/dhclient.conf +sed -i "/^send host-name \"hetzner\"/d" %{_sysconfdir}/dhclient.conf grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || { - echo "send host-name \"`hostname`-${RANDOM_PASSWORD}\";" \ + echo "send host-name gethostname();" \ >> %{_sysconfdir}/dhclient.conf } : @@ -181,18 +181,17 @@ grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || { %attr(644,root,root) %config(noreplace) %{_sysconfdir}/dhcpd.conf %attr(644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd %{_sysconfdir}/dhcpd.conf.example -%attr(755,root,root) %{_initrddir}/dhcpd %{_bindir}/omshell /sbin/dhcpd /sbin/dhcrelay +%attr(644,root,root) %{_unitdir}/dhcpd@.service %dir %{_localstatedir}/lib/dhcp %config(noreplace) %{_localstatedir}/lib/dhcp/dhcpd.leases %{_mandir}/man1/omshell.* %{_mandir}/man5/dhcpd.* %{_mandir}/man8/dhcpd.* %{_mandir}/man8/dhcrelay.* -%doc LICENSE README RELNOTES -%doc doc +%doc LICENSE README %files devel %defattr(-,root,root) @@ -206,8 +205,13 @@ grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || { %{_libdir}/libdst.a %{_libdir}/libomapi.a %{_mandir}/man3/* +%doc RELNOTES doc %changelog +* Tue Dec 23 2014 Silvan Calarco 4.3.1-2mamba +- dhclient.conf: use gethostname() as default send hostname +- server: remove initscript; add systemd service file + * Tue Aug 12 2014 Automatic Build System 4.3.1-1mamba - automatic version update by autodist diff --git a/dhcpd-initscript b/dhcpd-initscript deleted file mode 100644 index c77ef4a..0000000 --- a/dhcpd-initscript +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Begin $rc_base/init.d/dhcp - -# Based on sysklogd script from LFS-3.1 and earlier. -# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org -# Modified by Silvan Calarco -# Modified by Davide Madrisan -# -# chkconfig: 345 55 15 -# description: The ISC DHCP (Dynamic Host Configuration Protocol) client - -. /etc/sysconfig/rc -. $rc_functions -. $rc_networkfunctions -. /etc/sysconfig/dhcpd -. /etc/sysconfig/network - -case "$1" in - start) - echo -n "Starting DHCP Server..." - for interface in $DHCPDIFS; do - loadproc dhcpd -q $interface $DHCPDARGS - done - echo - ;; - - stop) - echo -n "Stopping DHCP Server..." - killproc dhcpd - echo - ;; - - restart) - $0 stop - sleep 1 - $0 start - ;; - - status) - statusproc dhcpd - ;; - - *) - echo "Usage: $0 {start|stop|restart|status}" - exit 1 - ;; -esac - -# End $rc_base/init.d/dhcp diff --git a/dhcpd@.service b/dhcpd@.service new file mode 100644 index 0000000..2fc523d --- /dev/null +++ b/dhcpd@.service @@ -0,0 +1,14 @@ +[Unit] +Description=DHCP server on %I +Wants=network.target +After=network.target + +[Service] +EnvironmentFile=-/etc/sysconfig/dhcpd +Type=forking +PIDFile=/run/dhcpd.pid +ExecStart=/sbin/dhcpd -q -pf /run/dhcpd4.pid %I $DHCPDARGS +KillSignal=SIGINT + +[Install] +WantedBy=multi-user.target