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) %define releasever %(echo %version | cut -d. -f1-3)
Name: dhcp Name: dhcp
Version: 4.3.1 Version: 4.3.1
Release: 1mamba Release: 2mamba
Summary: The ISC DHCP (Dynamic Host Configuration Protocol) client Summary: The ISC DHCP (Dynamic Host Configuration Protocol) client
Group: System/Servers Group: System/Servers
Vendor: openmamba Vendor: openmamba
@ -11,7 +11,7 @@ Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://www.isc.org/software/dhcp URL: http://www.isc.org/software/dhcp
Source0: ftp://ftp.isc.org/isc/dhcp/%{releasever}/%{name}-%{releasever}.tar.gz 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 #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 Source2: dhcpd-conf
Source3: dhcpd-sysconfig Source3: dhcpd-sysconfig
Source4: dhcp-Makefile.conf Source4: dhcp-Makefile.conf
@ -125,7 +125,7 @@ _EOF
%makeinstall DESTDIR=%{buildroot} %makeinstall DESTDIR=%{buildroot}
install -m0700 client/scripts/linux %{buildroot}/sbin/dhclient-script 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:2} %{buildroot}%{_sysconfdir}/dhcpd.conf
install -D %{S:3} %{buildroot}%{_sysconfdir}/sysconfig/dhcpd install -D %{S:3} %{buildroot}%{_sysconfdir}/sysconfig/dhcpd
install -D %{S:5} %{buildroot}%{_sysconfdir}/dhclient.conf install -D %{S:5} %{buildroot}%{_sysconfdir}/dhclient.conf
@ -138,28 +138,28 @@ touch %{buildroot}%{_localstatedir}/lib/dhcp/dhcpd.leases
%clean %clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" [ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%preun server #%preun server
# erase ## erase
if [ $1 -eq 0 ]; then #if [ $1 -eq 0 ]; then
service dhcpd stop # service dhcpd stop
/sbin/chkconfig --del dhcpd # /sbin/chkconfig --del dhcpd
fi #fi
: #:
%postun server #%postun server
# update ## update
if [ $1 -eq 1 ]; then #if [ $1 -eq 1 ]; then
/sbin/chkconfig dhcpd # /sbin/chkconfig dhcpd
[ $? -eq 0 ] && service dhcpd restart # [ $? -eq 0 ] && service dhcpd restart
fi #fi
: #:
%post client %post client
# Remove "tao" send hostname to fix bug from installations pre <20090705 # 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 \"tao\"/d" %{_sysconfdir}/dhclient.conf
sed -i "/^send host-name \"hetzner\"/d" %{_sysconfdir}/dhclient.conf
grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || { grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || {
echo "send host-name \"`hostname`-${RANDOM_PASSWORD}\";" \ echo "send host-name gethostname();" \
>> %{_sysconfdir}/dhclient.conf >> %{_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}/dhcpd.conf
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd %attr(644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd
%{_sysconfdir}/dhcpd.conf.example %{_sysconfdir}/dhcpd.conf.example
%attr(755,root,root) %{_initrddir}/dhcpd
%{_bindir}/omshell %{_bindir}/omshell
/sbin/dhcpd /sbin/dhcpd
/sbin/dhcrelay /sbin/dhcrelay
%attr(644,root,root) %{_unitdir}/dhcpd@.service
%dir %{_localstatedir}/lib/dhcp %dir %{_localstatedir}/lib/dhcp
%config(noreplace) %{_localstatedir}/lib/dhcp/dhcpd.leases %config(noreplace) %{_localstatedir}/lib/dhcp/dhcpd.leases
%{_mandir}/man1/omshell.* %{_mandir}/man1/omshell.*
%{_mandir}/man5/dhcpd.* %{_mandir}/man5/dhcpd.*
%{_mandir}/man8/dhcpd.* %{_mandir}/man8/dhcpd.*
%{_mandir}/man8/dhcrelay.* %{_mandir}/man8/dhcrelay.*
%doc LICENSE README RELNOTES %doc LICENSE README
%doc doc
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)
@ -206,8 +205,13 @@ grep "^send host-name" %{_sysconfdir}/dhclient.conf >/dev/null || {
%{_libdir}/libdst.a %{_libdir}/libdst.a
%{_libdir}/libomapi.a %{_libdir}/libomapi.a
%{_mandir}/man3/* %{_mandir}/man3/*
%doc RELNOTES doc
%changelog %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 * Tue Aug 12 2014 Automatic Build System <autodist@mambasoft.it> 4.3.1-1mamba
- automatic version update by autodist - 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