]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
grub: Add file with cloud helping stuff
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jul 2021 10:07:08 +0000 (10:07 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 1 Aug 2021 13:24:22 +0000 (13:24 +0000)
This file will detect whether to do certain actions depending on the
environment it is running on.

Currently this detects whether IPFire is booting up on AWS EC2 and
selects the serial console boot entry.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
config/grub2/00_cloud [new file with mode: 0644]
config/rootfiles/common/aarch64/grub
config/rootfiles/common/i586/grub
config/rootfiles/common/x86_64/grub
lfs/grub

diff --git a/config/grub2/00_cloud b/config/grub2/00_cloud
new file mode 100644 (file)
index 0000000..3f9c5a1
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+# This is an IPFire helper script for GRUB to enable the serial console
+# on AWS instances at the time of the first boost
+
+set -e
+
+# Do nothing if first boot isn't enabled
+if [ "${GRUB_FIRST_BOOT}" != "true" ]; then
+       exit 0
+fi
+
+. "${pkgdatadir}/grub-mkconfig_lib"
+
+if [ -z "${boot_device_id}" ]; then
+       boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
+fi
+
+cat <<EOF
+# Read the system manufacturer string from the BIOS
+smbios --type 1 --get-string 4 --set system_manufacturer
+
+# Are we on Amazon EC2?
+if [ "\$system_manufacturer" = "Amazon EC2" ]; then
+       next_entry=gnulinux-serial-${boot_device_id}
+fi
+EOF
index 2c89512497cc2143b5badb107a8e46808727fa39..ae6bdfec30809d27e81b08a0063b17e8a68d4a38 100644 (file)
@@ -4,6 +4,7 @@ boot/grub/splash.png
 #etc/bash_completion.d/grub
 etc/default/grub
 #etc/grub.d
+etc/grub.d/00_cloud
 etc/grub.d/00_header
 etc/grub.d/10_linux
 etc/grub.d/20_linux_xen
index 72884a2343c27b4f02574660c46c3386f4b3693a..74e6461500a9c7a11231f56ef685058e1d11baaa 100644 (file)
@@ -5,6 +5,7 @@ boot/grub/splash.png
 #etc/bash_completion.d/grub
 etc/default/grub
 #etc/grub.d
+etc/grub.d/00_cloud
 etc/grub.d/00_header
 etc/grub.d/10_linux
 etc/grub.d/20_linux_xen
index 8cddfcff935b361bd53a5c8bd19516265643b439..5450499e364d58f41b57c53e0d1a9ca19c859fbb 100644 (file)
@@ -5,6 +5,7 @@ boot/grub/splash.png
 #etc/bash_completion.d/grub
 etc/default/grub
 #etc/grub.d
+etc/grub.d/00_cloud
 etc/grub.d/00_header
 etc/grub.d/10_linux
 etc/grub.d/20_linux_xen
index cc1581306fec171dfaecac54a6bcb0e3e9b10889..aed9e6ad8eba1fd0d2b14b4c550fe898e139b920 100644 (file)
--- a/lfs/grub
+++ b/lfs/grub
@@ -125,6 +125,10 @@ ifeq "$(BUILD_PC)" "1"
        touch /boot/grub/grub.cfg
 endif
 
+       # Install our own helpers
+       install -v -m 644 $(DIR_SRC)/config/grub2/00_cloud \
+               /etc/grub.cfg
+
        # Install background image
        -mkdir -pv /boot/grub
        install -m 644 $(DIR_SRC)/config/grub2/splash.png /boot/grub/splash.png