File pxeconf.spec of Package pxeconf

#
# spec file for package BBpxeconf
#
# Copyright (c) 2026 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

Name:			pxeconf
Version:		1.0.0
Release:		0
Group:			Productivity/Networking/Boot/Utilities
Summary:		Arquivos para instalação via PXE
License:		SUSE-NonFree
URL:			https://build.opensuse.org/package/show/home:PerryWerneck/pxeconf-tw

Source10:		grub.cfg
Source11:		apache.conf
Source12:		permissions

Source100:		bootx64.efi

BuildRequires:	fdupes
BuildRequires:	tftp
BuildRequires:	dos2unix
BuildRequires:	mkdud
BuildRequires:	shim

BuildRequires:	grub2-x86_64-efi

Provides:		nwipe.dud

PreReq:			permissions

Requires:		tftp(server)
Requires:		grub2-x86_64-efi
Requires:		shim

Requires(post):	apache2
Requires(post):	firewalld

Requires(pre):	user(tftp)
Requires(pre):	group(tftp)
Requires(pre):	group(www)
Requires(pre):	group(wwwrun)

%description
PXE server configuration

%prep

%build

%verifyscript
%verify_permissions -e /srv/tftpboot

%install

mkdir -p %{buildroot}%{_sysconfdir}/permissions.d
install -m 0644 %{SOURCE12} %{buildroot}%{_sysconfdir}/permissions.d/pxe

mkdir -p %{buildroot}/etc/apache2/conf.d
install --mode=644 %{SOURCE11} %{buildroot}/etc/apache2/conf.d/pxe.conf

mkdir -p %{buildroot}/srv/tftpboot/EFI/BOOT/
install -m 0644 %{SOURCE10} %{buildroot}/srv/tftpboot/EFI/BOOT/grub.cfg
install -m 0644 %{SOURCE100} %{buildroot}/srv/tftpboot/EFI/BOOT

mkdir -p %{buildroot}/srv/tftpboot/EFI/BOOT/x86_64-efi
for SRC in $(find /usr/share/efi/x86_64 -maxdepth 1 -type f | grep -v index.txt)
do
	FILENAME=$(basename ${SRC})
	install --mode=644 $(readlink -f ${SRC}) %{buildroot}/srv/tftpboot/EFI/BOOT/x86_64-efi/${FILENAME}
done

for SRC in grub.efi shim.efi
do
	install \
		--mode=644 \
		$(readlink -f /usr/share/efi/x86_64/${SRC}) \
		%{buildroot}/srv/tftpboot/EFI/BOOT/x86_64-efi/$(SRC)
done

find %{buildroot} -type d -exec chmod 755 {} \;
find %{buildroot} -type f -exec chmod 644 {} \;

# Build indexes
for path in %{buildroot}/srv/tftpboot/EFI/BOOT %{buildroot}/srv/tftpboot/EFI/BOOT/x86_64-efi
do
	TEMPFILE=$(mktemp)
	find ${path} -maxdepth 1 -type f -exec basename {} \; | grep -v index.txt >> ${TEMPFILE}
	install --mode=644 ${TEMPFILE} ${path}/index.txt
done

%fdupes %{buildroot}/srv

%pre

%posttrans
systemctl enable tftp.socket
systemctl enable apache2

if [ ! -d /.build ]; then

	echo "Ativando apache2"
	/usr/bin/firewall-cmd --permanent --zone=public --add-service=apache2
	systemctl restart apache2
    
	echo "Ativando tftp"
	/usr/bin/firewall-cmd --permanent --zone=public --add-service=tftp
	systemctl restart tftp.socket

fi

%post
%set_permissions /srv/tftpboot/

a2enmod expires 2>&1 > /dev/null
a2enmod deflate 2>&1 > /dev/null
a2enmod filter 2>&1 > /dev/null
a2enmod cache 2>&1 > /dev/null
a2enmod headers 2>&1 > /dev/null
a2enmod proxy 2>&1 > /dev/null
a2enmod proxy_http 2>&1 > /dev/null
a2enmod mod_cache 2>&1 > /dev/null
a2enmod mod_disk_cache 2>&1 > /dev/null
a2enmod mod_mem_cache 2>&1 > /dev/null
a2enmod mod_rewrite 2>&1 > /dev/null

%restart_on_update apache2

%postun
%restart_on_update apache2

%files
%defattr(-,root,root)
%dir %attr (0755,tftp,tftp) /srv/tftpboot
%dir %attr (0755,tftp,tftp) /srv/tftpboot/EFI
%dir %attr (0755,tftp,tftp) /srv/tftpboot/EFI/BOOT
%dir %attr (0755,tftp,tftp) /srv/tftpboot/EFI/BOOT/x86_64-efi

#/srv/tftpboot/EFI/BOOT/*

%config(noreplace) /srv/tftpboot/EFI/BOOT/*.cfg

%dir /etc/apache2
%dir /etc/apache2/conf.d
%config /etc/apache2/conf.d/pxe.conf
%config %{_sysconfdir}/permissions.d/pxe

%changelog
 

openSUSE Build Service is sponsored by