diff --git a/install-stormux.sh b/install-stormux.sh index bd59d17..c8d6add 100755 --- a/install-stormux.sh +++ b/install-stormux.sh @@ -27,7 +27,7 @@ trap cleanup EXIT # make sure the script cleans up after itself before closing. cleanup() { if [[ $mounted -eq 0 ]]; then - umount -R /mnt + umount -R /mnt || echo "Warning: Failed to unmount /mnt" fi exit 0 } @@ -58,13 +58,13 @@ menulist() { # returns: selected tag local instructions="${1}" shift - dialog --title "$(gettext "Stormux X86_64 Installer")" \ - --backtitle "$(gettext "Use the up and down arrow keys to find the option you want, then press enter to select it.")" \ + dialog --title "Stormux X86_64 Installer" \ + --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \ --clear \ - --cancel-label "$(gettext "Exit")" \ - --ok-label "$(gettext "Continue")" \ + --cancel-label "Exit" \ + --ok-label "Continue" \ --no-tags \ - --menu "$(gettext "${instructions}")" 0 0 0 "$@" --stdout + --menu "${instructions}" 0 0 0 "$@" --stdout local code=$? [[ $code -eq 1 ]] && exit 0 } @@ -81,7 +81,7 @@ yesno() { # Returns: 0 yes, or 1 no # Args: Question to user. dialog --clear --title "Stormux X86_64 Installer" \ - --backtitle "$(gettext "Press 'Enter' for \"yes\" or 'Escape' for \"no\".")" --yesno "$*" -1 -1 --stdout + --backtitle "Press 'Enter' for \"yes\" or 'Escape' for \"no\"." --yesno "$*" -1 -1 --stdout return $? } @@ -115,7 +115,28 @@ answer="$(yesno "Have you created your own disk layout and mounted it at /mnt?") if [[ $answer -eq 1 ]]; then msgbox "Stormux can format a drive for you. Keep in mind that all data on the selected drive will be lost, including any other operating system that may be installed. To cancel, press control+c." mapfile -t driveList < <(lsblk -l -d -o 'PATH,SiZE' | tail -n +2 | tr -s '[:space:]' | tr '[:space:]' $'\n') - drive=$(menulist "Select a drive for the installation." "${driveList[@]}") + drive=$(menulist "Select a drive for the installation." "${driveList[@]}" --stdout) + # Check if the system is using UEFI + if [ -d /sys/firmware/efi ]; then + echo "UEFI detected. Setting up GPT partition table." + parted -s "$drive" mklabel gpt + parted -s "$drive" mkpart primary fat32 1MiB 512MiB + parted -s "$drive" set 1 esp on + parted -s "$drive" mkpart primary ext4 512MiB 100% + mkfs.fat -F32 "${drive}1" + mkfs.ext4 "${drive}2" + mount "${drive}2" /mnt + mkdir -p /mnt/boot + mount "${drive}1" /mnt/boot + else + echo "BIOS detected. Setting up MBR partition table." + parted -s "$drive" mklabel msdos + parted -s "$drive" mkpart primary ext4 1MiB 100MiB + parted -s "$drive" set 1 boot on + mkfs.ext4 "${drive}1" + mount "${drive}1" /mnt + mounted=0 + fi fi language=$(menulist "Select the System Language" \