Skip to content

Commit c6826c3

Browse files
committed
Implement bootloader-universe script
This script downloads the grub and shim files and places them in the correct locations. It has various TODOs and is incomplete, but helps with providing the structure. Long term this is better to be included in the TFTP module itself and exposed via a REST API call. It accepts a repo URL so it can be easily downloaded from Pulp repositories.
1 parent cbfe296 commit c6826c3

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

extra/bootloader-universe

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
# TODO: read from Smart Proxy config?
6+
TFTPROOT=/var/lib/tftpboot
7+
TFTPROOT=$PWD/tftpboot
8+
9+
os=$1
10+
version=$2
11+
arch=$3
12+
repo=$4
13+
14+
case $arch in
15+
x86_64)
16+
grub_arch=x64
17+
# TODO
18+
esac
19+
20+
grub="grub2-efi-${grub_arch}"
21+
shim="shim-${grub_arch}"
22+
23+
if [[ -z $repo ]] ; then
24+
major=${version%.*}
25+
case $os in
26+
almalinux)
27+
repo=https://repo.almalinux.org/almalinux/${major}/BaseOS/${arch}/os
28+
;;
29+
centos)
30+
repo=https://mirror.stream.centos.org/${major}-stream/BaseOS/${arch}/os
31+
;;
32+
redhat)
33+
echo "Download from https://access.redhat.com/downloads/content/package-browser" 2>&1
34+
exit 1
35+
;;
36+
rocky_linux)
37+
repo=https://dl.rockylinux.org/pub/rocky/${major}/BaseOS/${arch}/os
38+
;;
39+
*)
40+
echo "Unknown OS '${os}'" 2>&1
41+
exit 1
42+
esac
43+
fi
44+
45+
BOOTLOADER_PATH="${TFTPROOT}/bootloader-universe/pxegrub2/${os}/${version}/${arch}"
46+
47+
dir=$(mktemp -d)
48+
trap 'rm -rf "$dir"' EXIT
49+
50+
(
51+
cd "$dir"
52+
53+
dnf --repofrompath "temp-repo,$repo" download --arch "$arch" --from-repo temp-repo "$grub" "$shim"
54+
55+
rpm2cpio "$grub"* | cpio --extract --make-directories --verbose
56+
rpm2cpio "$shim"* | cpio --extract --make-directories --verbose
57+
58+
if [[ $UID == 0 ]] ; then
59+
install -o foreman-proxy -g foreman-proxy -d "${BOOTLOADER_PATH}"
60+
else
61+
install -d "${BOOTLOADER_PATH}"
62+
fi
63+
cp "boot/efi/EFI/${os}/grub${grub_arch}.efi" "${BOOTLOADER_PATH}/grub${grub_arch}.efi"
64+
cp "boot/efi/EFI/${os}/shim${grub_arch}.efi" "${BOOTLOADER_PATH}/shim${grub_arch}.efi"
65+
ln -sr "${BOOTLOADER_PATH}/grub${grub_arch}.efi" "${BOOTLOADER_PATH}/boot.efi"
66+
ln -sr "${BOOTLOADER_PATH}/shim${grub_arch}.efi" "${BOOTLOADER_PATH}/boot-sb.efi"
67+
chmod 0644 "${BOOTLOADER_PATH}/grub${grub_arch}.efi" "${BOOTLOADER_PATH}/shim${grub_arch}.efi"
68+
)

0 commit comments

Comments
 (0)