|
15 | 15 | # under the License. |
16 | 16 | set -ex |
17 | 17 |
|
| 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 |
18 | 22 |
|
19 | 23 | # Create TFTP, HTTP serving directories |
20 | 24 | if [ ! -d "/var/lib/ironic/tftpboot/pxelinux.cfg" ]; then |
|
35 | 39 |
|
36 | 40 | # Copy iPXE and grub files to tftpboot, httpboot |
37 | 41 | 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 |
40 | 48 | # 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 |
43 | 57 | 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 |
48 | 58 | done |
49 | 59 |
|
| 60 | +# Ensure all boot assets are readable |
| 61 | +chmod -R +r /var/lib/ironic/httpboot /var/lib/ironic/tftpboot |
| 62 | + |
50 | 63 | # Patch ironic-python-agent with custom CA certificates |
51 | 64 | if [ -f "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" ] && [ -f "/var/lib/ironic/httpboot/ironic-python-agent.initramfs" ]; then |
52 | 65 | # Extract the initramfs |
|
69 | 82 |
|
70 | 83 | # Build an ESP image |
71 | 84 | 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 |
77 | 91 |
|
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 |
83 | 98 | fi |
84 | 99 | popd |
0 commit comments