dhclient.conf: use gethostname() as default send hostname

server: remove initscript; add systemd service file [release 4.3.1-2mamba;Tue Dec 23 2014]
This commit is contained in:
Silvan Calarco 2024-01-05 21:45:41 +01:00
parent c2a266c5c4
commit 5686855e52
3 changed files with 40 additions and 71 deletions

View File

@ -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 <silvan.calarco@mambasoft.it>
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 <silvan.calarco@mambasoft.it> 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 <autodist@mambasoft.it> 4.3.1-1mamba
- automatic version update by autodist

View File

@ -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 <silvan.calarco@mambasoft.it>
# Modified by Davide Madrisan <davide.madrisan@qilinux.it>
#
# 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

14
dhcpd@.service Normal file
View File

@ -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