Split the large amount of varaible setup to a lib file
This commit is contained in:
parent
e948933780
commit
432e82f651
@ -12,23 +12,27 @@
|
|||||||
# immutable variables {
|
# immutable variables {
|
||||||
|
|
||||||
readonly DIST="ArchLabs" # Linux distributor
|
readonly DIST="ArchLabs" # Linux distributor
|
||||||
readonly VER="1.6.67" # Installer version
|
readonly VER="1.6.69" # 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
|
||||||
|
|
||||||
readonly EFI="/sys/firmware/efi/efivars"
|
readonly EFI="/sys/firmware/efi/efivars"
|
||||||
readonly LIB="/usr/share/archlabs/installer/lib"
|
|
||||||
readonly TRN="/usr/share/archlabs/installer/lang"
|
readonly TRN="/usr/share/archlabs/installer/lang"
|
||||||
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
||||||
|
|
||||||
readonly VM="$(dmesg | grep -i "hypervisor")"
|
readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||||
|
|
||||||
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
||||||
|
|
||||||
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
||||||
|
|
||||||
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
||||||
|
|
||||||
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
||||||
|
|
||||||
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
||||||
|
|
||||||
if [[ $IGNORE_DEV ]]; then
|
if [[ $IGNORE_DEV ]]; then
|
||||||
readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')"
|
readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')"
|
||||||
else
|
else
|
||||||
@ -43,11 +47,12 @@ elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) ]]; then
|
|||||||
readonly UCODE="amd-ucode.img"
|
readonly UCODE="amd-ucode.img"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create associative array for SUBZONES[zone], value is: 'sub-zone country_code'
|
# create associative array for SUBZONES[zone]
|
||||||
declare -Ag SUBZONES
|
declare -A SUBZONES
|
||||||
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
|
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
|
||||||
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
|
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
|
||||||
done
|
done
|
||||||
|
|
||||||
readonly SUBZONES # make it read only
|
readonly SUBZONES # make it read only
|
||||||
|
|
||||||
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
||||||
@ -71,19 +76,22 @@ 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 BMNTS=(
|
declare -Ar 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]}"
|
|
||||||
|
declare -Ar BOOTLDRS=([BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}"
|
||||||
[UEFI]="grub ${BMNTS[UEFI-grub]} systemd-boot ${BMNTS[UEFI-systemd-boot]} syslinux ${BMNTS[UEFI-syslinux]}"
|
[UEFI]="grub ${BMNTS[UEFI-grub]} systemd-boot ${BMNTS[UEFI-systemd-boot]} syslinux ${BMNTS[UEFI-syslinux]}"
|
||||||
)
|
)
|
||||||
declare -Agr FS_CMDS=(
|
|
||||||
|
declare -Ar 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"
|
||||||
)
|
)
|
||||||
declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
|
|
||||||
|
declare -Ar 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"
|
||||||
[reiserfs]="acl - off nolog - off notail - off replayonly - off user_xattr - off"
|
[reiserfs]="acl - off nolog - off notail - off replayonly - off user_xattr - off"
|
||||||
@ -91,41 +99,43 @@ declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
|
|||||||
[nilfs2]="discard - off nobarrier - off errors=continue - off errors=panic - off order=relaxed - off order=strict - off norecovery - off"
|
[nilfs2]="discard - off nobarrier - off errors=continue - off errors=panic - off order=relaxed - off order=strict - off norecovery - off"
|
||||||
[f2fs]="data_flush - off disable_roll_forward - off disable_ext_identify - off discard - off fastboot - off flush_merge - off inline_xattr - off inline_data - off inline_dentry - off no_heap - off noacl - off nobarrier - off noextent_cache - off noinline_data - off norecovery - off"
|
[f2fs]="data_flush - off disable_roll_forward - off disable_ext_identify - off discard - off fastboot - off flush_merge - off inline_xattr - off inline_data - off inline_dentry - off no_heap - off noacl - off nobarrier - off noextent_cache - off noinline_data - off norecovery - off"
|
||||||
)
|
)
|
||||||
|
|
||||||
# }
|
# }
|
||||||
|
|
||||||
init_variables() {
|
init_variables() {
|
||||||
declare -g BT="$DIST Installer - (x86_64) - Version $VER"
|
BT="$DIST Installer - (x86_64) - Version $VER"
|
||||||
declare -g ROOT_PART=""
|
ROOT_PART=""
|
||||||
declare -g BOOT_DEVICE=""
|
BOOT_DEVICE=""
|
||||||
declare -g BOOT_PART=""
|
BOOT_PART=""
|
||||||
declare -g BOOTLDR=""
|
BOOTLDR=""
|
||||||
declare -g EXTRA_MNT=""
|
EXTRA_MNT=""
|
||||||
declare -g EXTRA_MNTS=""
|
EXTRA_MNTS=""
|
||||||
declare -g SWAP="none"
|
SWAP="none"
|
||||||
declare -g SWAP_SIZE="${SYS_MEM}M"
|
SWAP_SIZE="${SYS_MEM}M"
|
||||||
declare -g NEWUSER=""
|
NEWUSER=""
|
||||||
declare -g USER_PASS=""
|
USER_PASS=""
|
||||||
declare -g ROOT_PASS=""
|
ROOT_PASS=""
|
||||||
declare -g LOGIN_WM=""
|
LOGIN_WM=""
|
||||||
declare -g LOGIN_TYPE=""
|
LOGIN_TYPE=""
|
||||||
declare -g INSTALL_WMS=""
|
INSTALL_WMS=""
|
||||||
declare -g KERNEL="linux"
|
KERNEL="linux"
|
||||||
declare -g WM_PACKAGES=""
|
WM_PACKAGES=""
|
||||||
declare -g EXTRA_PACKAGES=""
|
EXTRA_PACKAGES=""
|
||||||
declare -g MKINIT_HOOKS="shutdown"
|
MKINIT_HOOKS="shutdown"
|
||||||
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
||||||
|
|
||||||
declare -g IS_64BIT=false
|
IS_64BIT=false
|
||||||
declare -g AUTOLOGIN=false
|
AUTOLOGIN=false
|
||||||
declare -g CONFIG_DONE=false
|
CONFIG_DONE=false
|
||||||
declare -g SEPERATE_BOOT=false
|
SEPERATE_BOOT=false
|
||||||
|
|
||||||
declare -Ag BCMDS=(
|
declare -A BCMDS=(
|
||||||
[syslinux]="syslinux-install_update -iam"
|
[syslinux]="syslinux-install_update -iam"
|
||||||
[grub]="grub-install --recheck --force"
|
[grub]="grub-install --recheck --force"
|
||||||
[systemd-boot]="bootctl --path=${BMNTS[UEFI-systemd-boot]} install"
|
[systemd-boot]="bootctl --path=/boot install"
|
||||||
)
|
)
|
||||||
declare -Ag FILES=(
|
|
||||||
|
declare -A FILES=(
|
||||||
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
|
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
|
||||||
[3]="/etc/locale.conf /etc/default/locale"
|
[3]="/etc/locale.conf /etc/default/locale"
|
||||||
[4]="/etc/hostname /etc/hosts"
|
[4]="/etc/hostname /etc/hosts"
|
||||||
@ -139,15 +149,9 @@ init_variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source_file() {
|
source_file() {
|
||||||
. $1 2>/dev/null && return 0
|
. $1 2>/dev/null && return 0 || { echo -e "\nFailed to source library file $1"; die 1; }
|
||||||
echo -e "\nFailed to source library file $1"
|
|
||||||
die 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## Setup ##
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
user_setup() {
|
user_setup() {
|
||||||
tput cnorm
|
tput cnorm
|
||||||
|
|
||||||
@ -212,7 +216,7 @@ select_language() {
|
|||||||
"9" "Magyar (hu_HU)" "10" "Chinese (zh_CN)")
|
"9" "Magyar (hu_HU)" "10" "Chinese (zh_CN)")
|
||||||
|
|
||||||
source_file $TRN/english.trans
|
source_file $TRN/english.trans
|
||||||
declare -g FONT="ter-i16n"
|
FONT="ter-i16n"
|
||||||
|
|
||||||
case $lang in
|
case $lang in
|
||||||
1) LOC="en_US.UTF-8" ;;
|
1) LOC="en_US.UTF-8" ;;
|
||||||
@ -241,7 +245,6 @@ select_language() {
|
|||||||
|
|
||||||
setup_keymap() {
|
setup_keymap() {
|
||||||
tput civis
|
tput civis
|
||||||
declare -g KEYMAP
|
|
||||||
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 $KEYMAPS)"
|
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 $KEYMAPS)"
|
||||||
[[ $? != 0 || $KEYMAP == "" ]] && return 1
|
[[ $? != 0 || $KEYMAP == "" ]] && return 1
|
||||||
@ -266,13 +269,11 @@ setup_keymap() {
|
|||||||
|
|
||||||
setup_timezone() {
|
setup_timezone() {
|
||||||
tput civis
|
tput civis
|
||||||
declare -g ZONE
|
|
||||||
ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 America - Australia - \
|
--title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 America - Australia - \
|
||||||
Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -)"
|
Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -)"
|
||||||
[[ $? != 0 || $ZONE == "" ]] && return 1
|
[[ $? != 0 || $ZONE == "" ]] && return 1
|
||||||
|
|
||||||
declare -g SUBZONE
|
|
||||||
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"
|
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"
|
||||||
[[ $? != 0 || $SUBZONE == "" ]] && return 1
|
[[ $? != 0 || $SUBZONE == "" ]] && return 1
|
||||||
@ -471,13 +472,10 @@ mirrorlist_cmd() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## Menus ##
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
display_selection() {
|
display_selection() {
|
||||||
local msg="Configuration values used for install
|
local msg="Configuration values used for install
|
||||||
|
|
||||||
|
|
||||||
Root Partition: $ROOT_PART
|
Root Partition: $ROOT_PART
|
||||||
Boot Partition: $BOOT_PART
|
Boot Partition: $BOOT_PART
|
||||||
|
|
||||||
@ -510,12 +508,10 @@ Packages: $EXTRA_PACKAGES"
|
|||||||
|
|
||||||
configure_install() {
|
configure_install() {
|
||||||
tput cnorm
|
tput cnorm
|
||||||
declare -g HOSTNAME
|
|
||||||
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
|
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
|
||||||
[[ $? != 0 || $HOSTNAME == "" ]] && return 1
|
[[ $? != 0 || $HOSTNAME == "" ]] && return 1
|
||||||
|
|
||||||
tput civis
|
tput civis
|
||||||
declare -g LOCALE
|
|
||||||
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
|
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
|
||||||
[[ $? != 0 || $LOCALE == "" ]] && return 1
|
[[ $? != 0 || $LOCALE == "" ]] && return 1
|
||||||
@ -525,11 +521,8 @@ configure_install() {
|
|||||||
user_setup || return 1
|
user_setup || return 1
|
||||||
window_manager || return 1
|
window_manager || return 1
|
||||||
|
|
||||||
if yesno 'Choose Kernel' "\nUse the current Linux kernel or the LTS kernel?\n" 'Current' 'LTS'; then
|
local msg="\nUse the current Linux kernel or the LTS kernel?\n"
|
||||||
KERNEL='linux'
|
yesno 'Choose Kernel' "$msg" 'Current' 'LTS' && KERNEL='linux' || KERNEL='linux-lts'
|
||||||
else
|
|
||||||
KERNEL='linux-lts'
|
|
||||||
fi
|
|
||||||
|
|
||||||
extra_packages || return 1
|
extra_packages || return 1
|
||||||
CONFIG_DONE=true
|
CONFIG_DONE=true
|
||||||
@ -541,7 +534,7 @@ edit_configs() {
|
|||||||
MENU_HIGHLIGHT=1
|
MENU_HIGHLIGHT=1
|
||||||
CURRENT_MENU="edit"
|
CURRENT_MENU="edit"
|
||||||
elif (( MENU_HIGHLIGHT < 10 )); then
|
elif (( MENU_HIGHLIGHT < 10 )); then
|
||||||
((MENU_HIGHLIGHT++))
|
(( MENU_HIGHLIGHT++ ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tput civis
|
tput civis
|
||||||
@ -550,8 +543,9 @@ edit_configs() {
|
|||||||
"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" "$BOOTLDR" "10" "pacman.conf" \
|
"6" "mkinitcpio.conf" "7" "fstab" "8" "crypttab" "9" "$BOOTLDR" "10" "pacman.conf" \
|
||||||
"11" "$LOGIN_TYPE")
|
"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" 'Reboot' 'Back' 'reboot'
|
||||||
else
|
else
|
||||||
local existing_files=""
|
local existing_files=""
|
||||||
for f in $(echo "${FILES[$MENU_HIGHLIGHT]}"); do
|
for f in $(echo "${FILES[$MENU_HIGHLIGHT]}"); do
|
||||||
@ -559,11 +553,7 @@ edit_configs() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ $existing_files != "" ]]; then
|
if [[ $existing_files != "" ]]; then
|
||||||
if [[ $DISPLAY && $TERM != 'linux' ]] && hash geany >/dev/null 2>&1; then
|
vim -O $existing_files
|
||||||
geany -i $existing_files
|
|
||||||
else
|
|
||||||
vim -O $existing_files
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
msgbox "$_ErrTitle" "$_NoFileErr"
|
msgbox "$_ErrTitle" "$_NoFileErr"
|
||||||
fi
|
fi
|
||||||
@ -606,15 +596,16 @@ main() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
for file in utils mount boot lvm luks install; do
|
for file in /usr/share/archlabs/installer/lib/?*.sh; do
|
||||||
source_file $LIB/$file.sh
|
source_file $file
|
||||||
done
|
done
|
||||||
|
|
||||||
trap sigint INT # trap Ctrl-C and call sigint() to properly exit
|
# trap Ctrl-C to properly exit
|
||||||
|
trap sigint INT
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in $@; do case $arg in
|
||||||
[[ $arg == "--debug" || $arg == "-d" ]] && debug
|
--debug|-d) debug ;;
|
||||||
done
|
esac done
|
||||||
|
|
||||||
init_variables
|
init_variables
|
||||||
select_language
|
select_language
|
||||||
|
@ -42,32 +42,34 @@ shim_secure_boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uefi_boot_fallback() {
|
uefi_boot_fallback() {
|
||||||
# some UEFI firmware is finicky and requires a specific folder in
|
# some UEFI firmware requires a directory in the ESP and a generic bootx64.efi
|
||||||
# /boot/efi/EFI/ and named 'boot', 'Boot', or 'BOOT'
|
# see: https://wiki.archlinux.org/index.php/GRUB#UEFI
|
||||||
# copy the bootloaders efi stub to that directory as bootx64.efi
|
# also: https://wiki.archlinux.org/index.php/syslinux#UEFI_Systems
|
||||||
|
|
||||||
local boot_dir="$DIST"
|
|
||||||
[[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
|
|
||||||
|
|
||||||
local default="boot"
|
|
||||||
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
|
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
|
||||||
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; }
|
|
||||||
done
|
|
||||||
|
|
||||||
[[ -d $esp/EFI/$default ]] && rm -f $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
|
local default
|
||||||
|
default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d)"
|
||||||
|
[[ $default ]] && default="$(basename $default)" || default="boot"
|
||||||
|
|
||||||
if [[ $1 == 'syslinux' ]]; then
|
# directory exists: remove everything inside, otherwise mkdir it
|
||||||
cp -rf $esp/EFI/$boot_dir/* $esp/EFI/$default/
|
[[ -d $esp/EFI/$default ]] && rm -rf $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
|
||||||
cp -f $esp/EFI/$boot_dir/syslinux.efi $esp/EFI/$default/bootx64.efi
|
|
||||||
else
|
# copy efi stub to the new default location
|
||||||
local grub_file="grubx64.efi"
|
if [[ $BOOTLDR == 'syslinux' ]]; then
|
||||||
local boot_file="bootx64.efi"
|
# syslinux requires the whole boot setup be copied, not just the stub
|
||||||
|
cp -rf $esp/EFI/syslinux/* $esp/EFI/$default/
|
||||||
|
cp -f $esp/EFI/syslinux/syslinux.efi $esp/EFI/$default/bootx64.efi
|
||||||
|
elif [[ $BOOTLDR == 'grub' ]]; then
|
||||||
|
# grub uses different names for the stub depending on architecture
|
||||||
if [[ $IS_64BIT != true ]]; then
|
if [[ $IS_64BIT != true ]]; then
|
||||||
local grub_file="grubia32.efi"
|
local grub_file="grubia32.efi"
|
||||||
local boot_file="bootia32.efi"
|
local boot_file="bootia32.efi"
|
||||||
|
else
|
||||||
|
local grub_file="grubx64.efi"
|
||||||
|
local boot_file="bootx64.efi"
|
||||||
fi
|
fi
|
||||||
cp -f $esp/EFI/$boot_dir/$grub_file $esp/EFI/$default/$boot_file
|
cp -f $esp/EFI/$DIST/$grub_file $esp/EFI/$default/$boot_file
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -101,12 +103,8 @@ prep_for_grub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prep_for_systemd-boot() {
|
prep_for_systemd-boot() {
|
||||||
local ucode="$1"
|
|
||||||
|
|
||||||
# no LVM then systemd-boot uses PARTUUID
|
# no LVM then systemd-boot uses PARTUUID
|
||||||
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
! [[ $ROOT_PART =~ /dev/mapper ]] && ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||||
ROOT_PART_ID="PART$ROOT_PART_ID"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create the boot entry configs
|
# create the boot entry configs
|
||||||
mkdir -p $MNT/boot/loader/entries
|
mkdir -p $MNT/boot/loader/entries
|
||||||
@ -118,7 +116,7 @@ EOF
|
|||||||
|
|
||||||
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
|
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
|
||||||
title $DIST Linux
|
title $DIST Linux
|
||||||
linux /vmlinuz-${KERNEL}$([[ $ucode ]] && echo -en "\ninitrd /$ucode")
|
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && echo -en "\ninitrd /$UCODE")
|
||||||
initrd /initramfs-$KERNEL.img
|
initrd /initramfs-$KERNEL.img
|
||||||
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
|
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
|
||||||
EOF
|
EOF
|
||||||
@ -142,7 +140,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
prep_for_syslinux() {
|
prep_for_syslinux() {
|
||||||
local ucode="$1"
|
|
||||||
local cfgdir="$MNT/boot/syslinux"
|
local cfgdir="$MNT/boot/syslinux"
|
||||||
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
||||||
FILES[9]="/boot/syslinux/syslinux.cfg"
|
FILES[9]="/boot/syslinux/syslinux.cfg"
|
||||||
@ -169,21 +166,19 @@ MENU LABEL $DIST Linux
|
|||||||
LINUX ../vmlinuz-$KERNEL
|
LINUX ../vmlinuz-$KERNEL
|
||||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
||||||
INITRD ../initramfs-$KERNEL.img
|
INITRD ../initramfs-$KERNEL.img
|
||||||
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
|
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
|
||||||
|
|
||||||
LABEL ${DIST}fallback
|
LABEL ${DIST}fallback
|
||||||
MENU LABEL $DIST Linux Fallback
|
MENU LABEL $DIST Linux Fallback
|
||||||
LINUX ../vmlinuz-$KERNEL
|
LINUX ../vmlinuz-$KERNEL
|
||||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
||||||
INITRD ../initramfs-$KERNEL-fallback.img
|
INITRD ../initramfs-$KERNEL-fallback.img
|
||||||
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
|
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
|
||||||
EOF
|
EOF
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_bootloader() {
|
install_bootloader() {
|
||||||
chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl"
|
|
||||||
|
|
||||||
# not an LVM we can use the UUID for booting otherwise use the partition label
|
# not an LVM we can use the UUID for booting otherwise use the partition label
|
||||||
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')"
|
||||||
@ -191,21 +186,12 @@ install_bootloader() {
|
|||||||
ROOT_PART_ID="$ROOT_PART"
|
ROOT_PART_ID="$ROOT_PART"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# needed for os-prober module to work properly in the chroot
|
# remove old UEFI boot entries
|
||||||
mkdir -p $MNT/run && mount --rbind /run $MNT/run/
|
[[ $SYS == 'UEFI' ]] && find $MNT${BMNTS[$SYS-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \
|
||||||
|
-name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||||
# make sure efivarfs has been mounted and remove old boot entries
|
|
||||||
if [[ $SYS == 'UEFI' ]]; then
|
|
||||||
mount -o remount,rw -t efivarfs efivarfs $EFI >/dev/null 2>&1
|
|
||||||
BCMDS[$BOOTLDR]="mount -o remount,rw -t efivarfs efivarfs $EFI; ${BCMDS[$BOOTLDR]}"
|
|
||||||
|
|
||||||
local esp="$MNT/boot/efi/EFI/"
|
|
||||||
[[ ! -d $MNT/boot/efi/EFI && -d $MNT/boot/EFI ]] && esp="$MNT/boot/EFI/"
|
|
||||||
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
|
|
||||||
|
|
||||||
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
|
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
|
||||||
prep_for_$BOOTLDR "$UCODE"
|
prep_for_$BOOTLDR
|
||||||
|
|
||||||
# run the bootloader command
|
# run the bootloader command
|
||||||
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
||||||
|
@ -51,11 +51,11 @@ install_base() {
|
|||||||
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
|
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
|
||||||
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
|
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
|
||||||
|
|
||||||
# for virtual machines remove configs for xorg, these cause mouse issues
|
|
||||||
if [[ $VM ]]; then
|
if [[ $VM ]]; then
|
||||||
|
# in a VM remove xorg configs, these cause issues
|
||||||
rm -rf $MNT/etc/X11/xorg.conf.d
|
rm -rf $MNT/etc/X11/xorg.conf.d
|
||||||
elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
|
elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
|
||||||
# setup xorg vsync config for intel graphics
|
# xorg config for intel, this should never happen in a VM
|
||||||
cat > $MNT/etc/X11/xorg.conf.d/20-intel.conf <<EOF
|
cat > $MNT/etc/X11/xorg.conf.d/20-intel.conf <<EOF
|
||||||
Section "Device"
|
Section "Device"
|
||||||
Identifier "Intel Graphics"
|
Identifier "Intel Graphics"
|
||||||
@ -71,11 +71,6 @@ EOF
|
|||||||
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
|
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
|
||||||
[[ $UCODE ]] && cp -f $RUN/${UCODE/-/_} $MNT/boot/$UCODE
|
[[ $UCODE ]] && cp -f $RUN/${UCODE/-/_} $MNT/boot/$UCODE
|
||||||
|
|
||||||
setup_configs
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_configs() {
|
|
||||||
# copy network settings
|
# copy network settings
|
||||||
cp -rf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
|
cp -rf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
|
||||||
cp -f /etc/resolv.conf $MNT/etc/
|
cp -f /etc/resolv.conf $MNT/etc/
|
||||||
@ -124,7 +119,7 @@ EOF
|
|||||||
|
|
||||||
create_user() {
|
create_user() {
|
||||||
local _home="$MNT/home/$LIVE"
|
local _home="$MNT/home/$LIVE"
|
||||||
local serve="$MNT/etc/systemd/system/getty@tty1.service.d"
|
local service="$MNT/etc/systemd/system/getty@tty1.service.d"
|
||||||
|
|
||||||
# set root password
|
# set root password
|
||||||
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
|
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
|
||||||
@ -138,29 +133,22 @@ create_user() {
|
|||||||
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
||||||
[[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
|
[[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
|
||||||
rm -rf $_home/.{zprofile,xinitrc}
|
rm -rf $_home/.{zprofile,xinitrc}
|
||||||
rm -rf $serve
|
rm -rf $service
|
||||||
else
|
else
|
||||||
if [[ $AUTOLOGIN == true ]]; then
|
if [[ $AUTOLOGIN == true ]]; then
|
||||||
sed -i "s/${LIVE}/${NEWUSER}/g" $serve/autologin.conf
|
sed -i "s/${LIVE}/${NEWUSER}/g" $service/autologin.conf
|
||||||
|
else
|
||||||
|
rm -rf $service
|
||||||
fi
|
fi
|
||||||
sed -i "s/openbox-session/${LOGIN_WM}/g" $_home/.xinitrc
|
sed -i "s/openbox-session/${LOGIN_WM}/g" $_home/.xinitrc
|
||||||
sed -i '/archlabs-installer/d' $_home/.zprofile
|
sed -i 's|exec sudo archlabs-installer|exec startx -- vt1 &>/dev/null|' $_home/.zprofile
|
||||||
cat >> $_home/.zprofile << EOF
|
|
||||||
[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.config/gtk-3.0/bookmarks
|
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.config/gtk-3.0/bookmarks $_home/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js
|
||||||
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
|
! [[ $INSTALL_WMS =~ openbox ]] && rm -rf $_home/.config/{openbox}
|
||||||
rm -rf $_home/.config/openbox
|
! [[ $INSTALL_WMS =~ bspwm ]] && rm -rf $_home/.config/{bspwm,sxhkd}
|
||||||
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
|
! [[ $INSTALL_WMS =~ i3-gaps ]] && rm -rf $_home/.config/i3
|
||||||
rm -rf $_home/.config/{bspwm,sxhkd}
|
|
||||||
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
|
|
||||||
rm -rf $_home/.config/i3
|
|
||||||
fi
|
|
||||||
|
|
||||||
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
|
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
|
||||||
chroot_cmd "usermod -aG $groups $NEWUSER"
|
chroot_cmd "usermod -aG $groups $NEWUSER"
|
||||||
@ -172,9 +160,7 @@ EOF
|
|||||||
|
|
||||||
run_mkinitcpio() {
|
run_mkinitcpio() {
|
||||||
# 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 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]]; then
|
[[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
|
||||||
luks_keyfile
|
|
||||||
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
|
local add
|
||||||
@ -182,6 +168,7 @@ run_mkinitcpio() {
|
|||||||
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
|
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
|
||||||
|
|
||||||
local conf="$MNT/etc/mkinitcpio.conf"
|
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
|
||||||
@ -210,27 +197,25 @@ update_system() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# for gnome and cinnamon we don't need the xfce provided stuff
|
# for gnome and cinnamon we don't need the xfce provided stuff
|
||||||
if [[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
|
[[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]] && rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
|
||||||
rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $BOOTLDR != 'grub' ]]; then
|
if [[ $BOOTLDR != 'grub' ]]; then
|
||||||
rmpkg="$rmpkg grub"
|
rmpkg="$rmpkg grub"
|
||||||
rm -f $MNT/etc/default/grub
|
rm -f $MNT/etc/default/grub
|
||||||
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||||
|
elif [[ $BOOTLDR != 'syslinux' ]]; then
|
||||||
|
find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local update="pacman -Syyu --noconfirm"
|
|
||||||
local network="pacman -S iputils --noconfirm"
|
|
||||||
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
|
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
|
||||||
local remove="pacman -Rs $rmpkg --noconfirm"
|
local remove="pacman -Rs $rmpkg --noconfirm"
|
||||||
|
|
||||||
chroot_cmd "$update; $network; $install; $remove" 2>/dev/null
|
chroot_cmd "pacman -Syyu --noconfirm; pacman -S iputils --noconfirm; $install; $remove" 2>/dev/null
|
||||||
|
|
||||||
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
|
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
|
||||||
mkdir -p $MNT/home$LIVE/.config/nvim
|
mkdir -p $MNT/home/$LIVE/.config/nvim
|
||||||
cp -f $MNT/home/$LIVE/.vimrc $MNT/home$LIVE/.config/nvim/init.vim
|
cp -f $MNT/home/$LIVE/.vimrc $MNT/home/$LIVE/.config/nvim/init.vim
|
||||||
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home$LIVE/.config/nvim/colors
|
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home/$LIVE/.config/nvim/colors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $INSTALL_WMS =~ dwm ]]; then
|
if [[ $INSTALL_WMS =~ dwm ]]; then
|
||||||
|
Reference in New Issue
Block a user