1
0
IaC/scripts/arch-install/create-unified-image.sh

42 lines
3.1 KiB
Bash
Raw Normal View History

2024-01-11 06:14:09 -05:00
#! /bin/bash
rm /boot/initramfs-intel-combined.img
rm /boot/initramfs-intel-combined-lts.img
rm /boot/initramfs-intel-combined-zen.img
rm /boot/arch-unified-unsigned.efi
rm /boot/arch-unified-unsigned-lts.efi
rm /boot/arch-unified-unsigned-zen.efi
cat /boot/intel-ucode.img /boot/initramfs-linux.img > /boot/initramfs-intel-combined.img
cat /boot/intel-ucode.img /boot/initramfs-linux-lts.img > /boot/initramfs-intel-combined-lts.img
cat /boot/intel-ucode.img /boot/initramfs-linux-zen.img > /boot/initramfs-intel-combined-zen.img
objcopy \
--add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
--add-section .cmdline="/boot/cmdline" --change-section-vma .cmdline=0x30000 \
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
--add-section .initrd="/boot/initramfs-intel-combined.img" --change-section-vma .initrd=0x3000000 \
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/boot/arch-unified-unsigned.efi"
objcopy \
--add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
--add-section .cmdline="/boot/cmdline" --change-section-vma .cmdline=0x30000 \
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
--add-section .linux="/boot/vmlinuz-linux-lts" --change-section-vma .linux=0x2000000 \
--add-section .initrd="/boot/initramfs-intel-combined-lts.img" --change-section-vma .initrd=0x3000000 \
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/boot/arch-unified-unsigned-lts.efi"
objcopy \
--add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
--add-section .cmdline="/boot/cmdline" --change-section-vma .cmdline=0x30000 \
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
--add-section .linux="/boot/vmlinuz-linux-zen" --change-section-vma .linux=0x2000000 \
--add-section .initrd="/boot/initramfs-intel-combined-zen.img" --change-section-vma .initrd=0x3000000 \
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/boot/arch-unified-unsigned-zen.efi"
mv /efi/arch-unified-signed.efi /efi/arch-unified-signed-last-good-$(date +%Y-%m-%d_%H-%M).efi
mv /efi/arch-unified-signed-lts.efi /efi/arch-unified-signed-last-good-$(date +%Y-%m-%d_%H-%M)-lts.efi
mv /efi/arch-unified-signed-zen.efi /efi/arch-unified-signed-last-good-$(date +%Y-%m-%d_%H-%M)-zen.efi
find /efi/arch-unified-signed*.efi -mtime +7 -exec rm {} \;
#cp /boot/arch-unified-unsigned.efi /efi/arch-unified-signed.efi
#cp /boot/arch-unified-unsigned-lts.efi /efi/arch-unified-signed-lts.efi
#cp /boot/arch-unified-unsigned-zen.efi /efi/arch-unified-signed-zen.efi
sbsign --key /boot/db.key --cert /boot/db.crt --output /efi/arch-unified-signed.efi /boot/arch-unified-unsigned.efi
sbsign --key /boot/db.key --cert /boot/db.crt --output /efi/arch-unified-signed-lts.efi /boot/arch-unified-unsigned-lts.efi
sbsign --key /boot/db.key --cert /boot/db.crt --output /efi/arch-unified-signed-zen.efi /boot/arch-unified-unsigned-zen.efi