diff --git a/lang/english.trans b/lang/english.trans index f6d73bb..7915199 100644 --- a/lang/english.trans +++ b/lang/english.trans @@ -1,127 +1,68 @@ # english translation file # written by natemaia10@gmail.com - 2018 -_Done="Done" -_Back="Back" -_Name="Name:" -_Skip="Skip/None" -_Exit="Exiting.\n" -_ErrTitle="Installation Error" -_TryAgain="Please try again.\n" -_Pass2="\nRe-enter the password for" -_NoFileErr="\nFile does not exist.\n" - _WelTitle="Welcome to the" _WelBody="\nThis will help you get $DIST setup on your system.\nHaving GNU/Linux experience is an asset, however we try our best to keep things simple.\n\nIf you are unsure about an option, a default will be listed or\nthe first selected option will be the default (excluding language and timezone).\n\n\nMenu Navigation:\n\n - Select items with the arrow keys or the option number.\n - Use [Space] to toggle options and [Enter] to confirm.\n - Switch between buttons using [Tab] or the arrow keys.\n - Use [Page Up] and [Page Down] to jump whole pages\n - Press the highlighted key of an option to select it.\n" -_NotRoot="\nThis installer must be run as root or using sudo.\n" -_Not64Bit="\nThis installer only supports x86_64 architectures.\n" -_NoNetwork="\nThis installer requires an active internet connection.\n" - -_PrepTitle="Prepare Install" -_PrepBody="\nThis is the menu in which you will prepare your system for the install.\n\nTo begin the install you must first have:\n\n - A root (/) partition mounted (UEFI systems also require a seperate boot partition).\n - A new user created and the passwords set.\n - The system configuration finished.\n\nOnce the above requirements are met and you have gone through any optional setup steps you like the install can be started." -_PrepLayout="Keyboard Layout" -_PrepShowDev="Show lsblk output (optional)" -_PrepParts="Edit partitions (optional)" +_PrepBody="\nThis is the menu where you can prepare your system for the install.\n\nTo begin the install you must first have:\n\n - A root (/) partition mounted (UEFI systems also require a seperate boot partition).\n - A new user created and the passwords set.\n - The system configuration finished.\n\nOnce the above requirements are met and you have gone through any optional setup steps you like the install can be started." +_PrepShow="Show lsblk output (optional)" +_PrepPart="Edit partitions (optional)" _PrepLUKS="LUKS encryption (optional)" _PrepLVM="Logical volume management (optional)" -_PrepMount="Mount and format partitions" +_PrepMnt="Mount and format partitions" _PrepUser="Create user and set passwords" -_PrepConfig="Configure system settings" +_PrepConf="Configure system settings" _PrepWM="Select window manager or desktop (optional)" _PrepPkg="Select additional packages (optional)" -_PrepShow="Check configuration choices (optional)" -_PrepInstall="Start the installation" +_PrepChk="Check configuration choices (optional)" +_Install="Start the installation" -_EditTitle="Finalization" -_EditBody="\nBefore exiting you can select configuration files from below to review/change.\n\nIf you need to make additional changes with the drives still mounted, use Ctrl-z to pause the installer and return to the terminal, when finished type 'fg' and [Enter] or Ctrl-z again to resume the installer." +_EditBody="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] or Ctrl-z again to resume the installer." -_CloseInst="Exit" -_CloseInstBody="\nUnmount partitions (if any) and exit the installer?\n" - -_TimeZTitle="Timezone" -_TimeZQ="\nConfirm time zone:" _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 you or one with the same time zone.\n\nTIP: Pressing the first letter of the city name repeatedly will navigate between entries beggining with that letter." -_MntBootBody="\nSelect which bootloader to use." - -_MirrorTitle="Mirrorlist" _MirrorSetup="\nSort the mirrorlist automatically?\n\nTakes longer but gets fastest mirrors.\n" _MirrorCmd="\nThe command below will be used to sort the mirrorlist, edit if needed.\n" -_WMChoice="Sessions" _WMChoiceBody="\nUse [Space] to toggle available sessions.\n\nFor all sessions a basic package set will be installed for basic compatibilty across sessions. In addition to this extra packages specific to each sessions will also be installed to provide basic functionality most people expect from an environment." -_Packages="Packages" _PackageMenu="\nSelect a category to choose packages from, once finished select the last entery or press [Esc] to return to the main menu." _PackageBody="\nUse [Space] to toggle packages(s) and press [Enter] to accept the selection.\n\nNOTE: Some packages may already be installed by your desktop environment (if any). Extra packages may also be installed for the selected packages eg. Selecting qutebrowser will also install qt5ct (the Qt5 theme tool) and qt5-styleplugins (for Gtk themes in Qt applications)." -_WMLogin="Login Managment" -_LoginTypeBody="\nSelect which login managment to use." -_AutoLoginBody="\nDo you want autologin enabled?\n" _WMLoginBody="\nSelect which of your session choices to use for the initial login.\n\nYou can be change this later by editing your ~/.xinitrc" _XMapBody="\nPick your system keymap from the list below\n\nThis is the keymap used once a graphical environment is running (usually Xorg).\n\nSystem default: us" _LocaleBody="\nLocale determines the system language and currency formats.\n\nThe format for locale names is languagecode_COUNTRYCODE\n\neg. en_US is: english United States\n en_GB is: english Great Britain" -_CMapTitle="Console Keymap" _CMapBody="\nSelect console keymap, the console is the tty shell you reach before starting a graphical environment (usually Xorg).\n\nIts keymap is seperate from the one used by the graphical environments, though many do use the same such as 'us' English.\n\nSystem default: us" -_ConfHost="Hostname" -_ConfLocale="Language and Locale" _HostNameBody="\nEnter a hostname for the new system.\n\nA hostname is used to identify systems on the network.\n\nIt's restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain hyphens (-) BUT NOT at the beggining or end." -_UserTitle="User Creation" -_Username="Username:" -_Password="Password:" -_Password2="Password2:" _RootBody="--- Enter root password (empty uses the password entered above) ---" _UserBody="\nEnter a name and password for the new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: Use the [Up] and [Down] arrows to switch between input fields, [Tab] to toggle between input fields and the buttons, and [Enter] to accept." -_MntTitle="Mount Status" -_MntFail="\nMount Failed!\n" -_MntSucc="\nMount Succeeded!\n" -_MntConfBody="\nConfirm mount options:" _MntBody="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount." -_WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nPartitions can be mounted without formatting by selecting '$_Skip' during mounting, useful for extra or already formatted partitions.\n\nThe exception to this is the root (/) partition, it needs to be formatted before install to ensure system stability.\n" +_WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nPartitions can be mounted without formatting by selecting skip during mounting, useful for extra or already formatted partitions.\n\nThe exception to this is the root (/) partition, it needs to be formatted before install to ensure system stability.\n" -_DevSelTitle="Device Selection" _DevSelBody="\nSelect a device to use from the list below.\n\nDevices (/dev) are the available drives on the system. /sda, /sdb, /sdc ..." -_ExtPartBody="\nYou can now select additional partitions you want mounted, once choosen you will be asked to enter a mountpoint.\n\nSelect '$_Done' to finish the mounting step and return to the main menu." +_ExtPartBody="\nYou can now select additional partitions you want mounted, once choosen you will be asked to enter a mountpoint.\n\nSelect 'done' to finish the mounting step and return to the main menu." _ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a slash (/).\nExamples include: /usr, /home, /var, etc." -_KernelTitle="Linux Kernel" -_KernelBody="\nSelect a kernel to use for the install." - -_ShellTitle="Login Shell" -_ShellBody="\nChoose a shell for the new user and root." - -_PartTitle="Partitioning" -_PartWipe="Secure wipe" -_PartAuto="Auto partitioning" -_PartShowTree="Show partition Table" _PartBody="\nFull device auto partitioning is available for beginners otherwise cfdisk is recommended.\n\n - All systems will require a root partition (8G or greater).\n - UEFI and BIOS using LUKS without LVM will require a boot partition (100-512M)." _PartBody1="\nWARNING: ALL data on" -_PartBody2="will be destroyed and the following partitions will be created\n\n- A 512M vfat/fat32 boot partition with boot flags enabled.\n- An ext4 partition using all remaining space" +_PartBody2="will be destroyed and the following partitions will be created\n\n- A vfat/fat32 boot partition with boot flags enabled (512M)\n- An ext4 partition using all remaining space" _PartBody3="\n\nDo you want to continue?\n" _PartWipeBody="will be destroyed using 'wipe -Ifre'.\n\nThis is ONLY intended for use on devices before sale or disposal to reliably destroy the data beyond recovery. This is NOT for devices you intend to continue using.\nThe wiping process can take a long time depending on the size and speed of the drive.\n\nDo you still want to continue?\n" -_FSTitle="Filesystem" _SelRootBody="\nSelect the root (/) partition, this is where $DIST will be installed." _SelUefiBody="\nSelect the EFI boot partition (/boot), required for UEFI boot.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as vfat/fat32 if not already." _SelBiosBody="\nDo you want to use a separate boot partition? (optional)\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already." _SelBiosLuksBody="\nSelect the boot partition (/boot), required for LUKS.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already." -_FormUefiBody="\nIMPORTANT: The EFI partition" -_FormBiosBody="\nIMPORTANT: The boot partition" _FormBootBody="is already formatted correctly.\n\nFor a clean install, previously existing partitions should be reformatted, however this removes ALL data (bootloaders) on the partition so choose carefully.\n\nDo you want to reformat the partition?\n" -_SelSwpNone="None" -_SelSwpFile="Swapfile" -_SelSwpSetup="Swap Setup" -_SelSwpBody="\nSelect whether to use a swap partition, swapfile, or none." _SelSwpErr="\nSwap Setup Error: Must be 1(M|G) or greater, and can only contain whole numbers\n\nSize Entered:" _SelSwpSize="\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\neg. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example it is filled in to match the size of your system memory (RAM).\n\nMust be greater than 1, contain only whole numbers, and end with either M or G." @@ -132,7 +73,7 @@ _LuksMenuBody3="\n\nAutomatic uses default encryption settings, and is recommend _LuksOpenBody="\nEnter a name and password for the encrypted device.\n\nIt is not necessary to prefix the name with /dev/mapper/,an example has been provided." _LuksEncrypt="Basic LUKS Encryption" _LuksEncryptAdv="Advanced LUKS Encryption" -_LuksOpen="Open Previous Encryption" +_LuksOpen="Open Encrypted Partition" _LuksEncryptBody="\nSelect the partition you want to encrypt." _LuksEncryptSucc="\nDone! encrypted partition opened and ready for mounting.\n" _LuksPartErrBody="\nA minimum of two partitions are required for encryption:\n\n 1. root (/) - standard or LVM.\n 2. boot (/boot) - standard (unless using LVM on BIOS systems).\n" @@ -142,18 +83,16 @@ _LuksWaitBody2="\n\nDevice or volume used:" _LuksCipherKey="Once the specified flags have been amended, they will automatically be used with the 'cryptsetup -q luksFormat /dev/...' command.\n\nNOTE: Do not specify any additional flags such as -v (--verbose) or -y (--verify-passphrase)." _LvmMenu="\nLogical volume management (LVM) allows 'virtual' hard drives (volume groups) and partitions (logical volumes) to be created from existing device partitions.\n\nA volume group must be created first, then one or more logical volumes within it.\n\nLVM can also be used with an encrypted partition to create multiple logical volumes (e.g. root and home) within it." -_LvmCreateVG="Create New VG and LV(s)" -_LvmDelVG="Delete Existing VG(s)" -_LvMDelAll="\nDelete *ALL* volume groups, logical volumes, and physical volumes" +_LvmNew="Create VG and LV(s)" +_LvmDel="Delete existing VG(s)" +_LvmDelAll="Delete all VGs, LVs, and PVs" _LvmDetBody="\nExisting logical volume management (LVM) detected.\n\nActivating...\n" -_LvmNameVgBody="\nEnter the name of the volume group (VG) to create.\n\nThe VG is the new virtual device to create out of the partition(s) selected." +_LvmNameVgBody="\nEnter the name of the volume group (VG) to create.\n\nThe VG is the new virtual device that will be created from the partition(s) selected." _LvmPvSelBody="\nSelect the partition(s) to use for the physical volume (PV)." _LvmPvConfBody1="\nConfirm creation of volume group:" _LvmPvConfBody2="with the following partition(s):" _LvmPvActBody1="\nCreating and activating volume group:" -_LvmPvDoneBody1="volume group:" -_LvmPvDoneBody2="has been created" -_LvmLvNumBody1="\nUse [Spacebar] to select the number of logical volumes (LVs) to create in:" +_LvmLvNumBody1="\nSelect the number of logical volumes (LVs) to create in:" _LvmLvNumBody2="\nThe last (or only) logical volume will automatically use all remaining space in the volume group." _LvmLvNameBody1="\nEnter the name of the logical volume (LV) to create.\n\nThis is like setting a name or label for a partition.\n" _LvmLvNameBody2="\nNOTE: This LV will use up all remaining space in the volume group" @@ -169,15 +108,7 @@ _LvmPartErrBody="\nThere are no viable partitions available to use for LVM, a mi _LvmLvNameErrBody="\nInvalid 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" -_UserErrTitle="User Name Error" -_PassErr="\nThe passwords entered do not match.\n" -_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" -_UserPassEmpty="\nThe user password cannot be left empty.\n" -_ErrNoMount="\nPartition(s) must be mounted first.\n" -_ErrNoConfig="\nSystem configuration must be done first.\n" -_ErrNoUser="\nA new user account must be created first.\n" +_ErrTitle="Installation Error" _ExtErrBody="\nCannot mount partition due to a problem with the mountpoint.\n\nEnsure it begins with a slash (/) followed by atleast one character.\n" _PartErrBody="\nYou need create the partiton(s) first.\n\n\nBIOS systems require at least one partition (ROOT).\n\nUEFI systems require at least two (ROOT and EFI).\n" diff --git a/src/archlabs-installer b/src/archlabs-installer index dd07c29..d2d151d 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -8,7 +8,7 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due -VER="2.0.1" # version +VER="2.0.6" # version DIST="ArchLabs" # distributor MNT="/mnt" # mountpoint @@ -16,7 +16,7 @@ MNT="/mnt" # mountpoint ROOT_PART="" # root partition BOOT_PART="" # boot partition -BOOT_DEVICE="" # device used for BIOS grub install +BOOT_DEV="" # device used for BIOS grub install BOOTLDR="" # bootloader selected EXMNT="" # holder for additional partitions while mounting EXMNTS="" # when an extra partition is mounted append it's info @@ -28,7 +28,7 @@ ROOT_PASS="" # root password LOGIN_WM="" # default login session LOGIN_TYPE="" # login manager can be lightdm or xinit INSTALL_WMS="" # space separated list of chosen wm/de -KERNEL="linux" # can be linux, linux-lts, linux-zen, or linux-hardened +KERNEL="" # can be linux, linux-lts, linux-zen, or linux-hardened MYSHELL="" # login shell for root and the primary user LOGINRC="" # login shell rc file PACKAGES="" # list of all packages to install including WM_PKGS @@ -209,40 +209,40 @@ main() (( SEL < 11 )) && (( SEL++ )) tput civis SEL=$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_PrepTitle " --default-item $SEL \ + --title " Prepare " --default-item $SEL \ --cancel-label 'Exit' --menu "$_PrepBody" 0 0 0 \ - "1" "$_PrepShowDev" \ - "2" "$_PrepParts" \ + "1" "$_PrepShow" \ + "2" "$_PrepPart" \ "3" "$_PrepLUKS" \ "4" "$_PrepLVM" \ - "5" "$_PrepMount" \ + "5" "$_PrepMnt" \ "6" "$_PrepUser" \ - "7" "$_PrepConfig" \ + "7" "$_PrepConf" \ "8" "$_PrepWM" \ "9" "$_PrepPkg" \ - "10" "$_PrepShow" \ - "11" "$_PrepInstall") + "10" "$_PrepChk" \ + "11" "$_Install") - [[ $WARN != true && $SEL =~ (2|5) ]] && { WARN=true; msgbox "$_PrepTitle" "$_WarnMount"; } + [[ $WARN != true && $SEL =~ (2|5) ]] && { WARN=true; msgbox "Prepare" "$_WarnMount"; } case $SEL in - 1) device_tree ;; + 1) dev_tree ;; 2) part_menu || (( SEL-- )) ;; 3) luks_menu || (( SEL-- )) ;; 4) lvm_menu || (( SEL-- )) ;; 5) mount_menu || (( SEL-- )) ;; - 6) prechecks 0 && { mkuser || (( SEL-- )); } ;; - 7) prechecks 1 && { cfg_menu || (( SEL-- )); } ;; + 6) prechecks 0 && { select_mkuser || (( SEL-- )); } ;; + 7) prechecks 1 && { select_config || (( SEL-- )); } ;; 8) prechecks 2 && { select_sessions || (( SEL-- )); } ;; 9) prechecks 2 && { select_packages || (( SEL-- )); } ;; 10) prechecks 2 && show_cfg ;; - 11) prechecks 2 && install ;; - *) yesno "$_CloseInst" "$_CloseInstBody" && die + 11) prechecks 2 && install_main ;; + *) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die esac } ############################################################################### -# dialog menus +# selection menus show_cfg() { @@ -257,12 +257,12 @@ show_cfg() pkgs="${pkgs# }" pkgs="${pkgs% }" pkgs="${pkgs// / }" - msgbox "$_PrepTitle" " + msgbox "Show Configuration" " ---------- PARTITION CONFIGURATION ------------ Root: ${ROOT_PART:-none} - Boot: ${BOOT_PART:-${BOOT_DEVICE:-none}} + Boot: ${BOOT_PART:-${BOOT_DEV:-none}} Swap: ${SWAP_PART:-none} Size: ${SWAP_SIZE:-none} @@ -307,24 +307,58 @@ show_cfg() " } -cfg_menu() +select_login() +{ + LOGIN_TYPE="$(menubox "Login Management" "\nSelect which login management to use." \ + "xinit" "Console login without a display manager" \ + "lightdm" "Lightweight display manager with a gtk greeter")" + + if [[ $LOGIN_TYPE == "" ]]; then + return 1 + elif [[ $LOGIN_TYPE == 'lightdm' ]]; then + WM_PKGS+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice" + EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf" + AUTOLOGIN=false + else + if [[ $WM_NUM -eq 1 ]]; then + LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}" + else + LOGIN_WM="$(menubox "Login Management" "$_WMLoginBody" $LOGIN_CHOICES)" || return 1 + LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}" + fi + + local msg="\nDo you want autologin enabled for $NEWUSER?\n\nPicking yes will create the following files:\n\n - /home/$NEWUSER/$LOGINRC (run startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (login $NEWUSER without password)\n\nTo disable autologin remove these files.\n" + + yesno "Autologin" "$msg" && AUTOLOGIN=true || AUTOLOGIN=false + + PACKAGES="${PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" + WM_PKGS="${WM_PKGS// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" + WM_PKGS+=" xorg-xinit" + EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile" + fi +} + +select_config() { tput civis - MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')" + MYSHELL="$(menubox "Shell" "\nChoose a shell for the new user and root." \ + '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')" + case $MYSHELL in "/bin/bash") LOGINRC=".bash_profile" ;; "/usr/bin/mksh") LOGINRC=".profile" ;; "/usr/bin/zsh") LOGINRC=".zprofile" ;; *) return 1 ;; esac + tput cnorm - HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")" + HOSTNAME="$(getinput "Hostname" "$_HostNameBody" "${DIST,,}")" [[ $HOSTNAME ]] || return 1 tput civis - LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $SHL $LOCALES)" + LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " Locale " --menu "$_LocaleBody" 0 0 $SHL $LOCALES)" [[ $LOCALE ]] || return 1 select_timezone || return 1 - KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" \ + KERNEL="$(menubox "Kernel" "\nSelect a kernel to use for the install." \ 'linux' 'Vanilla Linux kernel and modules, with a few patches applied.' \ 'linux-lts' 'Long-term support (LTS) Linux kernel and modules.' \ 'linux-zen' 'A collaborative effort of kernel hackers to provide the best Linux kernel for everyday systems' \ @@ -336,47 +370,48 @@ cfg_menu() return 0 } -mkuser() +select_mkuser() { - local values="" user="" pass="" pass2="" rpass="" rpass2="" err=0 + local v="" u="" p="" p2="" rp="" rp2="" err=0 + local l=$((${#_RootBody} + 1)) while true; do tput cnorm - values="$(dialog --stdout --no-cancel --separator ';:~:;' \ - --ok-label "Submit" --backtitle "$BT" --title " $_UserTitle " \ + v="$(dialog --stdout --no-cancel --separator ';:~:;' \ + --ok-label "Submit" --backtitle "$BT" --title " User Creation " \ --insecure --mixedform "$_UserBody" 0 0 0 \ - "$_Username" 1 1 "$user" 1 $((${#_Username} + 2)) $COLUMNS 0 0 \ - "$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \ - "$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1 \ - "$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) $COLUMNS 0 2 \ - "$_Password" 8 1 "" 8 $((${#_Password} + 2)) $COLUMNS 0 1 \ - "$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) $COLUMNS 0 1)" + "Username:" 1 1 "$u" 1 11 $COLUMNS 0 0 \ + "Password:" 2 1 "" 2 11 $COLUMNS 0 1 \ + "Password2:" 3 1 "" 3 12 $COLUMNS 0 1 \ + "$_RootBody" 6 1 "" 6 $l $COLUMNS 0 2 \ + "Password:" 8 1 "" 8 11 $COLUMNS 0 1 \ + "Password2:" 9 1 "" 9 12 $COLUMNS 0 1)" err=$? (( err == 0 )) || break - user="$(awk -F';:~:;' '{print $1}' <<< "$values")" - pass="$(awk -F';:~:;' '{print $2}' <<< "$values")" - pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")" - rpass="$(awk -F';:~:;' '{print $5}' <<< "$values")" - rpass2="$(awk -F';:~:;' '{print $6}' <<< "$values")" + u="$(awk -F';:~:;' '{print $1}' <<< "$v")" + p="$(awk -F';:~:;' '{print $2}' <<< "$v")" + p2="$(awk -F';:~:;' '{print $3}' <<< "$v")" + rp="$(awk -F';:~:;' '{print $5}' <<< "$v")" + rp2="$(awk -F';:~:;' '{print $6}' <<< "$v")" # root passwords empty, so use the user passwords - [[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; } + [[ $rp == "" && $rp2 == "" ]] && { rp="$p"; rp2="$p2"; } # make sure a username was entered and that the passwords match - if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9] ]]; then - msgbox "$_UserErrTitle" "$_UserErrBody"; user="" - elif [[ $pass == "" ]]; then - msgbox "$_ErrTitle" "$_UserPassEmpty\n$_TryAgain" - elif [[ "$pass" != "$pass2" ]]; then - msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain" - elif [[ "$rpass" != "$rpass2" ]]; then - msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain" + if [[ ${#u} -eq 0 || $u =~ \ |\' || $u =~ [^a-z0-9] ]]; then + msgbox "Invalid Username" "\nIncorrect user name.\n\nPlease try again.\n"; u="" + elif [[ $p == "" ]]; then + msgbox "Empty Password" "\nThe user password cannot be left empty.\n\nPlease try again.\n" + elif [[ "$p" != "$p2" ]]; then + msgbox "Password Mismatch" "\nThe user passwords do not match.\n\nPlease try again.\n" + elif [[ "$rp" != "$rp2" ]]; then + msgbox "Password Mismatch" "\nThe root passwords do not match.\n\nPlease try again.\n" else - NEWUSER="$user" - USER_PASS="$pass" - ROOT_PASS="$rpass" + NEWUSER="$u" + USER_PASS="$p" + ROOT_PASS="$rp" break fi done @@ -387,7 +422,7 @@ select_keymap() { tput civis KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_PrepLayout " --menu "$_XMapBody" 0 0 $SHL \ + --title " Keyboard Layout " --menu "$_XMapBody" 0 0 $SHL \ 'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \ 'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \ 'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \ @@ -413,7 +448,7 @@ select_keymap() if [[ $CMAPS == *"$KEYMAP"* ]]; then CMAP="$KEYMAP" else - CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_CMapTitle " --menu "$_CMapBody" 0 0 $SHL $CMAPS)" + CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " Console Keymap " --menu "$_CMapBody" 0 0 $SHL $CMAPS)" [[ $CMAP ]] || return 1 fi @@ -437,16 +472,16 @@ select_timezone() while true; do tput civis - ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" \ + ZONE="$(menubox "Timezone" "$_TimeZBody" \ 'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \ 'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')" [[ $ZONE ]] || { err=1; break; } SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $SHL ${subz[$ZONE]})" + --title " Timezone " --menu "$_TimeSubZBody" 0 0 $SHL ${subz[$ZONE]})" [[ $SUBZONE ]] || { err=1; break; } - yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE\n" && break + yesno "Timezone" "\nConfirm time zone: $ZONE/$SUBZONE\n" && break done return $err @@ -458,7 +493,7 @@ select_sessions() tput civis INSTALL_WMS="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 0 \ + --title " Sessions " --checklist "$_WMChoiceBody\n" 0 0 0 \ "i3-gaps" "A fork of i3wm with more features including gaps" off \ "openbox" "A lightweight, powerful, and highly configurable stacking wm" off \ "bspwm" "A tiling wm that represents windows as the leaves of a binary tree" off \ @@ -491,121 +526,6 @@ select_sessions() return 0 } -select_login() -{ - LOGIN_TYPE="$(menubox "$_WMLogin" "$_LoginTypeBody" \ - "xinit" "Console login without a display manager" \ - "lightdm" "Lightweight display manager with a gtk greeter")" - - - if [[ $LOGIN_TYPE == "" ]]; then - return 1 - elif [[ $LOGIN_TYPE == 'lightdm' ]]; then - WM_PKGS+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice" - EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf" - AUTOLOGIN=false - else - if [[ $WM_NUM -eq 1 ]]; then - LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}" - else - LOGIN_WM="$(menubox "$_WMLogin" "$_WMLoginBody" $LOGIN_CHOICES)" || return 1 - LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}" - fi - - local msg="\nPicking yes will create the following files:\n - /home/$NEWUSER/$LOGINRC (run 'startx' when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (login $NEWUSER without password)\n\nTo disable autologin remove these files." - yesno "$_WMLogin" "$_AutoLoginBody\n$msg\n" && AUTOLOGIN=true || AUTOLOGIN=false - PACKAGES="${PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" - WM_PKGS="${WM_PKGS// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" - WM_PKGS+=" xorg-xinit" - EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile" - fi -} - -select_mirrorcmd() -{ - local c - local key="5f29642060ab983b31fdf4c2935d8c56" - - if hash reflector >/dev/null 2>&1; then - MIRROR_CMD="reflector --score 100 -l 50 -f 5 --sort rate --verbose" - yesno "$_MirrorTitle" "$_MirrorSetup" && return 0 - - c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")" - MIRROR_CMD="reflector --country $c --fastest 5 --sort rate --verbose" - - tput cnorm - MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $_MirrorTitle " --inputbox "$_MirrorCmd\n - --score n Limit the list to the n servers with the highest score. - --latest n Limit the list to the n most recently synchronized servers. - --fastest n Return the n fastest mirrors that meet the other criteria. - --sort {age,rate,country,score,delay} - - 'age': Last server synchronization; - 'rate': Download rate; - 'country': Server location; - 'score': MirrorStatus score; - 'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")" - elif hash rankmirrors >/dev/null 2>&1; then - infobox "$_MirrorTitle" "\nQuerying mirrors near your location\n" - c="$(json 'country_code' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_code")" - local w="https://www.archlinux.org/mirrorlist" - if [[ $c ]]; then - if [[ $c =~ (CA|US) ]]; then - MIRROR_CMD="curl -s '$w/?country=US&country=CA&use_mirror_status=on'" - else - MIRROR_CMD="curl -s '$w/?country=${c}&use_mirror_status=on'" - fi - else - MIRROR_CMD="curl -s '$w/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on'" - fi - fi - - return 0 -} - -edit_configs() -{ - tput civis - local choice i=0 - - while true; do - choice=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $_EditTitle " --menu "$_EditBody" 0 0 0 \ - "finished" "exit the installer and reboot" \ - "keyboard" "${EDIT_FILES[keyboard]}" \ - "console" "${EDIT_FILES[console]}" \ - "locale" "${EDIT_FILES[locale]}" \ - "hostname" "${EDIT_FILES[hostname]}" \ - "sudoers" "${EDIT_FILES[sudoers]}" \ - "mkinitcpio" "${EDIT_FILES[mkinitcpio]}" \ - "fstab" "${EDIT_FILES[fstab]}" \ - "crypttab" "${EDIT_FILES[crypttab]}" \ - "bootloader" "${EDIT_FILES[bootloader]}" \ - "pacman" "${EDIT_FILES[pacman]}" \ - "login" "${EDIT_FILES[login]}") - - if [[ $choice == "" || $choice == "finished" ]]; then - [[ $DEBUG == true && -r $DBG ]] && vim $DBG - # when die() is passed 127 it will call: systemctl -i reboot - die 127 - else - local exists="" - for f in $(printf "%s" "${EDIT_FILES[$choice]}"); do - [[ -e ${MNT}$f ]] && exists+=" ${MNT}$f" - done - if [[ $exists ]]; then - vim -O $exists - else - msgbox "$_ErrTitle" "$_NoFileErr" - fi - fi - done -} - -############################################################################### -# package menus - select_packages() { local cur=0 b="" e="" f="" t="" m="" ml="" p="" v="" fn="" to="" s="" x="" @@ -615,7 +535,7 @@ select_packages() tput civis cur=$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_Packages " --default-item $cur \ + --title " Packages " --default-item $cur \ --menu "$_PackageMenu" 0 0 0 \ 1 "Web Browsers" \ 2 "Text Editors" \ @@ -663,10 +583,56 @@ select_packages() return 0 } +select_mirrorcmd() +{ + local c + local key="5f29642060ab983b31fdf4c2935d8c56" + + if hash reflector >/dev/null 2>&1; then + MIRROR_CMD="reflector --score 100 -l 50 -f 5 --sort rate --verbose" + yesno "Mirrorlist" "$_MirrorSetup" && return 0 + + c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")" + MIRROR_CMD="reflector --country $c --fastest 5 --sort rate --verbose" + + tput cnorm + MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ + --title " Mirrorlist " --inputbox "$_MirrorCmd\n + --score n Limit the list to the n servers with the highest score. + --latest n Limit the list to the n most recently synchronized servers. + --fastest n Return the n fastest mirrors that meet the other criteria. + --sort {age,rate,country,score,delay} + + 'age': Last server synchronization; + 'rate': Download rate; + 'country': Server location; + 'score': MirrorStatus score; + 'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")" + elif hash rankmirrors >/dev/null 2>&1; then + infobox "Mirrorlist" "\nQuerying mirrors near your location\n" + c="$(json 'country_code' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_code")" + local w="https://www.archlinux.org/mirrorlist" + if [[ $c ]]; then + if [[ $c =~ (CA|US) ]]; then + MIRROR_CMD="curl -s '$w/?country=US&country=CA&use_mirror_status=on'" + else + MIRROR_CMD="curl -s '$w/?country=${c}&use_mirror_status=on'" + fi + else + MIRROR_CMD="curl -s '$w/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on'" + fi + fi + + return 0 +} + +############################################################################### +# package menus + pkg_browsers() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "firefox" "A popular open-source graphical web browser from Mozilla" $(ofn 'firefox') \ "chromium" "an open-source graphical web browser based on the Blink rendering engine" $(ofn 'chromium') \ "opera" "A Fast and secure, free of charge web browser from Opera Software" $(ofn 'opera') \ @@ -679,7 +645,7 @@ pkg_browsers() pkg_editors() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "neovim" "A fork of Vim aiming to improve user experience, plugins, and GUIs." $(ofn 'neovim') \ "atom" "An open-source text editor developed by GitHub that is licensed under the MIT License" $(ofn 'atom') \ "geany" "A fast and lightweight IDE" $(ofn 'geany') \ @@ -691,7 +657,7 @@ pkg_editors() pkg_files() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "thunar" "A modern file manager for the Xfce Desktop Environment" $(ofn 'thunar') \ "pcmanfm" "A fast and lightweight file manager based in Lxde" $(ofn 'pcmanfm') \ "nautilus" "The default file manager for Gnome" $(ofn 'nautilus') \ @@ -704,7 +670,7 @@ pkg_files() pkg_terms() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "termite" "A minimal VTE-based terminal emulator" $(ofn 'termite') \ "rxvt-unicode" "A unicode enabled rxvt-clone terminal emulator" $(ofn 'rxvt-unicode') \ "xterm" "The standard terminal emulator for the X window system" $(ofn 'xterm') \ @@ -720,7 +686,7 @@ pkg_terms() pkg_media() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "vlc" "A free and open source cross-platform multimedia player" $(ofn 'vlc') \ "mpv" "A media player based on mplayer" $(ofn 'mpv') \ "mpd" "A flexible, powerful, server-side application for playing music" $(ofn 'mpd') \ @@ -738,7 +704,7 @@ pkg_media() pkg_mail() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "thunderbird" "Standalone mail and news reader from mozilla" $(ofn 'thunderbird') \ "geary" "A lightweight email client for the GNOME desktop" $(ofn 'geary') \ "evolution" "Manage your email, contacts and schedule" $(ofn 'evolution') \ @@ -753,7 +719,7 @@ pkg_mail() pkg_prof() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "libreoffice-fresh" "Full featured office suite" $(ofn 'libreoffice-fresh') \ "abiword" "Fully-featured word processor" $(ofn 'abiword') \ "calligra" "A set of applications for productivity" $(ofn 'calligra') \ @@ -772,7 +738,7 @@ pkg_prof() pkg_fonts() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "ttf-hack" "A hand groomed and optically balanced typeface based on Bitstream Vera Mono" $(ofn 'ttf-hack') \ "ttf-anonymous-pro" "A family fixed-width fonts designed with coding in mind" $(ofn 'ttf-anonymous-pro') \ "ttf-font-awesome" "Iconic font designed for Bootstrap" $(ofn 'ttf-font-awesome') \ @@ -785,7 +751,7 @@ pkg_fonts() pkg_viewers() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "evince" "A document viewer" $(ofn 'evince') \ "zathura" "Minimalistic document viewer" $(ofn 'zathura') \ "qpdfview" "A tabbed PDF viewer" $(ofn 'qpdfview') \ @@ -797,7 +763,7 @@ pkg_viewers() pkg_torrent() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "deluge" "A BitTorrent client written in python" $(ofn 'deluge') \ "qbittorrent" "An advanced BitTorrent client" $(ofn 'qbittorrent') \ "transmission-gtk" "Free BitTorrent client GTK+ GUI" $(ofn 'transmission-gtk') \ @@ -809,7 +775,7 @@ pkg_torrent() pkg_sys() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "gnome-disk-utility" "Disk Management Utility" $(ofn 'gnome-disk-utility') \ "gnome-system-monitor" "View current processes and monitor system state" $(ofn 'gnome-system-monitor') \ "qt5ct" "GUI for managing Qt based application themes, icons, and fonts" $(ofn 'qt5ct'))" @@ -819,7 +785,7 @@ pkg_sys() pkg_extra() { local pkgs="" - pkgs="$(checkbox "$_Packages" "$_PackageBody" \ + pkgs="$(checkbox "Packages" "$_PackageBody" \ "steam" "A popular game distribution platform by Valve" $(ofn 'steam') \ "gpick" "Advanced color picker using GTK+ toolkit" $(ofn 'gpick') \ "gcolor2" "A simple GTK+2 color selector" $(ofn 'gcolor2') \ @@ -839,42 +805,41 @@ part_menu() if [[ $# -eq 1 ]]; then device="$1" else - select_device 'root' || return 1 + umount_dir $MNT + select_device || return 1 device="$DEVICE" fi tput civis if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then - choice="$(menubox "$_PartTitle" "$_PartBody" \ - "$_PartShowTree" "Shows output from the lsblk command" \ - "$_PartAuto" "Full device automatic partitioning" \ + choice="$(menubox "Edit Partitions" "$_PartBody" \ + "view partition table" "Shows output from the lsblk command" \ + "auto partition" "Full device automatic partitioning" \ "gparted" "GUI front end to parted" \ "cfdisk" "Curses front end to fdisk" \ "parted" "GNU partition editor" \ - "$_PartWipe" "Wipe data before disposal or sale of a device" \ - "$_Done" "Return to the main menu")" + "secure wipe" "Wipe data before disposal or sale of a device" \ + "done" "return to the main menu")" else - choice="$(menubox "$_PartTitle" "$_PartBody" \ - "$_PartShowTree" "Show output of 'lsblk $device'" \ - "$_PartAuto" "Full device automatic partitioning" \ + choice="$(menubox "Edit Partitions" "$_PartBody" \ + "view partition table" "Shows output from the lsblk command" \ + "auto partition" "Full device automatic partitioning" \ "cfdisk" "Curses front end to fdisk" \ "parted" "GNU partition editor" \ - "$_PartWipe" "Wipe data before disposal or sale of the device" \ - "$_Done" "Return to the main menu")" + "secure wipe" "Wipe data before disposal or sale of the device" \ + "done" "return to the main menu")" fi tput civis - if [[ $choice == "$_Done" || $choice == "" ]]; then + if [[ $choice == "done" || $choice == "" ]]; then return 0 - elif [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then - clear; tput cnorm; $choice "$device" - elif [[ $choice == "$_PartShowTree" ]]; then - msgbox "$_PartTitle" "\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT "$device")\n\n" - elif [[ $choice == "$_PartWipe" ]]; then - yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody" && wipe -Ifrev $device - else + elif [[ $choice == "view partition table" ]]; then + msgbox "Partition Table" "\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT "$device")\n\n" + elif [[ $choice == "secure wipe" ]]; then + yesno "Wipe Partition" "\nWARNING: ALL data on $device $_PartWipeBody" && wipe -Ifrev $device + elif [[ $choice == "auto partition" ]]; then local root_size msg ret table boot_fs root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 { if ($1 ~ "G") { @@ -890,13 +855,11 @@ part_menu() msg="$_PartBody2"; table="gpt"; boot_fs="fat32" fi - if yesno "$_PrepParts" "$_PartBody1 $device $msg ($root_size)$_PartBody3"; then - if auto_partition "$device" "$table" "$boot_fs" "$root_size"; then - return 0 - else - return 1 - fi + if yesno "Auto Partition" "\nWARNING: ALL data on $device $msg ($root_size)$_PartBody3"; then + auto_partition "$device" "$table" "$boot_fs" "$root_size" && return 0 || return 1 fi + else + clear; tput cnorm; $choice "$device" fi part_menu "$device" @@ -904,7 +867,7 @@ part_menu() format_as() { - infobox "$_FSTitle" "\nRunning: ${FS_CMDS[$2]} $1\n" 1 + infobox "Format" "\nRunning: ${FS_CMDS[$2]} $1\n" 1 ${FS_CMDS[$2]} "$1" >/dev/null 2>$ERR errshow "${FS_CMDS[$2]} $1" && FORMATTED+=" $part" } @@ -913,12 +876,25 @@ decr_pcount() { for i in $(printf "%s" "$@"); do if (( COUNT > 0 )); then - PARTS="$(sed "/${i//\//\\/}/d" <<< "$PARTS")" - (( COUNT-- )) + PARTS="$(sed "/${i//\//\\/}/d" <<< "$PARTS")" && (( COUNT-- )) fi done } +dev_tree() +{ + tput civis + local msg + if [[ $IGNORE_DEV != "" ]]; then + msg="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | + awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/')" + else + msg="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | + awk '/disk|part|lvm|crypt|NAME/')" + fi + msgbox "Device Tree" "\n\n$msg\n\n" +} + enable_swap() { if [[ $1 == "$MNT/swapfile" && $SWAP_SIZE ]]; then @@ -934,50 +910,34 @@ enable_swap() return 0 } -device_tree() -{ - tput civis - local msg - if [[ $IGNORE_DEV != "" ]]; then - msg="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | - awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/')" - else - msg="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | - awk '/disk|part|lvm|crypt|NAME/')" - fi - msgbox "$_PrepShowDev" "\n\n$msg\n\n" -} - select_device() { - local dev msg - [[ $1 == 'boot' ]] && msg="$_DevSelTitle for bootloader\n" || umount_dir $MNT - if [[ $DEV_COUNT -eq 1 && $SYS_DEVS ]]; then DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")" elif (( DEV_COUNT > 1 )); then tput civis - DEVICE="$(menubox "$_DevSelTitle " "${msg}$_DevSelBody" $SYS_DEVS)" + if [[ $1 ]]; then + DEVICE="$(menubox "Boot Device" "\nSelect the device to use for bootloader install." $SYS_DEVS)" + else + DEVICE="$(menubox "Select Device" "$_DevSelBody" $SYS_DEVS)" + fi [[ $DEVICE ]] || return 1 - elif [[ $DEV_COUNT -lt 1 && $1 != 'boot' ]]; then - msgbox "$_ErrTitle" "\nNo available devices to use.\n$_Exit"; die 1 + elif [[ $DEV_COUNT -lt 1 && ! $1 ]]; then + msgbox "$_ErrTitle" "\nNo available devices.\n\nExiting..\n"; die 1 fi - [[ $1 == 'boot' ]] && BOOT_DEVICE="$DEVICE" + [[ $1 ]] && BOOT_DEV="$DEVICE" return 0 } confirm_mount() { - local part="$1" mount="$2" - [[ $mount == "$MNT" ]] && local m="/ (root)" || local m="${mount#$MNT}" - - if [[ $(mount) == *"$mount"* ]]; then - infobox "$_MntTitle" "$_MntSucc\nPartition: $part\nMountpoint: $m\n" 1 - decr_pcount $part + if [[ $(mount) == *"$1"* ]]; then + infobox "Mount Success" "\nPartition $1 mounted at $2\n" 1 + decr_pcount $1 else - infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 + infobox "Mount Fail" "\nPartition $1 failed to mount at $2\n" 1 return 1 fi return 0 @@ -1031,7 +991,7 @@ auto_partition() local device="$1" table="$2" boot_fs="$3" size="$4" local dev_info="$(parted -s $device print)" - infobox "$_PrepParts" "\nRemoving partitions on $device and setting table to $table\n" 2 + infobox "Auto Partition" "\nRemoving partitions on $device and setting table to $table\n" 2 # in case the device was previously used for swap swapoff -a @@ -1045,7 +1005,7 @@ auto_partition() parted -s $device mklabel $table >/dev/null 2>&1 fi - infobox "$_PrepParts" "\nCreating a 512M $fs boot partition.\n" 2 + infobox "Auto Partition" "\nCreating a 512M $fs boot partition.\n" 2 if [[ $SYS == "BIOS" ]]; then parted -s $device mkpart primary $fs 1MiB 513MiB >/dev/null 2>&1 else @@ -1053,7 +1013,7 @@ auto_partition() fi sleep 0.5 - BOOT_DEVICE="$device" + BOOT_DEV="$device" AUTO_BOOT_PART=$(lsblk -lno NAME,TYPE $device | awk 'NR == 2 {print "/dev/"$1}') if [[ $SYS == "BIOS" ]]; then @@ -1062,13 +1022,13 @@ auto_partition() mkfs.vfat -F32 $AUTO_BOOT_PART >/dev/null 2>&1 fi - infobox "$_PrepParts" "\nCreating a $size ext4 root partition.\n" 0 + infobox "Auto Partition" "\nCreating a $size ext4 root partition.\n" 0 parted -s $device mkpart primary ext4 513MiB 100% >/dev/null 2>&1 sleep 0.5 AUTO_ROOT_PART="$(lsblk -lno NAME,TYPE $device | awk 'NR == 3 {print "/dev/"$1}')" mkfs.ext4 -q $AUTO_ROOT_PART >/dev/null 2>&1 tput civis; sleep 0.5 - msgbox "$_PrepParts" "\nAuto partitioning complete.\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE $device)\n" + msgbox "Auto Partition" "\nProcess complete.\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE $device)\n" } mount_partition() @@ -1079,11 +1039,12 @@ mount_partition() fs="$(lsblk -lno FSTYPE $part)" mkdir -p "$mountp" - if [[ $fs && ${FS_OPTS[$fs]} && $part != "$BOOT_PART" ]] && select_mount_opts "$part" "$fs"; then + if [[ $fs && ${FS_OPTS[$fs]} && $part != "$BOOT_PART" ]] && select_mntopts "$part" "$fs"; then mount -o $MNT_OPTS "$part" "$mountp" 2>$ERR else mount "$part" "$mountp" 2>$ERR fi + confirm_mount $part "$mountp" || return 1 check_cryptlvm "$part" @@ -1126,20 +1087,20 @@ find_partitions() esac # if there aren't enough partitions show the relevant error message - [[ $err ]] && { msgbox "$_ErrTitle" "$err"; return 1; } + [[ $err ]] && { msgbox "Not Enough Partitions" "$err"; return 1; } return 0 } setup_boot_device() { - infobox "$_PrepMount" "\nSetting device flags for: $BOOT_PART\n" 1 - [[ $BOOT_PART = /dev/nvme* ]] && BOOT_DEVICE="${BOOT_PART%p[1-9]}" || BOOT_DEVICE="${BOOT_PART%[1-9]}" + infobox "Boot Device" "\nSetting device flags for: $BOOT_PART\n" 1 + [[ $BOOT_PART = /dev/nvme* ]] && BOOT_DEV="${BOOT_PART%p[1-9]}" || BOOT_DEV="${BOOT_PART%[1-9]}" BOOT_PART_NUM="${BOOT_PART: -1}" if [[ $SYS == 'UEFI' ]]; then - parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on >/dev/null 2>&1 + parted -s $BOOT_DEV set $BOOT_PART_NUM esp on >/dev/null 2>&1 else - parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on >/dev/null 2>&1 + parted -s $BOOT_DEV set $BOOT_PART_NUM boot on >/dev/null 2>&1 fi return 0 } @@ -1173,25 +1134,25 @@ mount_menu() select_swap() { tput civis - SWAP_PART="$(menubox "$_SelSwpSetup" "$_SelSwpBody" \ - "$_SelSwpNone" "Don't allocate any swap space" \ - "$_SelSwpFile" "Allocate $SYS_MEM of swap at /swapfile" \ + SWAP_PART="$(menubox "Swap Setup" "\nSelect whether to use a swap partition, swapfile, or none." \ + "none" "Don't allocate any swap space" \ + "swapfile" "Allocate $SYS_MEM of swap at /swapfile" \ $PARTS)" - if [[ $SWAP_PART == "" || $SWAP_PART == "$_SelSwpNone" ]]; then + if [[ $SWAP_PART == "" || $SWAP_PART == "none" ]]; then SWAP_PART=""; return 0 - elif [[ $SWAP_PART == "$_SelSwpFile" ]]; then + elif [[ $SWAP_PART == "swapfile" ]]; then tput cnorm local i=0 while ! [[ ${SWAP_SIZE:0:1} =~ [1-9] && ${SWAP_SIZE: -1} =~ (M|G) ]]; do - (( i > 0 )) && msgbox "$_SelSwpSetup Error" "\n$_SelSwpErr $SWAP_SIZE\n" - if ! SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"; then + (( i > 0 )) && msgbox "Swap Setup Error" "\n$_SelSwpErr $SWAP_SIZE\n" + if ! SWAP_SIZE="$(getinput "Swap Setup" "$_SelSwpSize" "$SYS_MEM")"; then SWAP_PART=""; SWAP_SIZE=""; break; return 0 fi (( i++ )) done - enable_swap "$MNT/swapfile" - SWAP_PART="/swapfile" + enable_swap "$MNT/$SWAP_PART" + SWAP_PART="/$SWAP_PART" else enable_swap $SWAP_PART decr_pcount $SWAP_PART @@ -1200,24 +1161,7 @@ select_swap() return 0 } -select_mountpoint() -{ - local err=0 - tput cnorm - while true; do - EXMNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1" "/" nolimit)" - err=$? - (( err == 0 )) || break - if [[ ${EXMNT:0:1} != "/" || ${#EXMNT} -le 1 || $EXMNT =~ \ |\' || $EXMNTS == *"$EXMNT"* ]]; then - msgbox "$_ErrTitle" "$_ExtErrBody" - else - break - fi - done - return $err -} - -select_mount_opts() +select_mntopts() { local part="$1" fs="$2" err=0 local title="${fs^} Mount Options" @@ -1234,7 +1178,7 @@ select_mount_opts() if [[ $MNT_OPTS ]]; then MNT_OPTS="$(sed 's/ /,/g; $s/,$//' <<< "$MNT_OPTS" )" - yesno "$title" "$_MntConfBody $MNT_OPTS\n" && break + yesno "$title" "\nConfirm mount options: $MNT_OPTS\n" && break else err=1; break fi @@ -1243,6 +1187,23 @@ select_mount_opts() return $err } +select_mountpoint() +{ + local err=0 + tput cnorm + while true; do + EXMNT="$(getinput "Extra Mount $part" "$_ExtPartBody1" "/" nolimit)" + err=$? + (( err == 0 )) || break + if [[ ${EXMNT:0:1} != "/" || ${#EXMNT} -le 1 || $EXMNT =~ \ |\' || $EXMNTS == *"$EXMNT"* ]]; then + msgbox "$_ErrTitle" "$_ExtErrBody" + else + break + fi + done + return $err +} + select_filesystem() { local part="$1" fs="" cur_fs="" err=0 @@ -1250,11 +1211,11 @@ select_filesystem() [[ $part == "$ROOT_PART" && $ROOT_PART == "$AUTO_ROOT_PART" && ! $LUKS && ! $LVM ]] && return 0 while true; do - local msg="\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-none}\nDefault: ext4" tput civis if [[ $cur_fs && ( $part != "$ROOT_PART" || $FORMATTED == *"$part"* ) ]]; then - fs="$(menubox "$_FSTitle: $part" "$msg" \ - "$_Skip" "Do not format this partition" \ + fs="$(menubox "Filesystem" \ + "\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-none}\nDefault: ext4" \ + "skip" "do not format this partition" \ "ext4" "${FS_CMDS[ext4]}" \ "ext3" "${FS_CMDS[ext3]}" \ "ext2" "${FS_CMDS[ext2]}" \ @@ -1266,10 +1227,9 @@ select_filesystem() "nilfs2" "${FS_CMDS[nilfs2]}" \ "reiserfs" "${FS_CMDS[reiserfs]}")" - [[ $fs == "$_Skip" ]] && break + [[ $fs == "skip" ]] && break else - local msg="\nSelect which filesystem to use for: $part\n\nDefault: ext4" - fs="$(menubox "$_FSTitle: $part" "$msg" \ + fs="$(menubox "Filesystem" "\nSelect which filesystem to use for: $part\n\nDefault: ext4" \ "ext4" "${FS_CMDS[ext4]}" \ "ext3" "${FS_CMDS[ext3]}" \ "ext2" "${FS_CMDS[ext2]}" \ @@ -1282,10 +1242,10 @@ select_filesystem() fi [[ $fs ]] || { err=1; break; } - yesno "$_FSTitle" "\nFormat $part as $fs?\n" && break + yesno "Filesystem" "\nFormat $part as $fs?\n" && break done (( err == 0 )) || return $err - [[ $fs == "$_Skip" ]] || format_as "$part" "$fs" + [[ $fs == "skip" ]] || format_as "$part" "$fs" } select_efi_partition() @@ -1297,13 +1257,13 @@ select_efi_partition() BOOT_PART="$AUTO_BOOT_PART" return 0 # were done here else - BOOT_PART="$(menubox "$_PrepMount" "$_SelUefiBody" $PARTS)" + BOOT_PART="$(menubox "EFI Partition" "$_SelUefiBody" $PARTS)" fi [[ $BOOT_PART ]] || return 1 if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then - local msg="$_FormUefiBody $BOOT_PART $_FormBootBody" - if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then + local msg="\nIMPORTANT: The EFI partition $BOOT_PART $_FormBootBody" + if yesno "Format EFI Partition" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then format_as "$BOOT_PART" "vfat" sleep 1 fi @@ -1322,16 +1282,16 @@ select_boot_partition() BOOT_PART="$AUTO_BOOT_PART" return 0 # were done here elif [[ $LUKS && ! $LVM ]]; then - BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosLuksBody" $PARTS)" + BOOT_PART="$(menubox "Boot Partition" "$_SelBiosLuksBody" $PARTS)" [[ $BOOT_PART ]] || return 1 else - BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosBody" "$_Skip" "-" $PARTS)" - [[ $BOOT_PART == "" || $BOOT_PART == "$_Skip" ]] && { BOOT_PART=""; return 0; } + BOOT_PART="$(menubox "Boot Partition" "$_SelBiosBody" "skip" "don't use a separate boot" $PARTS)" + [[ $BOOT_PART == "" || $BOOT_PART == "skip" ]] && { BOOT_PART=""; return 0; } fi if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then - local msg="$_FormBiosBody $BOOT_PART $_FormBootBody" - if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then + local msg="\nIMPORTANT: The boot partition $BOOT_PART $_FormBootBody" + if yesno "Format Boot Partition" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then format_as "$BOOT_PART" "ext4" sleep 1 fi @@ -1348,7 +1308,7 @@ select_root_partition() if (( COUNT == 1 )); then ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$PARTS")" else - ROOT_PART="$(menubox "$_PrepMount" "$_SelRootBody" $PARTS)" + ROOT_PART="$(menubox "Mount Root" "$_SelRootBody" $PARTS)" [[ $ROOT_PART ]] || return 1 fi @@ -1362,8 +1322,8 @@ select_extra_partitions() local part while (( COUNT > 0 )); do tput civis - part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)" - if [[ $part == "$_Done" || $part == "" ]]; then + part="$(menubox "Mount Boot" "$_ExtPartBody" "done" "return to the main menu" $PARTS)" + if [[ $part == "done" || $part == "" ]]; then break elif select_filesystem "$part" && select_mountpoint && mount_partition "$part" "$EXMNT"; then EXMNTS="$EXMNTS $part: $EXMNT" @@ -1378,7 +1338,7 @@ select_extra_partitions() ############################################################################### # installation -install() +install_main() { clear tput cnorm @@ -1387,18 +1347,51 @@ install() genfstab -U $MNT >$MNT/etc/fstab 2>$ERR errshow 1 "genfstab -U $MNT >$MNT/etc/fstab" [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab - mirrorlist_sort - package_operations - run_mkinitcpio - install_bootloader + install_mirrorlist + install_packages + install_mkinitcpio + install_boot printf "Setting hardware clock with: hwclock --systohc --utc\n" chrun "hwclock --systohc --utc" || chrun "hwclock --systohc --utc --directisa" - create_user - login_manager + install_user + install_login printf "Setting ownership of /home/$NEWUSER\n" chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" sleep 1 - edit_configs + + while true; do + tput civis + choice=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ + --title " Finalization " --menu "$_EditBody" 0 0 0 \ + "finished" "exit the installer and reboot" \ + "keyboard" "${EDIT_FILES[keyboard]}" \ + "console" "${EDIT_FILES[console]}" \ + "locale" "${EDIT_FILES[locale]}" \ + "hostname" "${EDIT_FILES[hostname]}" \ + "sudoers" "${EDIT_FILES[sudoers]}" \ + "mkinitcpio" "${EDIT_FILES[mkinitcpio]}" \ + "fstab" "${EDIT_FILES[fstab]}" \ + "crypttab" "${EDIT_FILES[crypttab]}" \ + "bootloader" "${EDIT_FILES[bootloader]}" \ + "pacman" "${EDIT_FILES[pacman]}" \ + "login" "${EDIT_FILES[login]}") + + if [[ $choice == "" || $choice == "finished" ]]; then + [[ $DEBUG == true && -r $DBG ]] && vim $DBG + # when die() is passed 127 it will call: systemctl -i reboot + die 127 + else + local exists="" + for f in $(printf "%s" "${EDIT_FILES[$choice]}"); do + [[ -e ${MNT}$f ]] && exists+=" ${MNT}$f" + done + if [[ $exists ]]; then + vim -O $exists + else + msgbox "File Error" "\nFile(s) do not exist.\n" + fi + fi + done } install_base() @@ -1407,7 +1400,7 @@ install_base() rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR errshow 1 "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/" else - mirrorlist_sort + install_mirrorlist pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt) 2>$ERR errshow 1 "pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt)" fi @@ -1435,7 +1428,7 @@ EOF if [[ -e /run/archiso/sfs/airootfs ]]; then printf "Copying vmlinuz and ucode to /boot\n" [[ $KERNEL == 'linux' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux - [[ $UCODE ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/${UCODE}.img + [[ $UCODE ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/$UCODE.img fi printf "Copying network settings to /etc\n" @@ -1498,7 +1491,7 @@ EOF } -create_user() +install_user() { printf "Setting root password\n" chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR @@ -1549,13 +1542,34 @@ al-info EOF fi - [[ $INSTALL_WMS == *dwm* ]] && suckless_install + [[ $INSTALL_WMS == *dwm* ]] && install_suckless [[ $LOGIN_WM =~ (startkde|gnome-session) ]] && sed -i '/super/d' $HOME/.xprofile /root/.xprofile return 0 } -setup_xinit() +install_login() +{ + printf "Setting up $LOGIN_TYPE\n" + SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d" + + # remove welcome message + sed -i '/printf/d' $MNT/root/.zshrc + + # remove unneeded shell files from installation + case $MYSHELL in + "/bin/bash") + rm -rf $MNT/home/$NEWUSER/.{zsh,mksh}* $MNT/root/.{zsh,mksh}* ;; + "/usr/bin/mksh") + rm -rf $MNT/home/$NEWUSER/.{zsh,bash}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{zsh,bash}* $MNT/root/.inputrc ;; + "/usr/bin/zsh") + rm -rf $MNT/home/$NEWUSER/.{bash,mksh}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{bash,mksh}* $MNT/root/.inputrc ;; + esac + + install_${LOGIN_TYPE:-xinit} +} + +install_xinit() { if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' $MNT/home/$NEWUSER/.xinitrc; then sed -i "/exec/ c exec ${LOGIN_WM}" $MNT/home/$NEWUSER/.xinitrc @@ -1581,7 +1595,7 @@ EOF fi } -setup_lightdm() +install_lightdm() { rm -rf $SERVICE rm -rf $MNT/home/$NEWUSER/.{xinitrc,profile,zprofile,bash_profile} @@ -1601,55 +1615,7 @@ position=30%,end 50%,end EOF } -login_manager() -{ - printf "Setting up $LOGIN_TYPE\n" - SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d" - - # remove welcome message - sed -i '/printf/d' $MNT/root/.zshrc - - # remove unneeded shell files from installation - case $MYSHELL in - "/bin/bash") - rm -rf $MNT/home/$NEWUSER/.{zsh,mksh}* $MNT/root/.{zsh,mksh}* ;; - "/usr/bin/mksh") - rm -rf $MNT/home/$NEWUSER/.{zsh,bash}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{zsh,bash}* $MNT/root/.inputrc ;; - "/usr/bin/zsh") - rm -rf $MNT/home/$NEWUSER/.{bash,mksh}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{bash,mksh}* $MNT/root/.inputrc ;; - esac - - if [[ $LOGIN_TYPE == 'lightdm' ]]; then - setup_lightdm - else - setup_xinit - fi -} - -run_mkinitcpio() -{ - local add="" - [[ $LUKS && $LUKS_PASS && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile - [[ $LUKS ]] && add="encrypt" - [[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; } - sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf - chrun "mkinitcpio -p $KERNEL" 2>$ERR - errshow 1 "mkinitcpio -p $KERNEL" -} - -mirrorlist_sort() -{ - printf "Sorting the mirrorlist\n" - if hash reflector >/dev/null 2>&1; then - $MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist --verbose || - reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist - else - { eval $MIRROR_CMD || curl -s 'https://www.archlinux.org/mirrorlist/all/'; } | - sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -v -t -n 10 - > $MNT/etc/pacman.d/mirrorlist - fi -} - -package_operations() +install_packages() { local rmpkg="archlabs-installer" local inpkg="$BASE_PKGS $PACKAGES $USER_PKGS" @@ -1685,7 +1651,7 @@ package_operations() return 0 } -suckless_install() +install_suckless() { # install and setup dwm printf "Installing and setting up dwm\n" @@ -1706,235 +1672,33 @@ suckless_install() fi } +install_mirrorlist() +{ + printf "Sorting the mirrorlist\n" + if hash reflector >/dev/null 2>&1; then + $MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist --verbose || + reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist + else + { eval $MIRROR_CMD || curl -s 'https://www.archlinux.org/mirrorlist/all/'; } | + sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -v -t -n 10 - > $MNT/etc/pacman.d/mirrorlist + fi +} + +install_mkinitcpio() +{ + local add="" + [[ $LUKS && $LUKS_PASS && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile + [[ $LUKS ]] && add="encrypt" + [[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; } + sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf + chrun "mkinitcpio -p $KERNEL" 2>$ERR + errshow 1 "mkinitcpio -p $KERNEL" +} + ############################################################################### # bootloader setup -setup_boot() -{ - tput civis - if [[ $SYS == 'BIOS' ]]; then - BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" \ - "grub" "The Grand Unified Bootloader, standard among many Linux distributions" \ - "syslinux" "A collection of boot loaders for booting drives, CDs, or over the network")" - - else - BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" \ - "systemd-boot" "A simple UEFI boot manager which executes configured EFI images" \ - "grub" "The Grand Unified Bootloader, standard among many Linux distributions" \ - "refind-efi" "A UEFI boot manager that aims to be platform neutral and simplify multi-boot" \ - "syslinux" "A collection of boot loaders for booting drives, CDs, or over the network (no chainloading support)")" - - fi - - [[ $BOOTLDR ]] || return 1 - if [[ $BOOT_PART ]]; then - mount_partition "$BOOT_PART" "/boot" && SEP_BOOT=true || return 1 - setup_boot_device - fi - setup_${BOOTLDR} || return 1 -} - -setup_grub() -{ - EDIT_FILES[bootloader]="/etc/default/grub" - - if [[ $SYS == 'BIOS' ]]; then - [[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; } - BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEVICE" - else - if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then - luks_pass "$_LuksOpen" 1 || return 1 - fi - BCMDS[grub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && - grub-install --recheck --force --target=x86_64-efi --efi-directory=/boot --bootloader-id=$DIST" - - grep -q /sys/firmware/efi/efivars <<< "$(mount)" || mount -t efivarfs efivarfs /sys/firmware/efi/efivars - fi - - BCMDS[grub]="mkdir -p /run/udev /run/lvm && - mount --bind /hostrun/udev /run/udev && - mount --bind /hostrun/lvm /run/lvm && - ${BCMDS[grub]} && - grub-mkconfig -o /boot/grub/grub.cfg && - sleep 1 && umount /run/udev /run/lvm" - - return 0 -} - -setup_syslinux() -{ - if [[ $SYS == 'BIOS' ]]; then - EDIT_FILES[bootloader]="/boot/syslinux/syslinux.cfg" - else - EDIT_FILES[bootloader]="/boot/EFI/syslinux/syslinux.cfg" - BCMDS[syslinux]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && - efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST -v" - fi -} - -setup_systemd-boot() -{ - EDIT_FILES[bootloader]="/boot/loader/entries/$DIST.conf" - BCMDS[systemd-boot]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && bootctl --path=/boot install" -} - -setup_refind-efi() -{ - EDIT_FILES[bootloader]="/boot/refind_linux.conf" - BCMDS[refind-efi]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && refind-install" -} - -prerun_refind-efi() -{ - cat > $MNT/boot/refind_linux.conf << EOF -"$DIST Linux" "root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && - printf "%s " "$LUKS_DEV")rw add_efi_memmap $([[ $UCODE ]] && - printf "initrd=/%s " "$UCODE")initrd=/initramfs-%v.img" -"$DIST Linux Fallback" "root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && - printf "%s " "$LUKS_DEV")rw add_efi_memmap $([[ $UCODE ]] && - printf "initrd=/%s " "$UCODE")initrd=/initramfs-%v-fallback.img" -EOF - mkdir -p $MNT/etc/pacman.d/hooks - cat > $MNT/etc/pacman.d/hooks/refind.hook << EOF -[Trigger] -Operation = Upgrade -Type = Package -Target = refind-efi - -[Action] -Description = Updating rEFInd on ESP -When = PostTransaction -Exec = /usr/bin/refind-install -EOF -} - -prerun_grub() -{ - sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; - s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub - if [[ $LUKS_DEV ]]; then - sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; - s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub 2>$ERR - errshow 1 "sed -i 's~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; - s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g' $MNT/etc/default/grub" - fi - if [[ $SYS == 'BIOS' && $LVM && $SEP_BOOT == false ]]; then - sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $MNT/etc/default/grub 2>$ERR - errshow 1 "sed -i 's/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g' $MNT/etc/default/grub" - fi - - # setup for os-prober module - mkdir -p /run/lvm - mkdir -p /run/udev - mkdir -p $MNT/hostrun/lvm - mkdir -p $MNT/hostrun/udev - mount --bind /run/lvm $MNT/hostrun/lvm - mount --bind /run/udev $MNT/hostrun/udev - - return 0 -} - -prerun_systemd-boot() -{ - mkdir -p $MNT/boot/loader/entries - cat > $MNT/boot/loader/loader.conf << EOF -default $DIST -timeout 5 -editor no -EOF - cat > $MNT/boot/loader/entries/$DIST.conf << EOF -title $DIST Linux -linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") -initrd /initramfs-$KERNEL.img -options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw -EOF - cat > $MNT/boot/loader/entries/$DIST-fallback.conf << EOF -title $DIST Linux Fallback -linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") -initrd /initramfs-$KERNEL-fallback.img -options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw -EOF - mkdir -p $MNT/etc/pacman.d/hooks - cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook << EOF -[Trigger] -Type = Package -Operation = Upgrade -Target = systemd - -[Action] -Description = Updating systemd-boot -When = PostTransaction -Exec = /usr/bin/bootctl update -EOF - systemd-machine-id-setup --root="$MNT" - return 0 -} - -prerun_syslinux() -{ - local cfgdir="$MNT/boot/syslinux" cfgsrcdir="/usr/lib/syslinux/bios" - if [[ $SYS == 'UEFI' ]]; then - cfgdir="$MNT/boot/EFI/syslinux"; cfgsrcdir="/usr/lib/syslinux/efi64/" - fi - - mkdir -pv $cfgdir - cp -rfv $cfgsrcdir/* $cfgdir/ - cat > $cfgdir/syslinux.cfg << EOF -UI vesamenu.c32 -MENU TITLE $DIST Boot Menu -MENU BACKGROUND splash.png -TIMEOUT 50 -DEFAULT $DIST - -# see: https://www.syslinux.org/wiki/index.php/Comboot/menu.c32 -MENU WIDTH 78 -MENU MARGIN 4 -MENU ROWS 4 -MENU VSHIFT 10 -MENU TIMEOUTROW 13 -MENU TABMSGROW 14 -MENU CMDLINEROW 14 -MENU HELPMSGROW 16 -MENU HELPMSGENDROW 29 -MENU COLOR border 30;44 #40ffffff #a0000000 std -MENU COLOR title 1;36;44 #9033ccff #a0000000 std -MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all -MENU COLOR unsel 37;44 #50ffffff #a0000000 std -MENU COLOR help 37;40 #c0ffffff #a0000000 std -MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std -MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std -MENU COLOR msg07 37;40 #90ffffff #a0000000 std -MENU COLOR tabmsg 31;40 #30ffffff #00000000 std - -LABEL $DIST -MENU LABEL $DIST Linux -LINUX ../vmlinuz-$KERNEL -APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw -INITRD $([[ $UCODE ]] && printf "%s" "../$UCODE.img,")../initramfs-$KERNEL.img - -LABEL ${DIST}fallback -MENU LABEL $DIST Linux Fallback -LINUX ../vmlinuz-$KERNEL -APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw -INITRD $([[ $UCODE ]] && printf "%s" "../$UCODE.img,")../initramfs-$KERNEL-fallback.img - -# examples of chainloading other bootloaders - -#LABEL grub2 -#MENU LABEL Grub2 -#COM32 chain.c32 -#APPEND file=../grub/boot.img - -#LABEL windows -#MENU LABEL Windows -#COM32 chain.c32 -#APPEND hd0 3 - -EOF - return 0 -} - -install_bootloader() +install_boot() { if [[ $ROOT_PART == */dev/mapper* ]]; then ROOT_PART_ID="$ROOT_PART" @@ -1982,7 +1746,7 @@ install_bootloader() cp -rf $MNT/boot/EFI/syslinux/* $MNT/boot/EFI/BOOT/ cp -f $MNT/boot/EFI/syslinux/syslinux.efi $MNT/boot/EFI/BOOT/BOOTX64.EFI elif [[ $BOOTLDR == 'refind-efi' ]]; then - sed -i '/#extra_kernel_version_strings/ c extra_kernel_version_strings linux-hardened,linux-zen,linux-lts,linux' + sed -i '/#extra_kernel_version_strings/ c extra_kernel_version_strings linux-hardened,linux-zen,linux-lts,linux' $MNT/boot/EFI/refind/refind.conf cp -fv $MNT/boot/EFI/refind/refind_x64.efi $MNT/boot/EFI/BOOT/BOOTX64.EFI fi fi @@ -1990,6 +1754,228 @@ install_bootloader() return 0 } +setup_boot() +{ + tput civis + if [[ $SYS == 'BIOS' ]]; then + BOOTLDR="$(menubox "Bootloader" "\nSelect which bootloader to use." \ + "grub" "The Grand Unified Bootloader, standard among many Linux distributions" \ + "syslinux" "A collection of boot loaders for booting drives, CDs, or over the network")" + + else + BOOTLDR="$(menubox "Bootloader" "\nSelect which bootloader to use." \ + "systemd-boot" "A simple UEFI boot manager which executes configured EFI images" \ + "grub" "The Grand Unified Bootloader, standard among many Linux distributions" \ + "refind-efi" "A UEFI boot manager that aims to be platform neutral and simplify multi-boot" \ + "syslinux" "A collection of boot loaders for booting drives, CDs, or over the network (no chainloading support)")" + + fi + + [[ $BOOTLDR ]] || return 1 + if [[ $BOOT_PART ]]; then + mount_partition "$BOOT_PART" "/boot" && SEP_BOOT=true || return 1 + setup_boot_device + fi + setup_${BOOTLDR} || return 1 +} + +setup_grub() +{ + EDIT_FILES[bootloader]="/etc/default/grub" + + if [[ $SYS == 'BIOS' ]]; then + [[ $BOOT_DEV ]] || { select_device 1 || return 1; } + BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEV" + else + if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then + luks_pass "$_LuksOpen" 1 || return 1 + fi + BCMDS[grub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && + grub-install --recheck --force --target=x86_64-efi --efi-directory=/boot --bootloader-id=$DIST" + + grep -q /sys/firmware/efi/efivars <<< "$(mount)" || mount -t efivarfs efivarfs /sys/firmware/efi/efivars + fi + + BCMDS[grub]="mkdir -p /run/udev /run/lvm && + mount --bind /hostrun/udev /run/udev && + mount --bind /hostrun/lvm /run/lvm && + ${BCMDS[grub]} && + grub-mkconfig -o /boot/grub/grub.cfg && + sleep 1 && umount /run/udev /run/lvm" + + return 0 +} + +setup_syslinux() +{ + if [[ $SYS == 'BIOS' ]]; then + EDIT_FILES[bootloader]="/boot/syslinux/syslinux.cfg" + else + EDIT_FILES[bootloader]="/boot/EFI/syslinux/syslinux.cfg" + BCMDS[syslinux]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && + efibootmgr -c -d $BOOT_DEV -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST -v" + fi +} + +setup_refind-efi() +{ + EDIT_FILES[bootloader]="/boot/refind_linux.conf" + BCMDS[refind-efi]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && refind-install" +} + +setup_systemd-boot() +{ + EDIT_FILES[bootloader]="/boot/loader/entries/$DIST.conf" + BCMDS[systemd-boot]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars || true && bootctl --path=/boot install" +} + +prerun_grub() +{ + sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; + s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub + if [[ $LUKS_DEV ]]; then + sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; + s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub 2>$ERR + errshow 1 "sed -i 's~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; + s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g' $MNT/etc/default/grub" + fi + if [[ $SYS == 'BIOS' && $LVM && $SEP_BOOT == false ]]; then + sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $MNT/etc/default/grub 2>$ERR + errshow 1 "sed -i 's/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g' $MNT/etc/default/grub" + fi + + # setup for os-prober module + mkdir -p /run/lvm + mkdir -p /run/udev + mkdir -p $MNT/hostrun/lvm + mkdir -p $MNT/hostrun/udev + mount --bind /run/lvm $MNT/hostrun/lvm + mount --bind /run/udev $MNT/hostrun/udev + + return 0 +} + +prerun_syslinux() +{ + local c="$MNT/boot/syslinux" s="/usr/lib/syslinux/bios" d=".." + if [[ $SYS == 'UEFI' ]]; then + c="$MNT/boot/EFI/syslinux"; s="/usr/lib/syslinux/efi64/"; d="" + fi + + mkdir -pv $c && cp -rfv $s/* $c/ && cp -f $RUN/syslinux/splash.png $c/ + cat > $c/syslinux.cfg << EOF +UI vesamenu.c32 +MENU TITLE $DIST Boot Menu +MENU BACKGROUND splash.png +TIMEOUT 50 +DEFAULT $DIST + +# see: https://www.syslinux.org/wiki/index.php/Comboot/menu.c32 +MENU WIDTH 78 +MENU MARGIN 4 +MENU ROWS 4 +MENU VSHIFT 10 +MENU TIMEOUTROW 13 +MENU TABMSGROW 14 +MENU CMDLINEROW 14 +MENU HELPMSGROW 16 +MENU HELPMSGENDROW 29 +MENU COLOR border 30;44 #40ffffff #a0000000 std +MENU COLOR title 1;36;44 #9033ccff #a0000000 std +MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all +MENU COLOR unsel 37;44 #50ffffff #a0000000 std +MENU COLOR help 37;40 #c0ffffff #a0000000 std +MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std +MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std +MENU COLOR msg07 37;40 #90ffffff #a0000000 std +MENU COLOR tabmsg 31;40 #30ffffff #00000000 std + +LABEL $DIST +MENU LABEL $DIST Linux +LINUX $d/vmlinuz-$KERNEL +APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw +INITRD $([[ $UCODE ]] && printf "%s" "$d/$UCODE.img,")$d/initramfs-$KERNEL.img + +LABEL ${DIST}fallback +MENU LABEL $DIST Linux Fallback +LINUX $d/vmlinuz-$KERNEL +APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw +INITRD $([[ $UCODE ]] && printf "%s" "$d/$UCODE.img,")$d/initramfs-$KERNEL-fallback.img +$([[ $SYS == 'BIOS' ]] && printf "\n%s" "# examples of chainloading other bootloaders + +#LABEL grub2 +#MENU LABEL Grub2 +#COM32 chain.c32 +#APPEND file=$d/grub/boot.img + +#LABEL windows +#MENU LABEL Windows +#COM32 chain.c32 +#APPEND hd0 3") +EOF + return 0 +} + +prerun_refind-efi() +{ + cat > $MNT/boot/refind_linux.conf << EOF +"$DIST Linux" "root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && + printf "%s " "$LUKS_DEV")rw add_efi_memmap $([[ $UCODE ]] && + printf "initrd=%s " "/$UCODE.img")initrd=/initramfs-$KERNEL.img" +"$DIST Linux Fallback" "root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && + printf "%s " "$LUKS_DEV")rw add_efi_memmap $([[ $UCODE ]] && + printf "initrd=%s " "/$UCODE.img")initrd=/initramfs-$KERNEL-fallback.img" +EOF + mkdir -p $MNT/etc/pacman.d/hooks + cat > $MNT/etc/pacman.d/hooks/refind.hook << EOF +[Trigger] +Operation = Upgrade +Type = Package +Target = refind-efi + +[Action] +Description = Updating rEFInd on ESP +When = PostTransaction +Exec = /usr/bin/refind-install +EOF +} + +prerun_systemd-boot() +{ + mkdir -p $MNT/boot/loader/entries + cat > $MNT/boot/loader/loader.conf << EOF +default $DIST +timeout 5 +editor no +EOF + cat > $MNT/boot/loader/entries/$DIST.conf << EOF +title $DIST Linux +linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") +initrd /initramfs-$KERNEL.img +options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw +EOF + cat > $MNT/boot/loader/entries/$DIST-fallback.conf << EOF +title $DIST Linux Fallback +linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") +initrd /initramfs-$KERNEL-fallback.img +options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw +EOF + mkdir -p $MNT/etc/pacman.d/hooks + cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook << EOF +[Trigger] +Type = Package +Operation = Upgrade +Target = systemd + +[Action] +Description = Updating systemd-boot +When = PostTransaction +Exec = /usr/bin/bootctl update +EOF + systemd-machine-id-setup --root="$MNT" + return 0 +} + ############################################################################### # lvm functions @@ -2000,16 +1986,21 @@ lvm_menu() local choice choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_PrepLVM " --menu "$_LvmMenu" 0 0 0 \ - "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \ - "$_LvmDelVG" "vgremove -f" \ - "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \ - "$_Back" "Return to the main menu")" + --title " Logical Volume Management " --menu "$_LvmMenu" 0 0 0 \ + "$_LvmNew" "vgcreate -f, lvcreate -L -n" \ + "$_LvmDel" "vgremove -f" \ + "$_LvmDelAll" "lvrmeove, vgremove, pvremove -f" \ + "back" "return to the main menu")" case $choice in - "$_LvmCreateVG") lvm_create || return 1 ;; - "$_LvmDelVG") lvm_del_vg ;; - "$_LvMDelAll") lvm_del_all ;; + "$_LvmNew") lvm_create || return 1 ;; + "$_LvmDelVG") + if lvm_show_vg && yesno "$_LvmDelVG" "$_LvmDelQ"; then + vgremove -f "$DEL_VG" >/dev/null 2>&1 + fi + lvm_menu + ;; + "$_LvMDelAll") lvm_del_all ;; esac return 0 @@ -2022,7 +2013,7 @@ lvm_detect() VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)" if [[ $VOLUMES && $VOLUME_GROUP && $PHYSICAL_VOLUMES ]]; then - infobox "$_PrepLVM" "$_LvmDetBody" 1 + infobox "Logical Volume Management" "$_LvmDetBody" 1 modprobe dm-mod >/dev/null 2>$ERR errshow 'modprobe dm-mod' vgscan >/dev/null 2>&1 @@ -2039,14 +2030,14 @@ lvm_show_vg() done [[ $VOL_GROUP_LIST == "" ]] && { msgbox "$_ErrTitle" "$_LvmVGErr"; return 1; } tput civis - DEL_VG="$(menubox "$_PrepLVM" "$_LvmSelVGBody" $VOL_GROUP_LIST)" + DEL_VG="$(menubox "Logical Volume Management" "$_LvmSelVGBody" $VOL_GROUP_LIST)" [[ $DEL_VG ]] } get_lv_size() { tput cnorm - local ttl=" $_LvmCreateVG (LV:$VOL_COUNT) " + local ttl=" $_LvmNew (LV:$VOL_COUNT) " local msg="${VOLUME_GROUP}: ${GROUP_SIZE}$GROUP_SIZE_TYPE (${VGROUP_MB}MB $_LvmLvSizeBody1).$_LvmLvSizeBody2" VOLUME_SIZE="$(getinput "$ttl" "$msg" "")" [[ $VOLUME_SIZE ]] || return 1 @@ -2076,7 +2067,7 @@ get_lv_size() fi if (( ERR_SIZE == 1 )); then - msgbox "$_ErrTitle" "$_LvmLvSizeErrBody" + msgbox "LVM Size Error" "$_LvmLvSizeErrBody" get_lv_size || return 1 fi @@ -2090,7 +2081,7 @@ lvm_volume_name() while true; do tput cnorm - name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$msg" "$default" nolimit)" + name="$(getinput "$_LvmNew (LV:$VOL_COUNT)" "\n$msg" "$default" nolimit)" [[ $name ]] || { err=1; break; } if [[ ${name:0:1} == "/" || ${#name} -eq 0 || $name =~ \ |\' ]] || grep -q "$name" <<< "$(lsblk)"; then msgbox "$_ErrTitle" "$_LvmLvNameErrBody" @@ -2109,7 +2100,7 @@ lvm_group_name() while true; do tput cnorm - group="$(getinput "$_LvmCreateVG" "$_LvmNameVgBody" "VolGroup" nolimit)" + group="$(getinput "$_LvmNew" "$_LvmNameVgBody" "VolGroup" nolimit)" [[ $group ]] || { err=1; break; } if [[ ${group:0:1} == "/" || ${#group} -eq 0 || $group =~ \ |\' ]] || grep -q "$group" <<< "$(lsblk)"; then msgbox "$_ErrTitle" "$_LvmNameVgErr" @@ -2130,24 +2121,13 @@ lvm_extra_lvs() lvm_volume_name "$_LvmLvNameBody1" && get_lv_size || { err=1; break; } lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME" || { err=1; break; } - msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$_Done Logical Volume (LV) $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2.\n" + msgbox "$_LvmNew (LV:$VOL_COUNT)" "\nDone, logical volume (LV) $VOLUME_NAME ($VOLUME_SIZE) has been created.\n" (( VOL_COUNT-- )) done return $err } -lvm_volumes() -{ - VOL_COUNT=$(dialog --cr-wrap --no-cancel --stdout \ - --backtitle "$BT" --title " $_LvmCreateVG " \ - --radiolist "$_LvmLvNumBody1 $VOLUME_GROUP\n$_LvmLvNumBody2" 0 0 0 \ - "1" "-" off "2" "-" off "3" "-" off "4" "-" off "5" "-" off \ - "6" "-" off "7" "-" off "8" "-" off "9" "-" off) - - [[ $VOL_COUNT ]] -} - lvm_partitions() { find_partitions 'part|crypt' || return 1 @@ -2155,7 +2135,7 @@ lvm_partitions() tput civis LVM_PARTS=($(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $_LvmCreateVG " --checklist "$_LvmPvSelBody" 0 0 0 $PARTS)) + --title " $_LvmNew " --checklist "$_LvmPvSelBody" 0 0 0 $PARTS)) (( ${#LVM_PARTS[@]} >= 1 )) } @@ -2165,7 +2145,7 @@ lvm_mkgroup() lvm_group_name || return 1 local msg="$_LvmPvConfBody1 $VOLUME_GROUP\n\n$_LvmPvConfBody2" - while ! yesno "$_LvmCreateVG" "$msg ${LVM_PARTS[*]}\n"; do + while ! yesno "$_LvmNew" "$msg ${LVM_PARTS[*]}\n"; do lvm_partitions || { break; return 1; } lvm_group_name || { break; return 1; } done @@ -2187,9 +2167,7 @@ lvm_mkgroup() else VGROUP_MB=$GROUP_SIZE fi - - local msg="$_LvmPvDoneBody1 $VOLUME_GROUP ($GROUP_SIZE $GROUP_SIZE_TYPE)" - msgbox "$_LvmCreateVG" "$msg $_LvmPvDoneBody2\n" + msgbox "$_LvmNew" "\nVolume group: $VOLUME_GROUP ($GROUP_SIZE $GROUP_SIZE_TYPE) has been created\n" } lvm_create() @@ -2198,21 +2176,18 @@ lvm_create() umount_dir $MNT lvm_partitions || return 1 lvm_mkgroup || return 1 - lvm_volumes || return 1 + VOL_COUNT=$(menubox "$_LvmNew" "$_LvmLvNumBody1 $VOLUME_GROUP\n$_LvmLvNumBody2" 0 0 0 \ + "1" "-" "2" "-" "3" "-" "4" "-" "5" "-" "6" "-" "7" "-" "8" "-" "9" "-") + + [[ $VOL_COUNT ]] || return 1 + lvm_extra_lvs || return 1 lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VGROUP_MB}MB)" || return 1 lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR errshow "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME" || return 1 LVM='logical volume'; tput civis; sleep 0.5 - local msg="\n$_Done $_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2.\n" - msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n" -} - -lvm_del_vg() -{ - if lvm_show_vg && yesno "$_LvmDelVG" "$_LvmDelQ"; then - vgremove -f "$DEL_VG" >/dev/null 2>&1 - fi + local msg="\nDone, volume: $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) has been created.\n" + msgbox "$_LvmNew (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n" } lvm_del_all() @@ -2221,7 +2196,7 @@ lvm_del_all() VOLUME_GROUP="$(vgs -o vg_name --noheading 2>/dev/null)" VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)" - if yesno "$_LvMDelAll" "$_LvmDelQ"; then + if yesno "$_LvmDelAll" "$_LvmDelQ"; then for i in $VOLUMES; do lvremove -f "/dev/mapper/$i" >/dev/null 2>&1 done @@ -2242,12 +2217,12 @@ luks_menu() { tput civis local choice - choice="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepLUKS " \ + choice="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " LUKS Encryption " \ --menu "${_LuksMenuBody}${_LuksMenuBody2}${_LuksMenuBody3}" 0 0 0 \ "$_LuksEncrypt" "cryptsetup -q luksFormat" \ "$_LuksOpen" "cryptsetup open --type luks" \ "$_LuksEncryptAdv" "cryptsetup -q -s -c luksFormat" \ - "$_Back" "Return to the main menu")" + "back" "Return to the main menu")" case $choice in "$_LuksEncrypt") luks_basic || return 1 ;; @@ -2282,24 +2257,24 @@ luks_open() luks_pass() { - local title="$1" onlypass="$2" values="" pass="" pass2="" err=0 + local t="$1" op="$2" v="" p="" p2="" err=0 while true; do tput cnorm - if [[ $onlypass ]]; then - values="$(dialog --stdout --no-cancel --separator ';:~:;' \ + if [[ $op ]]; then + v="$(dialog --stdout --no-cancel --separator ';:~:;' \ --ok-label "Submit" --backtitle "$BT" --title " $title " --insecure --mixedform \ "\nEnter the password to decrypt $ROOT_PART.\n\nThis is needed to create a keyfile." 0 0 0 \ - "$_Password" 1 1 "" 1 $((${#_Password} + 2)) $COLUMNS 0 1 \ - "$_Password2" 2 1 "" 2 $((${#_Password2} + 2)) $COLUMNS 0 1)" + "Password:" 1 1 "" 1 11 $COLUMNS 0 1 \ + "Password2:" 2 1 "" 2 12 $COLUMNS 0 1)" else - values="$(dialog --stdout --no-cancel --separator ';:~:;' \ + v="$(dialog --stdout --no-cancel --separator ';:~:;' \ --ok-label "Submit" --backtitle "$BT" --title " $title " \ --insecure --mixedform "$_LuksOpenBody" 0 0 0 \ - "$_Name" 1 1 "${LUKS_NAME:-cryptroot}" 1 $((${#_Name} + 2)) $COLUMNS 0 0 \ - "$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \ - "$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1)" + "Name:" 1 1 "${LUKS_NAME:-cryptroot}" 1 7 $COLUMNS 0 0 \ + "Password:" 2 1 "" 2 11 $COLUMNS 0 1 \ + "Password2:" 3 1 "" 3 12 $COLUMNS 0 1)" fi @@ -2307,22 +2282,22 @@ luks_pass() (( err == 0 )) || break if [[ $onlypass ]]; then - pass="$(awk -F';:~:;' '{print $1}' <<< "$values")" - pass2="$(awk -F';:~:;' '{print $2}' <<< "$values")" + p="$(awk -F';:~:;' '{print $1}' <<< "$v")" + p2="$(awk -F';:~:;' '{print $2}' <<< "$v")" else - name="$(awk -F';:~:;' '{print $1}' <<< "$values")" - pass="$(awk -F';:~:;' '{print $2}' <<< "$values")" - pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")" + n="$(awk -F';:~:;' '{print $1}' <<< "$v")" + p="$(awk -F';:~:;' '{print $2}' <<< "$v")" + p2="$(awk -F';:~:;' '{print $3}' <<< "$v")" fi - if [[ ! $onlypass && $name == "" ]]; then - infobox "$_ErrTitle" "\nEncrypted device name cannot be empty.\n\n$_TryAgain" - elif [[ $pass == "" || "$pass" != "$pass2" ]]; then - [[ $onlypass ]] || LUKS_NAME="$name" - infobox "$_ErrTitle" "$_PassErr\n$_TryAgain" + if [[ ! $op && $n == "" ]]; then + infobox "Name Empty" "\nEncrypted device name cannot be empty.\n\nPlease try again.\n" + elif [[ $p == "" || "$p" != "$p2" ]]; then + [[ $op ]] || LUKS_NAME="$n" + infobox "Password Mismatch" "\nThe passwords entered do not match.\n\nPlease try again.\n" else - [[ $onlypass ]] || LUKS_NAME="$name" - LUKS_PASS="$pass" + [[ $op ]] || LUKS_NAME="$n" + LUKS_PASS="$p" break fi done @@ -2364,7 +2339,7 @@ luks_advanced() if luks_setup; then tput cnorm local cipher - cipher="$(getinput "$_PrepLUKS" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64" nolimit)" + cipher="$(getinput "LUKS Encryption" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64" nolimit)" [[ $cipher ]] || return 1 infobox "$_LuksEncryptAdv" "$_LuksCreateWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0 cryptsetup -q $cipher luksFormat $LUKS_PART <<< "$LUKS_PASS" 2>$ERR @@ -2438,7 +2413,6 @@ is_ssd() die() { (( $# >= 1 )) && exitcode=$1 || exitcode=0 - trap - INT tput cnorm @@ -2500,7 +2474,7 @@ system_devices() awk '/disk/ {print "/dev/" $1 " " $2}')" fi - [[ $SYS_DEVS ]] || { infobox "$_ErrTitle" "\nNo available devices...$_Exit\n"; die 1; } + [[ $SYS_DEVS ]] || { infobox "$_ErrTitle" "\nNo available devices...\n\nExiting..\n"; die 1; } DEV_COUNT="$(wc -l <<< "$SYS_DEVS")" } @@ -2576,24 +2550,29 @@ net_connect() system_checks() { if [[ $(whoami) != "root" ]]; then - infobox "$_ErrTitle" "$_NotRoot\n$_Exit" + infobox "Not Root" "\nThis installer must be run as root or using sudo.\n\nExiting..\n" die 1 elif ! grep -qw 'lm' /proc/cpuinfo; then - infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" + infobox "Not x86_64" "\nThis installer only supports x86_64 architectures.\n\nExiting..\n" die 1 fi + grep -q 'BCM4352' <<< "$(lspci -vnn -d 14e4:)" && load_bcm - net_connect || { infobox "$_ErrTitle" "$_NoNetwork\n$_Exit"; die 1; } + + if ! net_connect; then + infobox "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" + die 1 + fi } prechecks() { if [[ $1 -ge 0 ]] && ! [[ $(lsblk -lno MOUNTPOINT) =~ $MNT ]]; then - infobox "$_ErrTitle" "$_ErrNoMount"; SEL=4; return 1 + infobox "Not Mounted" "\nPartition(s) must be mounted first.\n"; SEL=4; return 1 elif [[ $1 -ge 1 && ($NEWUSER == "" || $USER_PASS == "") ]]; then - infobox "$_ErrTitle" "\nYou need to create a user first.\n"; SEL=5; return 1 + infobox "No User" "\nA user must be created first.\n"; SEL=5; return 1 elif [[ $1 -ge 2 && $CONFIG_DONE != true ]]; then - infobox "$_ErrTitle" "$_ErrNoConfig"; SEL=6; return 1 + infobox "Not Configured" "\nSystem configuration must be done first.\n"; SEL=6; return 1 fi return 0