From 0640a65e0b6f5bee1bfce70fce29345276b7e61a Mon Sep 17 00:00:00 2001 From: natemaia Date: Sat, 15 Sep 2018 20:57:15 -0700 Subject: [PATCH] Cleanup, fix missing/wrong dialogs, allow mounting old /home without overwriting --- lang/english.trans | 77 ++++++++++++++---------------------------- src/archlabs-installer | 4 +-- src/lib/boot.sh | 44 +++++++++--------------- src/lib/install.sh | 21 +++++++----- src/lib/mount.sh | 6 ++-- src/lib/utils.sh | 36 ++++++-------------- 6 files changed, 71 insertions(+), 117 deletions(-) diff --git a/lang/english.trans b/lang/english.trans index 2b1a8d3..dfe532f 100644 --- a/lang/english.trans +++ b/lang/english.trans @@ -2,12 +2,12 @@ # written by natemaia10@gmail.com - 2018 # Generic -_All="All" _Done="Done" _Skip="Skip/None" _ErrTitle="Installation Error" _NoFileErr="\nFile does not exist.\n" _PassErr="\nThe passwords entered do not match.\n" +_OnlyOne="\nOnly one partition available" _Pass2="\nRe-enter the password for" _TryAgain="Please try again.\n" _Exit="Exiting.\n" @@ -21,29 +21,23 @@ _WelBody="This will unpack and setup $DIST on your system\n\nMenu Navigation:\n\ # Requirements _NotRoot="\nThe installer must be run as root or using sudo.\n" _Not64Bit="\nThe installer must be run on x86_64 capable hardware or virtual machine.\n" -_NoNetwork="\nThe installer must be run with an active network connection.\n" +_NoNetwork="\nThe installer should be run with an active network connection.\n" # Preparation Menu _PrepTitle="Prepare System" _PrepBody="\nFollow the steps in order.\n\nConfigure settings before install." _PrepLayout="Keyboard Layout" -_PrepShowDev="List Devices (optional)" -_PrepParts="Partition Device" -_PrepLUKS="LUKS Encryption (optional)" +_PrepShowDev="List Device Tree" +_PrepParts="Edit Partitions" +_PrepLUKS="LUKS (optional)" _PrepLVM="LVM (optional)" _PrepMount="Mount Partitions" -_PrepConfig="Configure Installation" +_PrepConfig="Configure Install" _PrepInstall="Install $DIST" -_BootLdr="Install Bootloader" - -# Configure Menu -_ConfTitle="Configure Install" -_ConfBody="\nConfigure settings for the new system" +# Configure _ConfHost="System Hostname" _ConfLocale="Language and Timezone" -_ConfRoot="Root Password" -_ConfUser="Create New User" # Select Config Files _EditBody="\nThe install is now finished.\n\nSelect configuration file(s) listed below to review or change or select $_Done to close the installer and reboot." @@ -52,13 +46,6 @@ _EditTitle="Edit Files" # Close Installer _CloseInst="Close Installer" _CloseInstBody="\nUnmount partitions and close the installer?\n" - - -## NEW - -_OnlyOne="\nOnly one partition available" - -# finished _InstFinBody="\nThe installation is now finished.\n\nWould you like to close the installer and reboot?\n" # error message @@ -67,9 +54,11 @@ _ErrChoiceConsole="\nUnmount the partitions and exit to view the error log or ke # timezone _TimeZTitle="Set Timezone" +_TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below" +_TimeSubZBody="\nSelect the nearest city to your location from the list below." +_TimeZQ="\nSet time zone as:" # bootloader -_InstBootTitle="Install Bootloader" _MntBootBody="\nSelect bootloader and boot partition mountpoint.\n\nGrub is recommended, especially for multiboot." _InstSysTitle="Install Syslinux" _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?" @@ -77,55 +66,30 @@ _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)? # mirrors _MirrorTitle="Setup Mirrorlist" _MirrorSetup="\nWant the mirrorlist automatically sorted?\n\nThis will take longer but guarantees the fastest mirrors.\n" -_MirrorSort="\nSorting the mirrorlist.\n\nThis will take a minute.\n" _MirrorCountry="\nSelect a country to use when sorting mirrors, the full command can be changed manually after\n\nNote: Your country may not have the fastest mirrors for your location.\n" _MirrorCmd="\nThe command below will be used to sort the mirrorlist, a short description of each option is provided, edit the command if needed.\n" # window managers and packages -_WMChoice="Select Window Managers or Desktop Environments" +_WMChoice="Select WM or DE" _WMChoiceBody="\nUse [Space] to (de)select window manager(s) or desktop environment(s) to install.\n\nDepending on the choice additional packages may be installed to improve the experience." +_ExtraPackages="Extra Packages" +_ExtraPackagesBody="\nUse [Space] to (de)select packages(s) to install from the list below." +# login setup _WMLogin="Select Login Type" _LoginTypeBody="\nUse console login (xinit) or a display manager (lightdm)?" _WMLoginBody="\nSelect which window manager or desktop to use for login." _AutoLoginBody="\nDo you want to automatically log in when the computer starts?" -_PackageChoice="Additional Packages" -_PackageChoiceBody="\nUse [Space] to (de)select additional packages to install." - -_ChooseExtraPackages="\nChoose additional packages to install?\n" -_ExtraPackages="Extra Packages" -_ExtraPackagesBody="\nUse [Space] to (de)select packages(s) to install from the list below." - -## END NEW - - -# Error Messages -_ErrNoMount="\nPartition(s) must be mounted first.\n" -_ErrNoBase="\nThe base system must be unpacked first.\n" -_ErrNoConfig="\nBasic configuration for the system must be done first.\n" -_ExtErrBody="\nCannot mount partition due to a problem with the mountpoint name.\n\nA name must be given after a forward slash.\n" -_PartErrBody="\nBIOS systems require at least one partition (ROOT).\n\nUEFI systems require at least two (ROOT and EFI).\n" -_UserErrTitle="User Name Error" -_UserErrBody="\nIncorrect user name.\n\nPlease try again.\n" -_UserPassErr="\nThe user passwords entered do not match.\n" -_RootPassErr="\nThe root passwords entered do not match.\n" - # Set keymap, hwclock, local and timezone _CMapTitle="Virtual Console Keymap" _CMapBody="\nSelect virtual console keymap.\n\nVirtual console is the shell prompt before reaching a graphical environment (Xorg).\n\nIts keymap is seperate from the one used by Xorg.\n\nDefault: us" _XMapBody="\nSelect the system wide keymap, this is the keyboard layout used once a graphical environment (Xorg) is running.\n\nDefault: us" _LocaleBody="\nLocale determines the date, time, currency, and language.\n\nThe format is language_COUNTRY\n\neg. en_US: english United States\n en_GB: english Great Britain" -_TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below" -_TimeSubZBody="\nSelect the nearest city to your location from the list below." -_TimeZQ="\nSet time zone as:" # Set hostname _HostNameBody="\nA hostname is used to identify systems on the network.\n\nIt is restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain a hyphen (-) BUT NOT at the beggining or end." -# Set root password -_RootBody="--- Enter root password (empty uses the password entered above) ---" - # Create new user and set password _UserTitle="Create New User" _UserBody="\nEnter the name and password for your new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: [Tab] to toggle between text input and buttons, or press [Enter] to accept." @@ -133,6 +97,7 @@ _UserSetBody="\nCreating user and setting groups..\n" _Username="Username:" _Password="Password:" _Password2="Password2:" +_RootBody="--- Enter root password (empty uses the password entered above) ---" # Mounting (Partitions) _MntTitle="Mount Status" @@ -173,7 +138,6 @@ _SelBiosBody="\nDo you want to use a seperate boot partition? (required for LUKS _SelSwpFile="Swapfile" _SelSwpSetup="Swap Setup" - _SelSwpBody="\nSelect SWAP partition/file, or none. If using a swapfile, it will be initially set the same size as your RAM." _SelSwpNone="None" @@ -230,4 +194,15 @@ _LvmPartErrBody="There are no viable partitions available to use for LVM. A mini _LvmLvNameErrBody="Invalid name entered.\n\nThe logical volume (LV) name may be alpha-numeric, but may not contain spaces or be preceded with a '/'\n" _LvmLvSizeErrBody="\nInvalid value Entered.\n\nMust be a numeric value with 'M' (megabytes) or 'G' (gigabytes) at the end.\n\neg. 400M, 10G, 250G, etc...\n\nThe value may also not be equal to or greater than the remaining size of the volume group.\n" +# Error Messages +_ErrNoMount="\nPartition(s) must be mounted first.\n" +_ErrNoBase="\nThe base system must be unpacked first.\n" +_ErrNoConfig="\nBasic configuration for the system must be done first.\n" +_ExtErrBody="\nCannot mount partition due to a problem with the mountpoint name.\n\nA name must be given after a forward slash.\n" +_PartErrBody="\nBIOS systems require at least one partition (ROOT).\n\nUEFI systems require at least two (ROOT and EFI).\n" +_UserErrTitle="User Name Error" +_UserErrBody="\nIncorrect user name.\n\nPlease try again.\n" +_UserPassErr="\nThe user passwords entered do not match.\n" +_RootPassErr="\nThe root passwords entered do not match.\n" + # vim:ft=sh:tw=0:syntax=off:nospell diff --git a/src/archlabs-installer b/src/archlabs-installer index 6941fd3..c58244b 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -12,7 +12,7 @@ # immutable variables { readonly DIST="ArchLabs" # Linux distributor -readonly VER="1.6.74" # Installer version +readonly VER="1.6.75" # Installer version readonly LIVE="liveuser" # Live session user readonly MNT="/mnt/install" # Install mountpoint readonly ERR="/tmp/errlog" # Built-in error log @@ -345,7 +345,7 @@ window_manager() { extra_packages() { local pkgs pkgs="$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 30 \ + --title " $_ExtraPackages " --checklist "$_ExtraPackagesBody\n" 0 0 30 \ "firefox" "A popular open-source graphical web browser from Mozilla" off \ "chromium" "an open-source graphical web browser based on the Blink rendering engine" off \ "opera" "Fast and secure, free of charge web browser from Opera Software" off \ diff --git a/src/lib/boot.sh b/src/lib/boot.sh index 3ae86fc..04eb7ed 100644 --- a/src/lib/boot.sh +++ b/src/lib/boot.sh @@ -6,14 +6,6 @@ # this file is not meant to be run directly # sourcing this file in a non bash shell is not advised -shim_secure_boot() { - # still a W.I.P - local shim_file="shim64.efi" - [[ $IS_64BIT != true ]] && shim_file="shim.efi" - efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file - return 0 -} - uefi_boot_fallback() { # some UEFI firmware requires a directory in the ESP and a generic bootx64.efi # see: https://wiki.archlinux.org/index.php/GRUB#UEFI @@ -21,9 +13,9 @@ uefi_boot_fallback() { local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}" - local default + local default="boot" default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d)" - [[ $default ]] && default="$(basename $default)" || default="boot" + [[ $default ]] && default="$(basename $default)" # directory exists: remove everything inside, otherwise mkdir it [[ -d $esp/EFI/$default ]] && rm -rf $esp/EFI/$default/* || mkdir -p $esp/EFI/$default @@ -35,39 +27,30 @@ uefi_boot_fallback() { cp -f $esp/EFI/syslinux/syslinux.efi $esp/EFI/$default/bootx64.efi elif [[ $BOOTLDR == 'grub' ]]; then # grub uses different names for the stub depending on architecture - if [[ $IS_64BIT != true ]]; then - local grub_file="grubia32.efi" - local boot_file="bootia32.efi" - else - local grub_file="grubx64.efi" - local boot_file="bootx64.efi" - fi - cp -f $esp/EFI/$DIST/$grub_file $esp/EFI/$default/$boot_file + local ext="ia32" + [[ $IS_64BIT == true ]] && ext="x64" + cp -f $esp/EFI/$DIST/grub${ext}.efi $esp/EFI/$default/boot${ext}.efi fi return 0 } prep_for_grub() { local cfg="$MNT/etc/default/grub" - sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg - if [[ $LUKS -eq 1 ]]; then sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg fi - if [[ $SYS == 'BIOS' && $LVM -eq 1 && $SEPERATE_BOOT == false ]]; then sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg fi - return 0 } prep_for_systemd-boot() { # no LVM then systemd-boot uses PARTUUID - ! [[ $ROOT_PART =~ /dev/mapper ]] && ROOT_PART_ID="PART$ROOT_PART_ID" + [[ $ROOT_PART =~ /dev/mapper ]] || ROOT_PART_ID="PART$ROOT_PART_ID" # create the boot entry configs mkdir -p $MNT/boot/loader/entries @@ -103,11 +86,8 @@ EOF prep_for_syslinux() { if [[ $SYS == 'UEFI' ]]; then local cfgdir="$MNT/boot/EFI/syslinux" - if [[ $IS_64BIT == true ]]; then - local cfgsrcdir="/usr/lib/syslinux/efi64/" - else - local cfgsrcdir="/usr/lib/syslinux/efi32/" - fi + local cfgsrcdir="/usr/lib/syslinux/efi32/" + [[ $IS_64BIT == true ]] && cfgsrcdir="/usr/lib/syslinux/efi64/" else local cfgdir="$MNT/boot/syslinux" local cfgsrcdir="/usr/lib/syslinux/bios/" @@ -165,3 +145,11 @@ install_bootloader() { [[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]] && uefi_boot_fallback return 0 } + +shim_secure_boot() { + # still a W.I.P + local shim_file="shim.efi" + [[ $IS_64BIT == true ]] && shim_file="shim64.efi" + efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file + return 0 +} diff --git a/src/lib/install.sh b/src/lib/install.sh index 96c4fdb..55ac26a 100644 --- a/src/lib/install.sh +++ b/src/lib/install.sh @@ -123,16 +123,19 @@ create_user() { # edit the group and passwd files in /etc/ to swap the liveuser account sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow} - # fix up some user files that reference the liveuser - sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/home/$LIVE/.config/gtk-3.0/bookmarks \ - $MNT/home/$LIVE/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js - [[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$LIVE/.config/{bspwm,sxhkd} - [[ $INSTALL_WMS =~ i3-gaps ]] || rm -rf $MNT/home/$LIVE/.config/i3 - [[ $INSTALL_WMS =~ openbox ]] || rm -rf $MNT/home/$LIVE/.config/{openbox,skippy-xd,jgmenu,conky,tint2} - - chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER" - chroot_cmd "usermod -aG rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin $NEWUSER" + if [[ -d $MNT/home/$NEWUSER ]]; then + rm -rf $MNT/home/$LIVE + else + # fix up some user files that reference the liveuser + sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/home/$LIVE/.config/gtk-3.0/bookmarks \ + $MNT/home/$LIVE/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js + [[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$LIVE/.config/{bspwm,sxhkd} + [[ $INSTALL_WMS =~ i3-gaps ]] || rm -rf $MNT/home/$LIVE/.config/i3 + [[ $INSTALL_WMS =~ openbox ]] || rm -rf $MNT/home/$LIVE/.config/{openbox,skippy-xd,jgmenu,conky,tint2} + chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER" + fi + chroot_cmd "usermod -aG rfkill,wheel,network,storage,power,video,audio,lp,autologin $NEWUSER" chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd" chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER" } diff --git a/src/lib/mount.sh b/src/lib/mount.sh index 779e533..46869e4 100644 --- a/src/lib/mount.sh +++ b/src/lib/mount.sh @@ -19,6 +19,7 @@ format() { decr_count() { # remove a partition from the dialog list and decrement the number partitions left local p="$1" + [[ $p ]] || return 1 PARTS="$(sed "s~${p} [0-9]*[G-M]~~; s~${p} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")" (( COUNT > 0 )) && (( COUNT-- )) return 0 @@ -116,6 +117,7 @@ find_partitions() { check_cryptlvm() { local part="$1" + local dev="" local devs="$(lsblk -lno NAME,FSTYPE,TYPE)" # Identify if $part is "crypt" (LUKS on LVM, or LUKS alone) @@ -405,8 +407,8 @@ select_boot_setup() { else FILES[9]="/etc/default/grub" if [[ $SYS == 'UEFI' ]]; then - local ttype - [[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi' + local ttype="i386-efi" + [[ $IS_64BIT == true ]] && ttype='x86_64-efi' BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST" else BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE" diff --git a/src/lib/utils.sh b/src/lib/utils.sh index b21a2f8..de75905 100644 --- a/src/lib/utils.sh +++ b/src/lib/utils.sh @@ -19,44 +19,31 @@ identify_system() { if [[ -d /sys/firmware/efi ]]; then SYS="UEFI" - # [[ $(mount) =~ $EFI ]] && mount -t efivarfs efivarfs $EFI >/dev/null 2>&1 - - local bitness - bitness=$(cat /sys/firmware/efi/fw_platform_size) - if [[ $bitness != "" && $bitness == 64 ]]; then - IS_64BIT=true - else - IS_64BIT=false - fi + [[ $(cat /sys/firmware/efi/fw_platform_size) == 64 ]] && IS_64BIT=true else SYS="BIOS" fi if [[ $IS_64BIT == true ]]; then - readonly BT="$DIST Installer - $SYS (i686) - Version $VER" - else readonly BT="$DIST Installer - $SYS (x86_64) - Version $VER" + else + readonly BT="$DIST Installer - $SYS (i686) - Version $VER" fi return 0 } check_requirements() { - local err=0 if [[ $(whoami) != "root" ]]; then - infobox "$_ErrTitle" "$_NotRoot\n$_Exit" - err=1 + infobox "$_ErrTitle" "$_NotRoot\n$_Exit" && die 1 elif ! grep -qw 'lm' /proc/cpuinfo; then - infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" - err=1 + infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" && die 1 elif ! (ping -c 1 archlinux.org || ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) >/dev/null 2>&1; then ([[ $(systemctl is-active NetworkManager) == "active" ]] && hash nmtui >/dev/null 2>&1) && { tput civis; nmtui; } if ! (ping -c 1 archlinux.org || ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) >/dev/null 2>&1; then - infobox "$_ErrTitle" "$_NoNetwork\n$_Exit" - err=1 + infobox "$_ErrTitle" "$_NoNetwork\n" fi fi - - [[ $err -eq 1 ]] && die 1 || return 0 + return 0 } check_for_errors() { @@ -83,16 +70,16 @@ check_for_errors() { } check_install_ready() { + [[ $(lsblk -o MOUNTPOINT) =~ $MNT && $CONFIG_DONE == true ]] && return 0 + if ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then msgbox "$_ErrTitle" "$_ErrNoMount" MENU_HIGHLIGHT=4 - return 1 - elif [[ $CONFIG_DONE != true ]]; then + else msgbox "$_ErrTitle" "$_ErrNoConfig" MENU_HIGHLIGHT=5 - return 1 fi - return 0 + return 1 } unmount_partitions() { @@ -166,7 +153,6 @@ debug() { set -x exec 3>| /tmp/debug-log BASH_XTRACEFD=3 - if [[ $DISPLAY && $TERM != 'linux' ]]; then if [[ $TERM_CMD == 'st' ]]; then $TERM_CMD -e tail -f /tmp/debug-log &