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