Fix format asking permission and other small issues

This commit is contained in:
natemaia 2018-08-26 21:08:51 -07:00
parent 224ea1c18a
commit 0e51c6ce6a
8 changed files with 358 additions and 407 deletions

View File

@ -3,22 +3,16 @@
# vim:ft=sh:fdm=marker:fmr={,} # vim:ft=sh:fdm=marker:fmr={,}
# This program is free software, provided under the GNU GPL # This program is free software, provided under the GNU GPL
# Written by Nathaniel Maia for use in Archlabs # Written by Nathaniel Maia for use in Archlabs
# Some ideas and code were taken from other installers # Some ideas and code were taken from other installers
# AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due # AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due
# dry run performing no action, good for checking syntax errors
# set -n # set -n
######################################################################
## Script Setup Functions ##
######################################################################
# immutable variables { # immutable variables {
readonly DIST="ArchLabs" # Linux distributor readonly DIST="ArchLabs" # Linux distributor
readonly VER="1.6.54" # Installer version readonly VER="1.6.58" # Installer version
readonly LIVE="liveuser" # Live session user readonly LIVE="liveuser" # Live session user
readonly MNT="/mnt/install" # Install mountpoint readonly MNT="/mnt/install" # Install mountpoint
readonly ERR="/tmp/errlog" # Built-in error log readonly ERR="/tmp/errlog" # Built-in error log
@ -26,24 +20,15 @@ readonly EFI="/sys/firmware/efi/efivars"
readonly LIB="/usr/share/archlabs/installer/lib" readonly LIB="/usr/share/archlabs/installer/lib"
readonly TRN="/usr/share/archlabs/installer/lang" readonly TRN="/usr/share/archlabs/installer/lang"
# hardware check
readonly VM="$(dmesg | grep -i "hypervisor")" readonly VM="$(dmesg | grep -i "hypervisor")"
# create a regex string of all usb devices on the system
for dev in $(lsblk -lno NAME,TRAN | awk '/usb/ {print $1}'); do
USB_DEVS="${dev}$([[ $USB_DEVS ]] && echo -n "|$USB_DEVS")"
done
# determine which device was used for booting to ignore later during partition select
readonly IGNORE_DEV="$(lsblk -lno NAME,TYPE,TRAN,MOUNTPOINT |
awk "/$USB_DEVS/"' && /\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE,TRAN |
awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')"
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')" readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD" | sort -r)" readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')"
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
# create associative array for SUBZONES[zone], value is: 'sub-zone country_code' # create associative array for SUBZONES[zone], value is: 'sub-zone country_code'
declare -Ag SUBZONES declare -Ag SUBZONES
@ -73,24 +58,18 @@ tz Swahili ke Swahili bw Tswana ph Filipino id Indonesian my Malay tm Turkmen bt
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer
az Azerbaijani" az Azerbaijani"
declare -Agr BOOT_MNTS=( declare -Agr BMNTS=(
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot" [UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
[BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot" [BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot"
) )
declare -Agr BOOTLDRS=([BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}"
# static list of bootloaders & boot partition mountpoints stored as the system type (BIOS or UEFI) [UEFI]="grub ${BMNTS[UEFI-grub]} systemd-boot ${BMNTS[UEFI-systemd-boot]} syslinux ${BMNTS[UEFI-syslinux]}"
declare -Agr BOOTLOADERS=([BIOS]="grub ${BOOT_MNTS[BIOS-grub]} syslinux ${BOOT_MNTS[BIOS-syslinux]}"
[UEFI]="grub ${BOOT_MNTS[UEFI-grub]} systemd-boot ${BOOT_MNTS[UEFI-systemd-boot]} syslinux ${BOOT_MNTS[UEFI-syslinux]}"
) )
# static mkfs commands for each filesystem offered
declare -Agr FS_CMDS=( declare -Agr FS_CMDS=(
[ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q" [ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q"
[f2fs]="mkfs.f2fs" [jfs]="mkfs.jfs -q" [xfs]="mkfs.xfs -f" [nilfs2]="mkfs.nilfs2 -q" [f2fs]="mkfs.f2fs" [jfs]="mkfs.jfs -q" [xfs]="mkfs.xfs -f" [nilfs2]="mkfs.nilfs2 -q"
[ntfs]="mkfs.ntfs -q" [reiserfs]="mkfs.reiserfs -q" [vfat]="mkfs.vfat -F32" [ntfs]="mkfs.ntfs -q" [reiserfs]="mkfs.reiserfs -q" [vfat]="mkfs.vfat -F32"
) )
# static filesystem mount options
declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]="" declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
[ext4]="dealloc - off discard - off nofail - off noacl - off relatime - off noatime - off nobarrier - off nodelalloc - off" [ext4]="dealloc - off discard - off nofail - off noacl - off relatime - off noatime - off nobarrier - off nodelalloc - off"
[jfs]="discard - off errors=continue - off errors=panic - off nointegrity - off" [jfs]="discard - off errors=continue - off errors=panic - off nointegrity - off"
@ -101,64 +80,40 @@ declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
) )
# } # }
luks_variable_init() { init_variables() {
declare -g LUKS=0
declare -g LVM=0
declare -g VOL_GROUP_MB=0
declare -g LUKS_NAME="cryptroot"
declare -g LUKS_PART=""
declare -g LUKS_PASS=""
declare -g LUKS_UUID=""
declare -g LUKS_DEV=""
declare -g MKINIT_HOOKS="shutdown"
declare -g SEPERATE_BOOT=0
}
initialize_variables() {
# Modified during runtime and are all globally accessible
# This is called once when the script is started, and again if/when an error occurs
# Some may never be used, depending on the system and choices made
declare -g BT="$DIST Installer - (x86_64) - Version $VER" declare -g BT="$DIST Installer - (x86_64) - Version $VER"
declare -g ROOT_PART="" declare -g ROOT_PART=""
declare -g BOOT_DEVICE="" declare -g BOOT_DEVICE=""
declare -g BOOT_PART="" declare -g BOOT_PART=""
declare -g BOOTLOADER="" declare -g BOOTLDR=""
declare -g EXTRA_MNT="" declare -g EXTRA_MNT=""
declare -g EXTRA_MNTS=""
declare -g SWAP="none" declare -g SWAP="none"
declare -g SWAP_SIZE="${SYS_MEM}M" declare -g SWAP_SIZE="${SYS_MEM}M"
declare -g KERNEL="linux"
declare -g NEWUSER="" declare -g NEWUSER=""
declare -g USER_PASS="" declare -g USER_PASS=""
declare -g ROOT_PASS="" declare -g ROOT_PASS=""
declare -g LOGIN_WM="" declare -g LOGIN_WM=""
declare -g LOGIN_TYPE="" declare -g LOGIN_TYPE=""
declare -g INSTALL_WMS="" declare -g INSTALL_WMS=""
declare -g KERNEL="linux"
declare -g WM_PACKAGES="" declare -g WM_PACKAGES=""
declare -g EXTRA_PACKAGES="" declare -g EXTRA_PACKAGES=""
declare -g REMOVE_PKGS="" declare -g MKINIT_HOOKS="shutdown"
declare -g CURRENT_MENU=""
declare -g MENU_HIGHLIGHT
declare -g EDITOR_CHOICE=""
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate" declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
# boolean checks declare -g IS_64BIT=false
declare -g AUTOLOGIN=false declare -g AUTOLOGIN=false
declare -g CONFIG_DONE=false declare -g CONFIG_DONE=false
declare -g IS_64BIT=false declare -g SEPERATE_BOOT=false
# Commands used to install each bootloader. declare -Ag BCMDS=(
# NOTE: syslinux and grub in particular can/will change during runtime
declare -Ag BOOT_CMDS=(
[syslinux]="syslinux-install_update -iam" [syslinux]="syslinux-install_update -iam"
[grub]="grub-install --recheck --force" [grub]="grub-install --recheck --force"
[systemd-boot]="bootctl --path=${BOOT_MNTS[UEFI-systemd-boot]} install" [systemd-boot]="bootctl --path=${BMNTS[UEFI-systemd-boot]} install"
) )
declare -Ag FILES=(
# files able to be reviewed when finishing install [2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
# item index [9] can change depending on which bootloader is selected
declare -Ag EDIT_FILES=(
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/vconsole.conf /etc/default/keyboard"
[3]="/etc/locale.conf /etc/default/locale" [3]="/etc/locale.conf /etc/default/locale"
[4]="/etc/hostname /etc/hosts" [4]="/etc/hostname /etc/hosts"
[5]="/etc/sudoers" [5]="/etc/sudoers"
@ -177,9 +132,61 @@ source_file() {
} }
###################################################################### ######################################################################
## System Setup Functions ## ## Setup ##
###################################################################### ######################################################################
user_setup() {
tput cnorm
local values
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
--title " $_UserTitle " --insecure --mixedform "$_UserBody" 27 75 10 \
"$_Username" 1 1 "" 1 $((${#_Username} + 2)) 71 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) 71 0 1 \
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) 71 0 2 \
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) 71 0 1)"
[[ $? != 0 || $values == "" ]] && return 1
local user
user="$(awk -F'~' '{print $1}' <<< "$values")"
local pass pass2
pass="$(awk -F'~' '{print $2}' <<< "$values")"
pass2="$(awk -F'~' '{print $3}' <<< "$values")"
local rpass rpass2
rpass="$(awk -F'~' '{print $5}' <<< "$values")"
rpass2="$(awk -F'~' '{print $6}' <<< "$values")"
# both root passwords are empty, so use the user passwords instead
[[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; }
# make sure a username was entered and that the passwords match
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9\ ] || $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
# password was left empty or doesn't match
if [[ $pass == "" ]]; then
msgbox "$_ErrTitle" "\nUser $_Password CANNOT be left empty.\n$_TryAgain"
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
else
msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain"
fi
else # bad username
msgbox "$_UserErrTitle" "$_UserErrBody"
user=""
fi
# recursively loop back unless the user cancels
user_setup || return 1
else
NEWUSER="$user"
USER_PASS="$pass"
ROOT_PASS="$rpass"
fi
return 0
}
select_language() { select_language() {
tput civis tput civis
local lang local lang
@ -272,58 +279,6 @@ setup_hostname() {
[[ $? != 0 || $HOSTNAME == "" ]] && return 1 || return 0 [[ $? != 0 || $HOSTNAME == "" ]] && return 1 || return 0
} }
user_setup() {
tput cnorm
local values
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
--title " $_UserTitle " --insecure --mixedform "$_UserBody" 27 75 10 \
"$_Username" 1 1 "" 1 $((${#_Username} + 2)) 71 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) 71 0 1 \
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) 71 0 2 \
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) 71 0 1)"
[[ $? != 0 || $values == "" ]] && return 1
local user
user="$(awk -F'~' '{print $1}' <<< "$values")"
local pass pass2
pass="$(awk -F'~' '{print $2}' <<< "$values")"
pass2="$(awk -F'~' '{print $3}' <<< "$values")"
local rpass rpass2
rpass="$(awk -F'~' '{print $5}' <<< "$values")"
rpass2="$(awk -F'~' '{print $6}' <<< "$values")"
# both root passwords are empty, so use the user passwords instead
[[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; }
# make sure a username was entered and that the passwords match
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9\ ] || $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
# password was left empty or doesn't match
if [[ $pass == "" ]]; then
msgbox "$_ErrTitle" "\nUser $_Password CANNOT be left empty.\n$_TryAgain"
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
else
msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain"
fi
else # bad username
msgbox "$_UserErrTitle" "$_UserErrBody"
user=""
fi
# recursively loop back unless the user cancels
user_setup || return 1
else
NEWUSER="$user"
USER_PASS="$pass"
ROOT_PASS="$rpass"
fi
return 0
}
window_manager() { window_manager() {
LOGIN_WM="" LOGIN_WM=""
LOGIN_TYPE="" LOGIN_TYPE=""
@ -342,11 +297,39 @@ window_manager() {
INSTALL_WMS="${INSTALL_WMS:-openbox}" INSTALL_WMS="${INSTALL_WMS:-openbox}"
WM_NUM=$(awk '{print NF}' <<< "$INSTALL_WMS") WM_NUM=$(awk '{print NF}' <<< "$INSTALL_WMS")
# packages needed for the selected window manager
for wm in $INSTALL_WMS; do
WM_LOGIN_CHOICES="${WM_LOGIN_CHOICES}$wm - "
case $wm in
openbox) WM_PACKAGES="$WM_PACKAGES $wm obconf archlabs-obkey archlabs-kickshaw tint2 conky" ;;
bspwm) WM_PACKAGES="$WM_PACKAGES $wm sxhkd" ;;
i3-gaps) WM_PACKAGES="$WM_PACKAGES $wm i3status perl-anyevent-i3" ;;
gnome) WM_PACKAGES="$WM_PACKAGES $wm gnome-extra" ;;
cinnamon) WM_PACKAGES="$WM_PACKAGES $wm" ;;
xfce4) WM_PACKAGES="$WM_PACKAGES $wm xfce4-goodies xfce4-pulseaudio-plugin" ;;
esac
done
if [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps) ]]; then
WM_PACKAGES="$WM_PACKAGES termite thunar archlabs-polybar archlabs-screenlock archlabs-skippy-xd archlabs-oblogout lxappearance"
elif [[ $INSTALL_WMS =~ (xfce4) ]]; then
WM_PACKAGES="$WM_PACKAGES archlabs-oblogout archlabs-screenlock"
fi
EXTRA_PACKAGES="$WM_PACKAGES"
# add lightdm packages if chosen
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
EXTRA_PACKAGES="$EXTRA_PACKAGES lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
fi
# if dwm is not the only WM chosen offer lightdm # if dwm is not the only WM chosen offer lightdm
if yesno "$_WMLogin" "$_LoginTypeBody\n" "xinit" "lightdm"; then if yesno "$_WMLogin" "$_LoginTypeBody\n" "xinit" "lightdm"; then
LOGIN_TYPE='lightdm'
else
LOGIN_TYPE='xinit' LOGIN_TYPE='xinit'
FILES[11]="/home/$NEWUSER/.xinitrc"
else
LOGIN_TYPE='lightdm'
FILES[11]="/etc/lightdm/lightdm.conf $MNT/etc/lightdm/lightdm-gtk-greeter.conf"
fi fi
if yesno "$_WMLogin" "$_AutoLoginBody\n"; then if yesno "$_WMLogin" "$_AutoLoginBody\n"; then
@ -375,7 +358,8 @@ window_manager() {
} }
extra_packages() { extra_packages() {
EXTRA_PACKAGES="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \ local pkgs
pkgs="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
--title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 20 \ --title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 20 \
"firefox" "A popular open-source graphical web browser from Mozilla" off \ "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 \ "chromium" "an open-source graphical web browser based on the Blink rendering engine" off \
@ -448,9 +432,9 @@ extra_packages() {
"ttf-fira-code" "Monospaced font with programming ligatures" off \ "ttf-fira-code" "Monospaced font with programming ligatures" off \
"noto-fonts-cjk" "Google Noto CJK fonts (Chinese, Japanese, Korean)" off \ "noto-fonts-cjk" "Google Noto CJK fonts (Chinese, Japanese, Korean)" off \
"noto-fonts noto-fonts-emoji" "Google Noto fonts and emoji" off)" "noto-fonts noto-fonts-emoji" "Google Noto fonts and emoji" off)"
[[ $? != 0 ]] && return 1
[[ $EXTRA_PACKAGES =~ kdenlive ]] && EXTRA_PACKAGES="$EXTRA_PACKAGES kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
[[ $pkgs =~ kdenlive ]] && pkgs="$pkgs kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
EXTRA_PACKAGES="$pkgs $EXTRA_PACKAGES"
return 0 return 0
} }
@ -497,9 +481,57 @@ mirrorlist_cmd() {
} }
###################################################################### ######################################################################
## Main Menu Functions ## ## Menus ##
###################################################################### ######################################################################
display_selection() {
local msg="Below are the configuration and setup values used during install
Root Partition: $ROOT_PART
Boot Partition: $BOOT_PART
Bootloader: $BOOTLDR
Boot Mount: ${BMNTS[$SYS-$BOOTLDR]}
Swap: $SWAP
Extra: $EXTRA_MNTS
LUKS: $LUKS
LVM: $LVM
New User: $NEWUSER
Autologin: $AUTOLOGIN
Login Type: $LOGIN_TYPE
Login Session: $LOGIN_WM
Hostname: $HOSTNAME
Locale: $LOCALE
Keymap: $KEYMAP
Timezone: $ZONE/$SUBZONE
Kernel: $KERNEL
Sessions: $INSTALL_WMS
Mirrors: $MIRROR_CMD
Packages: $EXTRA_PACKAGES"
msgbox "Install Info" "\n$msg\n"
return 0
}
configure_install() {
# whether to use a custom mirror sorting command later
setup_hostname || return 1
setup_locale || return 1
setup_timezone || return 1
mirrorlist_cmd || return 1
user_setup || return 1
window_manager || return 1
choose_kernel
extra_packages || return 1
CONFIG_DONE=true
return 0
}
edit_configs() { edit_configs() {
if [[ $CURRENT_MENU != "edit" ]]; then if [[ $CURRENT_MENU != "edit" ]]; then
MENU_HIGHLIGHT=1 MENU_HIGHLIGHT=1
@ -512,13 +544,14 @@ edit_configs() {
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \ MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_EditTitle " --default-item $MENU_HIGHLIGHT --menu "$_EditBody" 0 0 0 \ --title " $_EditTitle " --default-item $MENU_HIGHLIGHT --menu "$_EditBody" 0 0 0 \
"1" "$_Done" "2" "keyboard" "3" "language + locale" "4" "hostname" "5" "sudoers" \ "1" "$_Done" "2" "keyboard" "3" "language + locale" "4" "hostname" "5" "sudoers" \
"6" "mkinitcpio.conf" "7" "fstab" "8" "crypttab" "9" "$BOOTLOADER" "10" "pacman.conf") "6" "mkinitcpio.conf" "7" "fstab" "8" "crypttab" "9" "$BOOTLDR" "10" "pacman.conf" \
"11" "$LOGIN_TYPE")
if [[ $MENU_HIGHLIGHT == "" || $MENU_HIGHLIGHT == 1 ]]; then if [[ $MENU_HIGHLIGHT == "" || $MENU_HIGHLIGHT == 1 ]]; then
wrap_up "$_InstFinBody" 'Exit & Reboot' 'Go Back' 'reboot' wrap_up "$_InstFinBody" 'Exit & Reboot' 'Go Back' 'reboot'
else else
local existing_files="" local existing_files=""
for f in $(echo "${EDIT_FILES[$MENU_HIGHLIGHT]}"); do for f in $(echo "${FILES[$MENU_HIGHLIGHT]}"); do
[[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f" [[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f"
done done
@ -536,20 +569,6 @@ edit_configs() {
edit_configs edit_configs
} }
configure_install() {
# whether to use a custom mirror sorting command later
setup_hostname || return 1
setup_locale || return 1
setup_timezone || return 1
user_setup || return 1
mirrorlist_cmd || return 1
window_manager || return 1
extra_packages || return 1
choose_kernel
CONFIG_DONE=true
return 0
}
main() { main() {
local retval local retval
@ -563,12 +582,13 @@ main() {
tput civis tput civis
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \ MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepTitle " --default-item $MENU_HIGHLIGHT --menu "$_PrepBody" 0 0 0 \ --title " $_PrepTitle " --default-item $MENU_HIGHLIGHT --menu "$_PrepBody" 0 0 0 \
"1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \ "1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \
"5" "$_PrepMount" "6" "$_PrepConfig" "7" "$_PrepInstall" "8" "$_Done") "5" "$_PrepMount" "6" "$_PrepConfig" "7" "Check Selections" "8" "$_PrepInstall" \
"9" "$_Done")
# if trying to install the system, make sure the partitions are mounted # if trying to install the system, make sure the partitions are mounted
# and that the needed config variables and user variables have been set up # and that the needed config variables and user variables have been set up
if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 7 ]]; then if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 8 ]]; then
check_install_ready check_install_ready
retval=$? retval=$?
[[ $retval -gt 0 ]] && { MENU_HIGHLIGHT=$retval; return 1; } [[ $retval -gt 0 ]] && { MENU_HIGHLIGHT=$retval; return 1; }
@ -581,36 +601,27 @@ main() {
4) lvm_menu || MENU_HIGHLIGHT=1 ;; 4) lvm_menu || MENU_HIGHLIGHT=1 ;;
5) mount_main || MENU_HIGHLIGHT=1 ;; 5) mount_main || MENU_HIGHLIGHT=1 ;;
6) configure_install ;; 6) configure_install ;;
7) install_main && edit_configs ;; 7) display_selection ;;
8) install_main && edit_configs ;;
*) wrap_up "$_CloseInstBody" 'Exit' 'Back' 'exit' *) wrap_up "$_CloseInstBody" 'Exit' 'Back' 'exit'
esac esac
} }
###################################################################### for file in utils mount partition bootloader lvm luks install; do
## Execution ## source_file $LIB/$file.sh
######################################################################
# source the library files before anything else to get access to functions
for file in utils.sh mount.sh partition.sh bootloader.sh package.sh lvm.sh luks.sh install.sh; do
source_file $LIB/$file
done done
# trap ctrl-c and call sigint() to properly exit, without this trap sigint INT # trap Ctrl-C and call sigint() to properly exit
# exiting via Ctrl-c can leave the terminal in a messed up state
trap sigint INT
for arg in "$@"; do for arg in "$@"; do
[[ $arg == "--debug" || $arg == "-d" ]] && debug # from $LIB/utils.sh [[ $arg == "--debug" || $arg == "-d" ]] && debug
done done
initialize_variables init_variables
luks_variable_init
select_language select_language
setup_keymap setup_keymap
check_requirements check_requirements
identify_system identify_system
msgbox "$_WelTitle $DIST Installer" "$_WelBody" msgbox "$_WelTitle $DIST Installer" "$_WelBody"
while true; do while true; do

View File

@ -9,25 +9,25 @@
select_boot_setup() { select_boot_setup() {
# choose bootloader and by extension mountpoint (if needed) # choose bootloader and by extension mountpoint (if needed)
tput civis tput civis
BOOTLOADER="$(dialog --cr-wrap --stdout --backtitle "$BT" \ BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLOADERS[$SYS]})" --title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"
[[ $? != 0 || $BOOTLOADER == "" ]] && return 1 [[ $? != 0 || $BOOTLDR == "" ]] && return 1
if [[ $SYS == 'BIOS' && $BOOTLOADER == 'grub' && $BOOT_DEVICE == "" ]]; then if [[ $SYS == 'BIOS' && $BOOTLDR == 'grub' && $BOOT_DEVICE == "" ]]; then
# grub on BIOS needs an install device, NOT partition eg. /dev/sda # grub on BIOS needs an install device, NOT partition eg. /dev/sda
select_device 'boot' || return 1 select_device 'boot' || return 1
fi fi
if [[ $BOOTLOADER == 'systemd-boot' ]]; then if [[ $BOOTLDR == 'systemd-boot' ]]; then
EDIT_FILES[9]="/boot/loader/entries/$DIST.conf" FILES[9]="/boot/loader/entries/$DIST.conf"
elif [[ $BOOTLOADER == 'syslinux' && $SYS == 'BIOS' ]]; then elif [[ $BOOTLDR == 'syslinux' && $SYS == 'BIOS' ]]; then
BOOT_CMDS[$BOOTLOADER]="$(dialog --cr-wrap --stdout --backtitle "$BT" \ BCMDS[$BOOTLDR]="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_InstSysTitle " --menu "$_InstSysBody" 0 0 0 \ --title " $_InstSysTitle " --menu "$_InstSysBody" 0 0 0 \
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \ "syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
"syslinux-install_update -i" "Install to root partition (/)")" "syslinux-install_update -i" "Install to root partition (/)")"
[[ $? != 0 || ${BOOT_CMDS[$BOOTLOADER]} == "" ]] && return 1 [[ $? != 0 || ${BCMDS[$BOOTLDR]} == "" ]] && return 1
else else
EDIT_FILES[9]="/etc/default/grub" FILES[9]="/etc/default/grub"
fi fi
return 0 return 0
@ -38,7 +38,7 @@ shim_secure_boot() {
local shim_file="shim64.efi" local shim_file="shim64.efi"
[[ $IS_64BIT != true ]] && shim_file="shim.efi" [[ $IS_64BIT != true ]] && shim_file="shim.efi"
efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BOOT_MNTS[$SYS-$BOOTLOADER]}/$shim_file efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file
return 0 return 0
} }
@ -48,7 +48,7 @@ uefi_boot_fallback() {
# copy the bootloaders efi stub to that directory as bootx64.efi # copy the bootloaders efi stub to that directory as bootx64.efi
local default="boot" local default="boot"
local esp="${MNT}${BOOT_MNTS[$SYS-$BOOTLOADER]}" local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
for i in $(find "$esp/EFI/" -maxdepth 1 -mindepth 1 -type d 2>/dev/null); do for i in $(find "$esp/EFI/" -maxdepth 1 -mindepth 1 -type d 2>/dev/null); do
grep -qi "boot" <<< "$(basename $i)" && { default="$(basename $i)"; break; } grep -qi "boot" <<< "$(basename $i)" && { default="$(basename $i)"; break; }
done done
@ -75,27 +75,27 @@ uefi_boot_fallback() {
} }
prep_for_grub() { prep_for_grub() {
local ttype
local cfg="$MNT/etc/default/grub" local cfg="$MNT/etc/default/grub"
if [[ $SYS == 'UEFI' ]]; then if [[ $SYS == 'UEFI' ]]; then
local gtype='x86_64-efi' [[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
[[ $IS_64BIT != true ]] && gtype='i386-efi' BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
BOOT_CMDS[grub]="${BOOT_CMDS[grub]} --target=$gtype --bootloader-id=$DIST"
else else
BOOT_CMDS[grub]="${BOOT_CMDS[grub]} --target=i386-pc $BOOT_DEVICE" BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
fi fi
BOOT_CMDS[grub]="${BOOT_CMDS[grub]} && grub-mkconfig -o /boot/grub/grub.cfg" BCMDS[grub]="${BCMDS[grub]} && grub-mkconfig -o /boot/grub/grub.cfg"
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g;
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg
if (( LUKS == 1 )); then if [[ $LUKS -eq 1 ]]; then
sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g;
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg
fi fi
if [[ $SYS != 'UEFI' && $LVM -eq 1 && $SEPERATE_BOOT -eq 0 ]]; then if [[ $SYS == 'BIOS' && $LVM -eq 1 && $SEPERATE_BOOT == false ]]; then
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg
fi fi
@ -138,11 +138,11 @@ EOF
prep_for_syslinux() { prep_for_syslinux() {
local cfgdir="$MNT/boot/syslinux" local cfgdir="$MNT/boot/syslinux"
local cfgsrcdir="/usr/lib/syslinux/bios/" local cfgsrcdir="/usr/lib/syslinux/bios/"
EDIT_FILES[9]="/boot/syslinux/syslinux.cfg" FILES[9]="/boot/syslinux/syslinux.cfg"
if [[ $SYS == 'UEFI' ]]; then if [[ $SYS == 'UEFI' ]]; then
EDIT_FILES[9]="/boot/EFI/syslinux/syslinux.cfg" FILES[9]="/boot/EFI/syslinux/syslinux.cfg"
BOOT_CMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST" BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
cfgdir="$MNT/boot/EFI/syslinux" cfgdir="$MNT/boot/EFI/syslinux"
cfgsrcdir="/usr/lib/syslinux/efi64/" cfgsrcdir="/usr/lib/syslinux/efi64/"
fi fi
@ -177,27 +177,29 @@ EOF
install_bootloader() { install_bootloader() {
chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl" chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl"
local msg="$_InstBootloader $BOOTLOADER\n" local msg="$_InstBootloader $BOOTLDR\n"
[[ $BOOT_PART != "" ]] && msg="$msg\n$_InstBootDev $BOOT_PART\n" [[ $BOOT_PART != "" ]] && msg="$msg\n$_InstBootDev $BOOT_PART\n"
echo -e "$msg\nMountpoint: ${BOOT_MNTS[$SYS-$BOOTLOADER]}\n" echo -e "$msg\nMountpoint: ${BMNTS[$SYS-$BOOTLDR]}\n"
# if not on an LVM we can use the UUID for booting # if not on an LVM we can use the UUID for booting
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
ROOT_PART_ID="UUID=$(blkid -s PARTUUID $ROOT_PART | sed 's/.*=//g; s/"//g')" ROOT_PART_ID="UUID=$(blkid -s PARTUUID $ROOT_PART | sed 's/.*=//g; s/"//g')"
[[ $BOOTLOADER == 'systemd-boot' ]] && ROOT_PART_ID="PART$ROOT_PART_ID" [[ $BOOTLDR == 'systemd-boot' ]] && ROOT_PART_ID="PART$ROOT_PART_ID"
else else
# for LVM use the partition name eg. /dev/mapper/cryptroot # for LVM use the partition name eg. /dev/mapper/cryptroot
ROOT_PART_ID="$ROOT_PART" ROOT_PART_ID="$ROOT_PART"
fi fi
# needed for os-prober module to work properly in the chroot # needed for os-prober module to work properly in the chroot
mkdir -p /run/udev && mount --bind /run/udev /run/udev >/dev/null 2>&1 echo -e "\n\nBinding mount: /run/udev -> $MNT/run/udev\n\n"
BOOT_CMDS[$BOOTLOADER]="mkdir -p /run/udev && mount --bind /run/udev /run/udev ; ${BOOT_CMDS[$BOOTLOADER]}" mkdir -p $MNT/run/udev && mount --bind /run/udev $MNT/run/udev
read NONE
# BCMDS[$BOOTLDR]="mkdir -p /run/udev && mount --bind /run/udev /run/udev ; ${BCMDS[$BOOTLDR]}"
if [[ $SYS == 'UEFI' ]]; then if [[ $SYS == 'UEFI' ]]; then
# make sure efivarfs has been mounted # make sure efivarfs has been mounted
mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1 mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1
BOOT_CMDS[$BOOTLOADER]="mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars ; ${BOOT_CMDS[$BOOTLOADER]}" BCMDS[$BOOTLDR]="mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars; ${BCMDS[$BOOTLDR]}"
# remove old boot entries # remove old boot entries
local esp="$MNT/boot/efi/EFI/" local esp="$MNT/boot/efi/EFI/"
@ -205,16 +207,16 @@ install_bootloader() {
find $esp -maxdepth 1 -mindepth 1 \( -name '[aA][rR][cC][hH][lL]abs' -o -name '[Bb][oO][oO][tT]' \) -type d -exec rm -rf '{}' \; >/dev/null 2>&1 find $esp -maxdepth 1 -mindepth 1 \( -name '[aA][rR][cC][hH][lL]abs' -o -name '[Bb][oO][oO][tT]' \) -type d -exec rm -rf '{}' \; >/dev/null 2>&1
fi fi
# sets up the bootloader config(s) and ${BOOT_CMDS[$BOOTLOADER]} # sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
prep_for_$BOOTLOADER prep_for_$BOOTLDR
# run the bootloader command # run the bootloader command
chroot_cmd "${BOOT_CMDS[$BOOTLOADER]}" chroot_cmd "${BCMDS[$BOOTLDR]}"
check_for_errors "${BOOT_CMDS[$BOOTLOADER]}" check_for_errors "${BCMDS[$BOOTLDR]}"
if [[ $SYS == 'UEFI' && $BOOTLOADER =~ (grub|syslinux) ]]; then if [[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]]; then
local boot_dir="$DIST" local boot_dir="$DIST"
[[ $BOOTLOADER == 'syslinux' ]] && boot_dir="syslinux" [[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
# copy efi stub to generic catch all # copy efi stub to generic catch all
uefi_boot_fallback "$boot_dir" uefi_boot_fallback "$boot_dir"

View File

@ -7,9 +7,6 @@
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
install_main() { install_main() {
# this assumes all needed variables/settings are setup as needed
# no additional user confirmation are performed aside from what is needed
# unpack the whole filesystem to install directory $MNT # unpack the whole filesystem to install directory $MNT
oneshot install_base oneshot install_base
@ -22,30 +19,36 @@ install_main() {
check_for_errors "sed -i s~${MNT}~~ $MNT/etc/fstab" check_for_errors "sed -i s~${MNT}~~ $MNT/etc/fstab"
fi fi
# run package operations before bootloader and mkinitcpio # update the mirrorlist, if this isn't done before updating or it may be slow
# due to the possibility of choosing lts kernel earlier local cmdtail="--verbose --save $MNT/etc/pacman.d/mirrorlist"
oneshot update_mirrorlist $MIRROR_CMD $cmdtail || reflector --score 100 -l 50 -f 10 --sort rate $cmdtail
oneshot update_system
oneshot install_packages oneshot update_system # MUST be before bootloader and mkinitcpio
[[ $LOGIN_TYPE == 'lightdm' ]] && oneshot setup_lightdm
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
oneshot setup_lightdm
fi
run_mkinitcpio || return 1 run_mkinitcpio || return 1
install_bootloader || return 1 install_bootloader || return 1
oneshot set_hwclock chroot_cmd "hwclock --systohc --utc" || chroot_cmd "hwclock --systohc --utc --directisa"
oneshot create_user || return 1 oneshot create_user || return 1
return 0 return 0
} }
install_base() { install_base() {
# unpack the main system clear
tput cnorm tput cnorm
clear && echo -e "\nUnpacking base filesystem..\n\n" echo -e "\nUnpacking base filesystem..\n\n"
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/ rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
# remove archiso init files # remove archiso init files and clean up install files
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \; find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \;
rm -rf $MNT/etc/{mkinitcpio-archiso.conf,sudoers.d/g_wheel,polkit-1/rules.d/49-nopasswd_global.rules} rm -f $MNT/etc/mkinitcpio-archiso.conf
rm -rf $MNT/etc/sudoers.d/g_wheel
rm -f $MNT/etc/polkit-1/rules.d/49-nopasswd_global.rules
# cleanup system permissions # cleanup system permissions
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
@ -55,7 +58,9 @@ install_base() {
[[ $VM ]] && rm -rf $MNT/etc/X11/xorg.conf.d [[ $VM ]] && rm -rf $MNT/etc/X11/xorg.conf.d
# if not installing the lts kernel, copy the kernel image # if not installing the lts kernel, copy the kernel image
[[ $KERNEL != 'linux-lts' ]] && cp -f /run/archiso/bootmnt/arch/boot/x86_64/vmlinuz $MNT/boot/vmlinuz-linux if [[ $KERNEL != 'linux-lts' ]]; then
cp -f /run/archiso/bootmnt/arch/boot/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
fi
setup_configs setup_configs
return 0 return 0
@ -71,9 +76,7 @@ setup_configs() {
sed -i "s/en_US.UTF-8/${LOCALE}/g" $MNT/etc/locale.conf sed -i "s/en_US.UTF-8/${LOCALE}/g" $MNT/etc/locale.conf
cp -f $MNT/etc/locale.conf $MNT/etc/default/locale cp -f $MNT/etc/locale.conf $MNT/etc/default/locale
chroot_cmd "locale-gen" 2>$ERR chroot_cmd "locale-gen" 2>$ERR
check_for_errors 'locale-gen'
chroot_cmd "ln -sf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime" 2>$ERR chroot_cmd "ln -sf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime" 2>$ERR
check_for_errors "ln -sf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime"
# setup xorg vsync config for intel graphics # setup xorg vsync config for intel graphics
if [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then if [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
@ -109,7 +112,6 @@ EOF
KEYMAP=$CONSOLE_MAP KEYMAP=$CONSOLE_MAP
FONT=$FONT FONT=$FONT
EOF EOF
# set the hostname # set the hostname
echo "$HOSTNAME" > $MNT/etc/hostname echo "$HOSTNAME" > $MNT/etc/hostname
cat > $MNT/etc/hosts << EOF cat > $MNT/etc/hosts << EOF
@ -123,20 +125,43 @@ EOF
} }
create_user() { create_user() {
echo -e "\nSetting root password\n" local _home="$MNT/home/$LIVE"
local serve="$MNT/etc/systemd/system/getty@tty1.service.d"
# set root password
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd" chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
echo -e "$_UserSetBody"
# edit the required files in /etc/ to swap the liveuser account name # edit the required files in /etc/ to swap the liveuser account name
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow} sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
# set standard groups for the new user # set standard groups for the new user
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin" local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
if [[ $AUTOLOGIN == true && $LOGIN_TYPE == 'lightdm' ]]; then if [[ $LOGIN_TYPE == 'lightdm' ]]; then
groups="$groups,nopasswdlogin" [[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
elif [[ $AUTOLOGIN == true ]]; then rm -rf $_home/.{zprofile,xinitrc}
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/systemd/system/getty@tty1.service.d/autologin.conf rm -rf $serve
else
if [[ $AUTOLOGIN == true ]]; then
sed -i "s/${LIVE}/${NEWUSER}/g" $serve/autologin.conf
fi
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $_home/.xinitrc
sed -i '/archlabs-installer/d' $_home/.zprofile
cat >> $_home/.zprofile << EOF
[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null
EOF
fi
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.config/gtk-3.0/bookmarks
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.mozilla/firefox/archlabs.default/prefs.js
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.mozilla/firefox/archlabs.default/sessionstore.js
if ! [[ $INSTALL_WMS =~ openbox ]]; then
rm -rf $_home/.config/openbox
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
rm -rf $_home/.config/{bspwm,sxhkd}
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
rm -rf $_home/.config/i3
fi fi
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER" chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
@ -144,67 +169,21 @@ create_user() {
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd" chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd"
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER" chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER"
setup_user_home
return 0
}
setup_user_home() {
local user_home="$MNT/home/$NEWUSER"
sed -i "s/${LIVE}/${NEWUSER}/g" $user_home/.config/gtk-3.0/bookmarks \
$user_home/.mozilla/firefox/{archlabs.default/prefs.js,archlabs.default/sessionstore.js}
if [[ $AUTOLOGIN == true ]]; then
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
rm -rf $user_home/.{zprofile,xinitrc}
else
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
fi
else
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
fi
if ! [[ $INSTALL_WMS =~ openbox ]]; then
rm -rf $user_home/.config/{openbox,ob-autostart,obmenu-generator}
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
rm -rf $user_home/.config/{bspwm,sxhkd}
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
rm -rf $user_home/.config/i3
fi
return 0
}
set_hwclock() {
chroot_cmd "hwclock --systohc --utc"
[[ $? != 0 ]] && chroot_cmd "hwclock --systohc --utc --directisa"
return 0
}
update_mirrorlist() {
echo -e "\nSorting the mirrorlist..\n"
$MIRROR_CMD --verbose --save $MNT/etc/pacman.d/mirrorlist && return 0
echo -e "\nAn error occurred while updating the mirrorlist.\n\nFalling back to automatic sorting...\n"
reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
return 0 return 0
} }
run_mkinitcpio() { run_mkinitcpio() {
local conf="$MNT/etc/mkinitcpio.conf"
local add
# setup a keyfile for LUKS.. Only when choosing grub and system is UEFI # setup a keyfile for LUKS.. Only when choosing grub and system is UEFI
if [[ $LUKS -eq 1 && $SYS == 'UEFI' && $BOOTLOADER == 'grub' && $LUKS_PASS && $LUKS_UUID ]]; then if [[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]]; then
luks_keyfile || return 1 luks_keyfile
fi fi
# new HOOKS needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM # new HOOKS needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
local add
(( LVM == 1 )) && add="lvm2" (( LVM == 1 )) && add="lvm2"
(( LUKS == 1 )) && add="encrypt$([[ $add != "" ]] && echo -n " $add")" (( LUKS == 1 )) && add="encrypt$([[ $add != "" ]] && echo -n " $add")"
local conf="$MNT/etc/mkinitcpio.conf"
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $conf sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $conf
tput civis tput civis
@ -213,3 +192,75 @@ run_mkinitcpio() {
return 0 return 0
} }
update_system() {
tput cnorm
local inpkg="base-devel git"
local rmpkg="archlabs-installer"
local vbx="virtualbox-guest-modules-arch"
if [[ $KERNEL == 'linux-lts' ]]; then
rmpkg="$rmpkg $vbx linux"
inpkg="linux-lts"
if [[ $VM ]]; then
inpkg="$inpkg virtualbox-guest-dkms linux-lts-headers"
else
rmpkg="$rmpkg virtualbox-guest-utils"
fi
elif ! [[ $VM ]]; then
rmpkg="$rmpkg $vbx virtualbox-guest-utils"
fi
if [[ $INSTALL_WMS == 'dwm' ]]; then
inpkg="$inpkg xorg-server"
fi
# for gnome and cinnamon we don't need the xfce provided stuff
if [[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
fi
if [[ $BOOTLDR != 'grub' ]]; then
rmpkg="$rmpkg grub"
rm -f $MNT/etc/default/grub
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
fi
local update="pacman -Syyu --noconfirm"
local network="pacman -S iputils --noconfirm"
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
local remove="pacman -Rs $rmpkg --noconfirm"
chroot_cmd "$update; $network; $install; $remove" 2>/dev/null
if [[ $INSTALL_WMS =~ dwm ]]; then
mkdir -pv $MNT/home/$LIVE/suckless
for prog in dwm st dmenu; do
local cmd="git clone https://bitbucket.org/natemaia/$prog /home/$LIVE/suckless/$prog"
chroot_cmd "$cmd; cd /home/$LIVE/suckless/$prog && make clean install && make clean"
done
fi
return 0
}
setup_lightdm() {
local cfg="$MNT/etc/lightdm/lightdm-gtk-greeter.conf"
chroot_cmd 'systemctl enable lightdm.service && systemctl set-default graphical.target'
sed -i '/#background=/ c background=/usr/share/backgrounds/archlabs/archlabs.jpg' $cfg
sed -i '/#theme-name=/ c theme-name=ArchLabs-dARK' $cfg
sed -i '/#icon-theme-name=/ c icon-theme-name=ArchLabs-Light' $cfg
sed -i '/#position=/ c position=34%,end 66%,end' $cfg
sed -i '/#font-name=/ c font-name=DejaVu Sans Mono 11' $cfg
sed -i '/\[greeter]/ a default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png' $cfg
sed -i '/\[greeter]/ a active-monitor=0' $cfg
if [[ $AUTOLOGIN == true ]]; then
chroot_cmd 'groupadd -r nopasswdlogin'
sed -i '/#%PAM-1.0/ a auth sufficient pam_succeed_if.so user ingroup nopasswdlogin' $MNT/etc/pam.d/lightdm
sed -i "/#autologin-session=/ c autologin-session=${LOGIN_WM}" $MNT/etc/lightdm/lightdm.conf
sed -i "/#autologin-user=/ c autologin-user=${NEWUSER}" $MNT/etc/lightdm/lightdm.conf
fi
}

View File

@ -6,6 +6,13 @@
# this file is not meant to be run directly # this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
declare -g LUKS=0
declare -g LUKS_DEV=""
declare -g LUKS_PART=""
declare -g LUKS_PASS=""
declare -g LUKS_UUID=""
declare -g LUKS_NAME="cryptroot"
luks_open() { luks_open() {
LUKS_PART="" LUKS_PART=""
modprobe -a dm-mod dm_crypt modprobe -a dm-mod dm_crypt
@ -42,7 +49,6 @@ luks_pass() {
LUKS_NAME="" LUKS_NAME=""
tput cnorm tput cnorm
local values local values
values="$(dialog --stdout --separator '~' --ok-label "Submit" --backtitle "$BT" \ values="$(dialog --stdout --separator '~' --ok-label "Submit" --backtitle "$BT" \
--title " $title " --insecure --mixedform "$_LuksOpenBody" 16 75 4 \ --title " $title " --insecure --mixedform "$_LuksOpenBody" 16 75 4 \
@ -166,19 +172,17 @@ luks_keyfile() {
if [[ ! -e $MNT/crypto_keyfile.bin ]]; then if [[ ! -e $MNT/crypto_keyfile.bin ]]; then
infobox "$_LuksKeyFileTitle" "$_LuksKeyFileCreate" 0 infobox "$_LuksKeyFileTitle" "$_LuksKeyFileCreate" 0
echo -e "$_LuksKeyFileCreate"
local dev local n
dev="/dev/$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')" n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
local keycmd local mkkey="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin"
keycmd="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin && chmod 000 /crypto_keyfile.bin" mkkey="$mkkey && chmod 000 /crypto_keyfile.bin"
keycmd="$keycmd && echo '$LUKS_PASS' | cryptsetup luksAddKey $dev /crypto_keyfile.bin" mkkey="$mkkey && echo '$LUKS_PASS' | cryptsetup luksAddKey /dev/$n /crypto_keyfile.bin"
chroot_cmd "$keycmd" 2>$ERR
check_for_errors "$keycmd"
chroot_cmd "$mkkey"
sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/g' $MNT/etc/mkinitcpio.conf 2>$ERR sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/g' $MNT/etc/mkinitcpio.conf 2>$ERR
check_for_errors 'sed -i "s/FILES=()/FILES=(/crypto_keyfile.bin)/g" /etc/mkinitcpio.conf'
fi fi
return 0 return 0

View File

@ -6,6 +6,10 @@
# this file is not meant to be run directly # this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
declare -g LVM=0
declare -g VOL_GROUP_MB=0
declare -g GROUP_PARTS=0
lvm_detect() { lvm_detect() {
PHYSICAL_VOLUMES="$(pvs -o pv_name --noheading 2>/dev/null)" PHYSICAL_VOLUMES="$(pvs -o pv_name --noheading 2>/dev/null)"
VOLUME_GROUP="$(vgs -o vg_name --noheading 2>/dev/null)" VOLUME_GROUP="$(vgs -o vg_name --noheading 2>/dev/null)"

View File

@ -29,12 +29,12 @@ mount_main() {
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n" 1 infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n" 1
fi fi
select_boot_setup || { BOOTLOADER=""; return 1; } select_boot_setup || { BOOTLDR=""; return 1; }
if [[ $BOOT_PART != "" ]]; then if [[ $BOOT_PART != "" ]]; then
setup_boot_device setup_boot_device
mount_partition "$BOOT_PART" "${BOOT_MNTS[$SYS-$BOOTLOADER]}" || return 1 mount_partition "$BOOT_PART" "${BMNTS[$SYS-$BOOTLDR]}" || return 1
SEPERATE_BOOT=1 SEPERATE_BOOT=true
fi fi
select_swap || return 1 select_swap || return 1
@ -209,6 +209,8 @@ select_extra_partitions() {
# mount it # mount it
mount_partition "$part" "$EXTRA_MNT" || { break; return 1; } mount_partition "$part" "$EXTRA_MNT" || { break; return 1; }
EXTRA_MNTS="$EXTRA_MNTS $part: $EXTRA_MNT"
# if the mountpoint was /usr add 'usr' to MKINIT_HOOKS # if the mountpoint was /usr add 'usr' to MKINIT_HOOKS
[[ $EXTRA_MNT == "/usr" && $MKINIT_HOOKS != *usr* ]] && MKINIT_HOOKS="usr $MKINIT_HOOKS" [[ $EXTRA_MNT == "/usr" && $MKINIT_HOOKS != *usr* ]] && MKINIT_HOOKS="usr $MKINIT_HOOKS"
done done

View File

@ -1,123 +0,0 @@
#!/usr/bin/bash
# vim:ft=sh:fdm=marker:fmr={,}
# archlabs installer library script file
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
update_system() {
tput cnorm
local pkgcmd
if [[ $KERNEL == 'linux-lts' ]]; then
pkgcmd="pacman -Rs linux --noconfirm ; pacman -S iputils --noconfirm ; pacman -S base-devel git linux-lts --needed --noconfirm"
else
pkgcmd="pacman -S iputils --noconfirm ; pacman -S base-devel git --needed --noconfirm"
fi
pkgcmd="pacman -Rs archlabs-installer --noconfirm ; $pkgcmd"
if [[ $KERNEL == 'linux-lts' && $VM ]]; then
pkgcmd="pacman -Rs virtualbox-guest-modules-arch --noconfirm ; pacman -S virtualbox-guest-dkms linux-lts-headers --noconfirm ; $pkgcmd"
elif ! [[ $VM ]]; then
pkgcmd="pacman -Rs virtualbox-guest-utils virtualbox-guest-modules-arch --noconfirm ; $pkgcmd"
fi
if [[ $BOOTLOADER != 'grub' ]]; then
pkgcmd="$pkgcmd ; pacman -Rs grub --noconfirm"
rm -f $MNT/etc/default/grub
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
fi
chroot_cmd "pacman -Syyu --noconfirm ; $pkgcmd" 2>/dev/null
return 0
}
install_packages() {
tput civis
# packages needed for the selected window manager
for wm in $INSTALL_WMS; do
WM_LOGIN_CHOICES="${WM_LOGIN_CHOICES}$wm - "
case $wm in
openbox) WM_PACKAGES="$WM_PACKAGES $wm obconf archlabs-obkey archlabs-kickshaw tint2 conky" ;;
bspwm) WM_PACKAGES="$WM_PACKAGES $wm sxhkd" ;;
i3-gaps) WM_PACKAGES="$WM_PACKAGES $wm i3status perl-anyevent-i3" ;;
gnome) WM_PACKAGES="$WM_PACKAGES $wm gnome-extra" ;;
cinnamon) WM_PACKAGES="$WM_PACKAGES $wm" ;;
xfce4) WM_PACKAGES="$WM_PACKAGES $wm xfce4-goodies xfce4-pulseaudio-plugin" ;;
esac
done
if [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps) ]]; then
WM_PACKAGES="$WM_PACKAGES termite thunar archlabs-polybar archlabs-screenlock archlabs-skippy-xd archlabs-oblogout lxappearance"
elif [[ $INSTALL_WMS =~ (xfce4) ]]; then
WM_PACKAGES="$WM_PACKAGES archlabs-oblogout archlabs-screenlock"
fi
local pkgs="$WM_PACKAGES"
# add lightdm packages if chosen
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
pkgs="$pkgs lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
fi
# add extra packages
[[ $EXTRA_PACKAGES != "" ]] && pkgs="$pkgs $EXTRA_PACKAGES"
# for gnome and cinnamon we dont need the xfce provided stuff
if [[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
REMOVE_PKGS="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
fi
[[ $INSTALL_WMS =~ dwm ]] && setup_dwm
local pkgcmd="pacman -S $pkgs --needed --noconfirm"
# are we removing some packages
[[ $REMOVE_PKGS != "" ]] && pkgcmd="pacman -Rs $REMOVE_PKGS --noconfirm ; $pkgcmd"
chroot_cmd "$pkgcmd" 2>/dev/null
return 0
}
setup_dwm() {
echo -e "\nSetting up dwm..\n\n"
mkdir -pv $MNT/home/$LIVE/suckless
for prog in dwm st dmenu; do
echo -e "\nInstalling $prog..\n"
git clone https://bitbucket.org/natemaia/$prog $MNT/home/$LIVE/suckless/$prog
chroot_cmd "cd /home/$LIVE/suckless/$prog && sudo make clean install && make clean"
echo -e "\n$prog has been installed..
\nSee /home/$NEWUSER/suckless/$prog to customize and rebuild\n"
done
}
setup_lightdm() {
# due to the user's information not being entered yet at this point, if they chose
# autologin then there is one value in the lightdm config that must be changed later
#
# autologin-user=$USER
echo -e "\nSetting up lightdm..\n"
chroot_cmd 'systemctl enable lightdm.service && systemctl set-default graphical.target'
local cfg="$MNT/etc/lightdm/lightdm-gtk-greeter.conf"
sed -i '/#background=/ c background=/usr/share/backgrounds/archlabs/archlabs.jpg' $cfg
sed -i '/#theme-name=/ c theme-name=ArchLabs-dARK' $cfg
sed -i '/#icon-theme-name=/ c icon-theme-name=ArchLabs-Light' $cfg
sed -i '/#position=/ c position=34%,end 66%,end' $cfg
sed -i '/#font-name=/ c font-name=DejaVu Sans Mono 11' $cfg
sed -i '/\[greeter]/ a default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png' $cfg
sed -i '/\[greeter]/ a active-monitor=0' $cfg
rm -rf $MNT/etc/systemd/system/getty@tty1.service.d
if [[ $AUTOLOGIN == true ]]; then
echo -e "\nSetting up autologin..\n"
chroot_cmd 'groupadd -r nopasswdlogin'
sed -i '/#%PAM-1.0/ a auth sufficient pam_succeed_if.so user ingroup nopasswdlogin' $MNT/etc/pam.d/lightdm
sed -i "/#autologin-session=/ c autologin-session=${LOGIN_WM}" $MNT/etc/lightdm/lightdm.conf
sed -i "/#autologin-user=/ c autologin-user=${NEWUSER}" $MNT/etc/lightdm/lightdm.conf
fi
}

View File

@ -8,7 +8,7 @@
format() { format() {
infobox "$_FSTitle" "\nFormatting: $1\n\nCommand: ${FS_CMDS[$2]}\n" 0 infobox "$_FSTitle" "\nFormatting: $1\n\nCommand: ${FS_CMDS[$2]}\n" 0
${FS_CMDS[$2]} $1 2>$ERR ${FS_CMDS[$2]} $1 >/dev/null 2>$ERR
check_for_errors "${FS_CMDS[$2]} $1" check_for_errors "${FS_CMDS[$2]} $1"
} }