Skip to content

Commit 6197630

Browse files
Merge pull request #692 from mumesan/OSPRH-27411
Recursively copy contents from var-lib-ironic in pxe-init.sh <JIRA:OSPRH-27411>
2 parents a34c8bf + 79871e3 commit 6197630

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

templates/common/bin/pxe-init.sh

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
# under the License.
1616
set -ex
1717

18+
# Copy pre-populated boot assets from container image if they exist
19+
if [ -d "/usr/share/ironic-operator/var-lib-ironic" ]; then
20+
cp -a /usr/share/ironic-operator/var-lib-ironic/. /var/lib/ironic/
21+
fi
1822

1923
# Create TFTP, HTTP serving directories
2024
if [ ! -d "/var/lib/ironic/tftpboot/pxelinux.cfg" ]; then
@@ -35,18 +39,27 @@ fi
3539

3640
# Copy iPXE and grub files to tftpboot, httpboot
3741
for dir in httpboot tftpboot; do
38-
cp /usr/share/ipxe/ipxe-snponly-x86_64.efi /var/lib/ironic/$dir/snponly.efi
39-
cp /usr/share/ipxe/undionly.kpxe /var/lib/ironic/$dir/undionly.kpxe
42+
if [ ! -e "/var/lib/ironic/$dir/snponly.efi" ]; then
43+
cp /usr/share/ipxe/ipxe-snponly-x86_64.efi /var/lib/ironic/$dir/snponly.efi
44+
fi
45+
if [ ! -e "/var/lib/ironic/$dir/undionly.kpxe" ]; then
46+
cp /usr/share/ipxe/undionly.kpxe /var/lib/ironic/$dir/undionly.kpxe
47+
fi
4048
# ipxe.lkrn is not packaged in RHEL 10
41-
if [ -f "/usr/share/ipxe/ipxe.lkrn" ]; then
42-
cp /usr/share/ipxe/ipxe.lkrn /var/lib/ironic/$dir/ipxe.lkrn
49+
if [ -f "/usr/share/ipxe/ipxe.lkrn" ] && [ ! -e "/var/lib/ironic/$dir/ipxe.lkrn" ]; then
50+
cp /usr/share/ipxe/ipxe.lkrn /var/lib/ironic/$dir/ipxe.lkrn
51+
fi
52+
if [ ! -e "/var/lib/ironic/$dir/bootx64.efi" ]; then
53+
cp /boot/efi/EFI/$efi_dir/shimx64.efi /var/lib/ironic/$dir/bootx64.efi
54+
fi
55+
if [ ! -e "/var/lib/ironic/$dir/grubx64.efi" ]; then
56+
cp /boot/efi/EFI/$efi_dir/grubx64.efi /var/lib/ironic/$dir/grubx64.efi
4357
fi
44-
cp /boot/efi/EFI/$efi_dir/shimx64.efi /var/lib/ironic/$dir/bootx64.efi
45-
cp /boot/efi/EFI/$efi_dir/grubx64.efi /var/lib/ironic/$dir/grubx64.efi
46-
# Ensure all files are readable
47-
chmod -R +r /var/lib/ironic/$dir
4858
done
4959

60+
# Ensure all boot assets are readable
61+
chmod -R +r /var/lib/ironic/httpboot /var/lib/ironic/tftpboot
62+
5063
# Patch ironic-python-agent with custom CA certificates
5164
if [ -f "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" ] && [ -f "/var/lib/ironic/httpboot/ironic-python-agent.initramfs" ]; then
5265
# Extract the initramfs
@@ -69,16 +82,18 @@ fi
6982

7083
# Build an ESP image
7184
pushd /var/lib/ironic/httpboot
72-
if ! command -v dd || ! command -v mkfs.msdos || ! command -v mmd; then
73-
echo "WARNING: esp.img will not be created because dd/mkfs.msdos/mmd are missing. Please patch the OpenstackVersion to update container images."
74-
elif [ ! -a "esp.img" ]; then
75-
dd if=/dev/zero of=esp.img bs=4096 count=2048
76-
mkfs.msdos -F 12 -n 'ESP_IMAGE' esp.img
85+
if [ ! -a "esp.img" ]; then
86+
if ! command -v dd || ! command -v mkfs.msdos || ! command -v mmd; then
87+
echo "WARNING: esp.img will not be created because dd/mkfs.msdos/mmd are missing. Please patch the OpenstackVersion to update container images."
88+
else
89+
dd if=/dev/zero of=esp.img bs=4096 count=2048
90+
mkfs.msdos -F 12 -n 'ESP_IMAGE' esp.img
7791

78-
mmd -i esp.img EFI
79-
mmd -i esp.img EFI/BOOT
80-
mcopy -i esp.img -v bootx64.efi ::EFI/BOOT
81-
mcopy -i esp.img -v grubx64.efi ::EFI/BOOT
82-
mdir -i esp.img ::EFI/BOOT;
92+
mmd -i esp.img EFI
93+
mmd -i esp.img EFI/BOOT
94+
mcopy -i esp.img -v bootx64.efi ::EFI/BOOT
95+
mcopy -i esp.img -v grubx64.efi ::EFI/BOOT
96+
mdir -i esp.img ::EFI/BOOT;
97+
fi
8398
fi
8499
popd

0 commit comments

Comments
 (0)