summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-03-08 14:12:51 +0100
committerSimon Rettberg2023-03-08 14:12:51 +0100
commit522c23ccb6cb36e045446f27bc2734e29ba33946 (patch)
tree618362d848c5e31aa9dc0f784bc9d50edada213f
parent[SSPS] Little improvement for config-backup script (diff)
downloadsetup-scripts-522c23ccb6cb36e045446f27bc2734e29ba33946.tar.gz
setup-scripts-522c23ccb6cb36e045446f27bc2734e29ba33946.tar.xz
setup-scripts-522c23ccb6cb36e045446f27bc2734e29ba33946.zip
[GRUB] Add localboot grub builder
-rw-r--r--grub_localboot/.gitignore1
-rw-r--r--grub_localboot/boot.cfg39
-rwxr-xr-xgrub_localboot/make.sh4
3 files changed, 44 insertions, 0 deletions
diff --git a/grub_localboot/.gitignore b/grub_localboot/.gitignore
new file mode 100644
index 0000000..ada5e8e
--- /dev/null
+++ b/grub_localboot/.gitignore
@@ -0,0 +1 @@
+grub-boot.img
diff --git a/grub_localboot/boot.cfg b/grub_localboot/boot.cfg
new file mode 100644
index 0000000..f26b137
--- /dev/null
+++ b/grub_localboot/boot.cfg
@@ -0,0 +1,39 @@
+insmod part_gpt
+insmod fat
+insmod chain
+#insmod part_msdos
+#insmod ext2
+
+echo
+echo "Scanning, first pass..."
+list_env
+echo "eins: '${1}' oder '$1'"
+set
+sleep 10
+#for efi in (*,gpt*)/efi/*/grub.cfg (*,gpt*)/efi/*/*/grub.cfg (*,gpt*)/grub.cfg (*,gpt*)/*/grub.cfg (*,gpt*)/efi/grub/grubx64.efi (*,gpt*)/efi/boot/bootx64.efi (*,gpt*)/efi/*/*/bootmgfw.efi (*,gpt*)/efi/*/*.efi ; do
+for efi in (*,gpt*)/efi/grub/grubx64.efi (*,gpt*)/efi/boot/bootx64.efi (*,gpt*)/efi/*/*/bootmgfw.efi (*,gpt*)/efi/*/*.efi \
+ (*,msdos*)/efi/grub/grubx64.efi (*,msdos*)/efi/boot/bootx64.efi (*,msdos*)/efi/*/*/bootmgfw.efi (*,msdos*)/efi/*/*.efi; do
+ regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
+done
+
+echo "Scanning, second pass..."
+for efi in (*,gpt*)/efi/grub/grubx64.efi (*,gpt*)/efi/boot/bootx64.efi (*,gpt*)/efi/*/*/bootmgfw.efi (*,gpt*)/efi/*/*.efi \
+ (*,msdos*)/efi/grub/grubx64.efi (*,msdos*)/efi/boot/bootx64.efi (*,msdos*)/efi/*/*/bootmgfw.efi (*,msdos*)/efi/*/*.efi; do
+ if [ -e "${efi}" ]; then
+ #regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
+ regexp --set=1:root '^(\(.*\))/' "${efi}"
+ regexp --set=1:efi_path '^\(.*\)(/.*)$' "${efi}"
+ echo " >> Found operating system! <<"
+ echo " Path: '${efi}' on '${root}'"
+ echo " Fallback '${efi_path}'"
+ echo " Booting in 5s..."
+ sleep --interruptible --verbose 5
+ chainloader "${efi}"
+ boot
+ echo " That failed..."
+ fi
+done
+
+echo "No EFI known OS found. Reboot."
+sleep --interruptible --verbose 15
+reboot
diff --git a/grub_localboot/make.sh b/grub_localboot/make.sh
new file mode 100755
index 0000000..d48a593
--- /dev/null
+++ b/grub_localboot/make.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# apt install --no-install-recommends grub-efi-amd64-bin
+grub-mkstandalone -O x86_64-efi -o grub-boot.img "boot/grub/grub.cfg=boot.cfg"