From 6e5beb07b29b14262923cecfed054da0e5f19fc8 Mon Sep 17 00:00:00 2001 From: langfingaz Date: Thu, 13 May 2021 20:39:25 +0200 Subject: [PATCH] install: autodetect BIOS type --- pkg/de-p1st-installer/PKGBUILD | 2 +- pkg/de-p1st-installer/de-p1st-installer.sh | 25 ++++++++++++++++++---- pkg/de-p1st-installer/installer.cfg | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pkg/de-p1st-installer/PKGBUILD b/pkg/de-p1st-installer/PKGBUILD index 61044b4..7eed206 100644 --- a/pkg/de-p1st-installer/PKGBUILD +++ b/pkg/de-p1st-installer/PKGBUILD @@ -2,7 +2,7 @@ _pkgname=installer _reponame=arch pkgname="de-p1st-$_pkgname" -pkgver=0.1.2 +pkgver=0.1.3 pkgrel=1 pkgdesc="Bash script to install Arch Linux" arch=('any') diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index 0332f0a..060a030 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -11,7 +11,7 @@ source /usr/lib/de-p1st-installer/block-device.sh || { exit 1; } function check_network() { echo "Sending ping to wikipedia.de ..." - ping -c 1 wikipedia.de || { + ping -c 1 wikipedia.de >/dev/null || { echo "Pleas set up network access." return 1 } @@ -22,7 +22,7 @@ function increase_cow_space() { # Usually not necessary! # make sure that we are on a live medium: - findmnt /run/archiso/cowspace || { + findmnt /run/archiso/cowspace >/dev/null || { echo "Not on live medium, did not increase cowspace!" return 1 } @@ -42,8 +42,25 @@ function get_user_input() { get_block_devices_with_size || return $? get_single_choice TARGET_BLOCK_DEVICE "Select target device for installation" BLOCK_DEVICE_SIZES || return $? - TMP1=('uefi' 'Newer mainboards' 'bios' 'Legacy BIOS on older mainboards') - get_single_choice BIOS_TYPE "Select your bios type" TMP1 || return $? + if [ "${BIOS_TYPE}" = "autodetect" ]; then + # Detect BIOS type: https://askubuntu.com/a/162573 + + # Check exit code; if 0 EFI, else BIOS. + # "-q": tell grep to output nothing + if dmesg | grep -q "EFI v"; then + echo "Detected EFI boot." + BIOS_TYPE="uefi" + else + echo "Detected BIOS boot" + BIOS_TYPE="bios" + fi + + else + # Let user select BIOS type + + TMP1=('uefi' 'Newer mainboards' 'bios' 'Legacy BIOS on older mainboards') + get_single_choice BIOS_TYPE "Select your bios type" TMP1 || return $? + fi TMP1=('BTRFS' 'Allows snapshots and dynamic extension of the FS' 'EXT4' 'Default FS of many distributions' 'F2FS' 'Flash-Friendly-FS for SSD or NVMe') get_single_choice FS "Select filesystem to use" TMP1 || return $? diff --git a/pkg/de-p1st-installer/installer.cfg b/pkg/de-p1st-installer/installer.cfg index 5c67d44..35f0ff2 100644 --- a/pkg/de-p1st-installer/installer.cfg +++ b/pkg/de-p1st-installer/installer.cfg @@ -21,6 +21,7 @@ FS_CHOSEN_MOUNT_OPTIONS=('noatime') # If not booted into the target system, these values should be set: # CPU_VENDOR: "autodetect", "amd", "intel" or "none" CPU_VENDOR=autodetect +# BIOS_TYPE: "autodetect", "uefi" or "bios" BIOS_TYPE=uefi # If set to "1", then the data, boot and luks partitions