Fix format asking permission and other small issues
This commit is contained in:
parent
224ea1c18a
commit
0e51c6ce6a
@ -3,22 +3,16 @@
|
||||
# vim:ft=sh:fdm=marker:fmr={,}
|
||||
|
||||
# This program is free software, provided under the GNU GPL
|
||||
|
||||
# Written by Nathaniel Maia for use in Archlabs
|
||||
# Some ideas and code were taken from other installers
|
||||
# AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due
|
||||
|
||||
# dry run performing no action, good for checking syntax errors
|
||||
# set -n
|
||||
|
||||
######################################################################
|
||||
## Script Setup Functions ##
|
||||
######################################################################
|
||||
|
||||
# immutable variables {
|
||||
|
||||
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 MNT="/mnt/install" # Install mountpoint
|
||||
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 TRN="/usr/share/archlabs/installer/lang"
|
||||
|
||||
# hardware check
|
||||
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 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'
|
||||
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
|
||||
az Azerbaijani"
|
||||
|
||||
declare -Agr BOOT_MNTS=(
|
||||
declare -Agr BMNTS=(
|
||||
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
|
||||
[BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot"
|
||||
)
|
||||
|
||||
# static list of bootloaders & boot partition mountpoints stored as the system type (BIOS or UEFI)
|
||||
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]}"
|
||||
declare -Agr 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]}"
|
||||
)
|
||||
|
||||
# static mkfs commands for each filesystem offered
|
||||
declare -Agr FS_CMDS=(
|
||||
[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"
|
||||
[ntfs]="mkfs.ntfs -q" [reiserfs]="mkfs.reiserfs -q" [vfat]="mkfs.vfat -F32"
|
||||
)
|
||||
|
||||
# static filesystem mount options
|
||||
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"
|
||||
[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() {
|
||||
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
|
||||
|
||||
init_variables() {
|
||||
declare -g BT="$DIST Installer - (x86_64) - Version $VER"
|
||||
declare -g ROOT_PART=""
|
||||
declare -g BOOT_DEVICE=""
|
||||
declare -g BOOT_PART=""
|
||||
declare -g BOOTLOADER=""
|
||||
declare -g BOOTLDR=""
|
||||
declare -g EXTRA_MNT=""
|
||||
declare -g EXTRA_MNTS=""
|
||||
declare -g SWAP="none"
|
||||
declare -g SWAP_SIZE="${SYS_MEM}M"
|
||||
declare -g KERNEL="linux"
|
||||
declare -g NEWUSER=""
|
||||
declare -g USER_PASS=""
|
||||
declare -g ROOT_PASS=""
|
||||
declare -g LOGIN_WM=""
|
||||
declare -g LOGIN_TYPE=""
|
||||
declare -g INSTALL_WMS=""
|
||||
declare -g KERNEL="linux"
|
||||
declare -g WM_PACKAGES=""
|
||||
declare -g EXTRA_PACKAGES=""
|
||||
declare -g REMOVE_PKGS=""
|
||||
declare -g CURRENT_MENU=""
|
||||
declare -g MENU_HIGHLIGHT
|
||||
declare -g EDITOR_CHOICE=""
|
||||
declare -g MKINIT_HOOKS="shutdown"
|
||||
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 CONFIG_DONE=false
|
||||
declare -g IS_64BIT=false
|
||||
declare -g SEPERATE_BOOT=false
|
||||
|
||||
# Commands used to install each bootloader.
|
||||
# NOTE: syslinux and grub in particular can/will change during runtime
|
||||
declare -Ag BOOT_CMDS=(
|
||||
declare -Ag BCMDS=(
|
||||
[syslinux]="syslinux-install_update -iam"
|
||||
[grub]="grub-install --recheck --force"
|
||||
[systemd-boot]="bootctl --path=${BOOT_MNTS[UEFI-systemd-boot]} install"
|
||||
[systemd-boot]="bootctl --path=${BMNTS[UEFI-systemd-boot]} install"
|
||||
)
|
||||
|
||||
# files able to be reviewed when finishing install
|
||||
# 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"
|
||||
declare -Ag FILES=(
|
||||
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
|
||||
[3]="/etc/locale.conf /etc/default/locale"
|
||||
[4]="/etc/hostname /etc/hosts"
|
||||
[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() {
|
||||
tput civis
|
||||
local lang
|
||||
@ -272,58 +279,6 @@ setup_hostname() {
|
||||
[[ $? != 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() {
|
||||
LOGIN_WM=""
|
||||
LOGIN_TYPE=""
|
||||
@ -342,11 +297,39 @@ window_manager() {
|
||||
INSTALL_WMS="${INSTALL_WMS:-openbox}"
|
||||
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 yesno "$_WMLogin" "$_LoginTypeBody\n" "xinit" "lightdm"; then
|
||||
LOGIN_TYPE='lightdm'
|
||||
else
|
||||
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
|
||||
|
||||
if yesno "$_WMLogin" "$_AutoLoginBody\n"; then
|
||||
@ -375,7 +358,8 @@ window_manager() {
|
||||
}
|
||||
|
||||
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 \
|
||||
"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 \
|
||||
@ -448,9 +432,9 @@ extra_packages() {
|
||||
"ttf-fira-code" "Monospaced font with programming ligatures" off \
|
||||
"noto-fonts-cjk" "Google Noto CJK fonts (Chinese, Japanese, Korean)" 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
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
if [[ $CURRENT_MENU != "edit" ]]; then
|
||||
MENU_HIGHLIGHT=1
|
||||
@ -512,13 +544,14 @@ edit_configs() {
|
||||
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_EditTitle " --default-item $MENU_HIGHLIGHT --menu "$_EditBody" 0 0 0 \
|
||||
"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
|
||||
wrap_up "$_InstFinBody" 'Exit & Reboot' 'Go Back' 'reboot'
|
||||
else
|
||||
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"
|
||||
done
|
||||
|
||||
@ -536,20 +569,6 @@ 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() {
|
||||
local retval
|
||||
|
||||
@ -563,12 +582,13 @@ main() {
|
||||
tput civis
|
||||
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepTitle " --default-item $MENU_HIGHLIGHT --menu "$_PrepBody" 0 0 0 \
|
||||
"1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \
|
||||
"5" "$_PrepMount" "6" "$_PrepConfig" "7" "$_PrepInstall" "8" "$_Done")
|
||||
"1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \
|
||||
"5" "$_PrepMount" "6" "$_PrepConfig" "7" "Check Selections" "8" "$_PrepInstall" \
|
||||
"9" "$_Done")
|
||||
|
||||
# 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
|
||||
if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 7 ]]; then
|
||||
if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 8 ]]; then
|
||||
check_install_ready
|
||||
retval=$?
|
||||
[[ $retval -gt 0 ]] && { MENU_HIGHLIGHT=$retval; return 1; }
|
||||
@ -581,36 +601,27 @@ main() {
|
||||
4) lvm_menu || MENU_HIGHLIGHT=1 ;;
|
||||
5) mount_main || MENU_HIGHLIGHT=1 ;;
|
||||
6) configure_install ;;
|
||||
7) install_main && edit_configs ;;
|
||||
7) display_selection ;;
|
||||
8) install_main && edit_configs ;;
|
||||
*) wrap_up "$_CloseInstBody" 'Exit' 'Back' 'exit'
|
||||
esac
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## Execution ##
|
||||
######################################################################
|
||||
|
||||
# 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
|
||||
for file in utils mount partition bootloader lvm luks install; do
|
||||
source_file $LIB/$file.sh
|
||||
done
|
||||
|
||||
# trap ctrl-c and call sigint() to properly exit, without this
|
||||
# exiting via Ctrl-c can leave the terminal in a messed up state
|
||||
trap sigint INT
|
||||
trap sigint INT # trap Ctrl-C and call sigint() to properly exit
|
||||
|
||||
for arg in "$@"; do
|
||||
[[ $arg == "--debug" || $arg == "-d" ]] && debug # from $LIB/utils.sh
|
||||
[[ $arg == "--debug" || $arg == "-d" ]] && debug
|
||||
done
|
||||
|
||||
initialize_variables
|
||||
luks_variable_init
|
||||
init_variables
|
||||
select_language
|
||||
setup_keymap
|
||||
|
||||
check_requirements
|
||||
identify_system
|
||||
|
||||
msgbox "$_WelTitle $DIST Installer" "$_WelBody"
|
||||
|
||||
while true; do
|
||||
|
@ -9,25 +9,25 @@
|
||||
select_boot_setup() {
|
||||
# choose bootloader and by extension mountpoint (if needed)
|
||||
tput civis
|
||||
BOOTLOADER="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLOADERS[$SYS]})"
|
||||
[[ $? != 0 || $BOOTLOADER == "" ]] && return 1
|
||||
BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"
|
||||
[[ $? != 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
|
||||
select_device 'boot' || return 1
|
||||
fi
|
||||
|
||||
if [[ $BOOTLOADER == 'systemd-boot' ]]; then
|
||||
EDIT_FILES[9]="/boot/loader/entries/$DIST.conf"
|
||||
elif [[ $BOOTLOADER == 'syslinux' && $SYS == 'BIOS' ]]; then
|
||||
BOOT_CMDS[$BOOTLOADER]="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
if [[ $BOOTLDR == 'systemd-boot' ]]; then
|
||||
FILES[9]="/boot/loader/entries/$DIST.conf"
|
||||
elif [[ $BOOTLDR == 'syslinux' && $SYS == 'BIOS' ]]; then
|
||||
BCMDS[$BOOTLDR]="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_InstSysTitle " --menu "$_InstSysBody" 0 0 0 \
|
||||
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
|
||||
"syslinux-install_update -i" "Install to root partition (/)")"
|
||||
[[ $? != 0 || ${BOOT_CMDS[$BOOTLOADER]} == "" ]] && return 1
|
||||
[[ $? != 0 || ${BCMDS[$BOOTLDR]} == "" ]] && return 1
|
||||
else
|
||||
EDIT_FILES[9]="/etc/default/grub"
|
||||
FILES[9]="/etc/default/grub"
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -38,7 +38,7 @@ shim_secure_boot() {
|
||||
|
||||
local shim_file="shim64.efi"
|
||||
[[ $IS_64BIT != true ]] && shim_file="shim.efi"
|
||||
efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${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
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ uefi_boot_fallback() {
|
||||
# copy the bootloaders efi stub to that directory as bootx64.efi
|
||||
|
||||
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
|
||||
grep -qi "boot" <<< "$(basename $i)" && { default="$(basename $i)"; break; }
|
||||
done
|
||||
@ -75,27 +75,27 @@ uefi_boot_fallback() {
|
||||
}
|
||||
|
||||
prep_for_grub() {
|
||||
local ttype
|
||||
local cfg="$MNT/etc/default/grub"
|
||||
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
local gtype='x86_64-efi'
|
||||
[[ $IS_64BIT != true ]] && gtype='i386-efi'
|
||||
BOOT_CMDS[grub]="${BOOT_CMDS[grub]} --target=$gtype --bootloader-id=$DIST"
|
||||
[[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
|
||||
else
|
||||
BOOT_CMDS[grub]="${BOOT_CMDS[grub]} --target=i386-pc $BOOT_DEVICE"
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
|
||||
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;
|
||||
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;
|
||||
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg
|
||||
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
|
||||
fi
|
||||
|
||||
@ -138,11 +138,11 @@ EOF
|
||||
prep_for_syslinux() {
|
||||
local cfgdir="$MNT/boot/syslinux"
|
||||
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
||||
EDIT_FILES[9]="/boot/syslinux/syslinux.cfg"
|
||||
FILES[9]="/boot/syslinux/syslinux.cfg"
|
||||
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
EDIT_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"
|
||||
FILES[9]="/boot/EFI/syslinux/syslinux.cfg"
|
||||
BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
|
||||
cfgdir="$MNT/boot/EFI/syslinux"
|
||||
cfgsrcdir="/usr/lib/syslinux/efi64/"
|
||||
fi
|
||||
@ -177,27 +177,29 @@ EOF
|
||||
install_bootloader() {
|
||||
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"
|
||||
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 ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
||||
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
|
||||
# for LVM use the partition name eg. /dev/mapper/cryptroot
|
||||
ROOT_PART_ID="$ROOT_PART"
|
||||
fi
|
||||
|
||||
# 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
|
||||
BOOT_CMDS[$BOOTLOADER]="mkdir -p /run/udev && mount --bind /run/udev /run/udev ; ${BOOT_CMDS[$BOOTLOADER]}"
|
||||
echo -e "\n\nBinding mount: /run/udev -> $MNT/run/udev\n\n"
|
||||
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
|
||||
# make sure efivarfs has been mounted
|
||||
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
|
||||
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
|
||||
fi
|
||||
|
||||
# sets up the bootloader config(s) and ${BOOT_CMDS[$BOOTLOADER]}
|
||||
prep_for_$BOOTLOADER
|
||||
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
|
||||
prep_for_$BOOTLDR
|
||||
|
||||
# run the bootloader command
|
||||
chroot_cmd "${BOOT_CMDS[$BOOTLOADER]}"
|
||||
check_for_errors "${BOOT_CMDS[$BOOTLOADER]}"
|
||||
chroot_cmd "${BCMDS[$BOOTLDR]}"
|
||||
check_for_errors "${BCMDS[$BOOTLDR]}"
|
||||
|
||||
if [[ $SYS == 'UEFI' && $BOOTLOADER =~ (grub|syslinux) ]]; then
|
||||
if [[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]]; then
|
||||
local boot_dir="$DIST"
|
||||
[[ $BOOTLOADER == 'syslinux' ]] && boot_dir="syslinux"
|
||||
[[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
|
||||
|
||||
# copy efi stub to generic catch all
|
||||
uefi_boot_fallback "$boot_dir"
|
||||
|
@ -7,9 +7,6 @@
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
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
|
||||
oneshot install_base
|
||||
|
||||
@ -22,30 +19,36 @@ install_main() {
|
||||
check_for_errors "sed -i s~${MNT}~~ $MNT/etc/fstab"
|
||||
fi
|
||||
|
||||
# run package operations before bootloader and mkinitcpio
|
||||
# due to the possibility of choosing lts kernel earlier
|
||||
oneshot update_mirrorlist
|
||||
oneshot update_system
|
||||
oneshot install_packages
|
||||
[[ $LOGIN_TYPE == 'lightdm' ]] && oneshot setup_lightdm
|
||||
# update the mirrorlist, if this isn't done before updating or it may be slow
|
||||
local cmdtail="--verbose --save $MNT/etc/pacman.d/mirrorlist"
|
||||
$MIRROR_CMD $cmdtail || reflector --score 100 -l 50 -f 10 --sort rate $cmdtail
|
||||
|
||||
oneshot update_system # MUST be before bootloader and mkinitcpio
|
||||
|
||||
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
||||
oneshot setup_lightdm
|
||||
fi
|
||||
|
||||
run_mkinitcpio || 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
|
||||
return 0
|
||||
}
|
||||
|
||||
install_base() {
|
||||
# unpack the main system
|
||||
clear
|
||||
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/
|
||||
|
||||
# remove archiso init files
|
||||
# remove archiso init files and clean up install files
|
||||
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
|
||||
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
|
||||
|
||||
# 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
|
||||
return 0
|
||||
@ -71,9 +76,7 @@ setup_configs() {
|
||||
sed -i "s/en_US.UTF-8/${LOCALE}/g" $MNT/etc/locale.conf
|
||||
cp -f $MNT/etc/locale.conf $MNT/etc/default/locale
|
||||
chroot_cmd "locale-gen" 2>$ERR
|
||||
check_for_errors 'locale-gen'
|
||||
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
|
||||
if [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
|
||||
@ -109,7 +112,6 @@ EOF
|
||||
KEYMAP=$CONSOLE_MAP
|
||||
FONT=$FONT
|
||||
EOF
|
||||
|
||||
# set the hostname
|
||||
echo "$HOSTNAME" > $MNT/etc/hostname
|
||||
cat > $MNT/etc/hosts << EOF
|
||||
@ -123,20 +125,43 @@ EOF
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
echo -e "$_UserSetBody"
|
||||
# edit the required files in /etc/ to swap the liveuser account name
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
|
||||
|
||||
# set standard groups for the new user
|
||||
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
|
||||
|
||||
if [[ $AUTOLOGIN == true && $LOGIN_TYPE == 'lightdm' ]]; then
|
||||
groups="$groups,nopasswdlogin"
|
||||
elif [[ $AUTOLOGIN == true ]]; then
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/systemd/system/getty@tty1.service.d/autologin.conf
|
||||
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
||||
[[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
|
||||
rm -rf $_home/.{zprofile,xinitrc}
|
||||
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
|
||||
|
||||
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
|
||||
@ -144,67 +169,21 @@ create_user() {
|
||||
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd"
|
||||
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
|
||||
}
|
||||
|
||||
run_mkinitcpio() {
|
||||
local conf="$MNT/etc/mkinitcpio.conf"
|
||||
local add
|
||||
|
||||
# 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
|
||||
luks_keyfile || return 1
|
||||
if [[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]]; then
|
||||
luks_keyfile
|
||||
fi
|
||||
|
||||
# new HOOKS needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
|
||||
local add
|
||||
(( LVM == 1 )) && add="lvm2"
|
||||
(( 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
|
||||
|
||||
tput civis
|
||||
@ -213,3 +192,75 @@ run_mkinitcpio() {
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -6,6 +6,13 @@
|
||||
# this file is not meant to be run directly
|
||||
# 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_PART=""
|
||||
modprobe -a dm-mod dm_crypt
|
||||
@ -42,7 +49,6 @@ luks_pass() {
|
||||
LUKS_NAME=""
|
||||
|
||||
tput cnorm
|
||||
|
||||
local values
|
||||
values="$(dialog --stdout --separator '~' --ok-label "Submit" --backtitle "$BT" \
|
||||
--title " $title " --insecure --mixedform "$_LuksOpenBody" 16 75 4 \
|
||||
@ -166,19 +172,17 @@ luks_keyfile() {
|
||||
|
||||
if [[ ! -e $MNT/crypto_keyfile.bin ]]; then
|
||||
infobox "$_LuksKeyFileTitle" "$_LuksKeyFileCreate" 0
|
||||
echo -e "$_LuksKeyFileCreate"
|
||||
|
||||
local dev
|
||||
dev="/dev/$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
|
||||
local n
|
||||
n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
|
||||
|
||||
local keycmd
|
||||
keycmd="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin && chmod 000 /crypto_keyfile.bin"
|
||||
keycmd="$keycmd && echo '$LUKS_PASS' | cryptsetup luksAddKey $dev /crypto_keyfile.bin"
|
||||
|
||||
chroot_cmd "$keycmd" 2>$ERR
|
||||
check_for_errors "$keycmd"
|
||||
local mkkey="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin"
|
||||
mkkey="$mkkey && chmod 000 /crypto_keyfile.bin"
|
||||
mkkey="$mkkey && echo '$LUKS_PASS' | cryptsetup luksAddKey /dev/$n /crypto_keyfile.bin"
|
||||
|
||||
chroot_cmd "$mkkey"
|
||||
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
|
||||
|
||||
return 0
|
||||
|
@ -6,6 +6,10 @@
|
||||
# this file is not meant to be run directly
|
||||
# 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() {
|
||||
PHYSICAL_VOLUMES="$(pvs -o pv_name --noheading 2>/dev/null)"
|
||||
VOLUME_GROUP="$(vgs -o vg_name --noheading 2>/dev/null)"
|
||||
|
@ -29,12 +29,12 @@ mount_main() {
|
||||
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n" 1
|
||||
fi
|
||||
|
||||
select_boot_setup || { BOOTLOADER=""; return 1; }
|
||||
select_boot_setup || { BOOTLDR=""; return 1; }
|
||||
|
||||
if [[ $BOOT_PART != "" ]]; then
|
||||
setup_boot_device
|
||||
mount_partition "$BOOT_PART" "${BOOT_MNTS[$SYS-$BOOTLOADER]}" || return 1
|
||||
SEPERATE_BOOT=1
|
||||
mount_partition "$BOOT_PART" "${BMNTS[$SYS-$BOOTLDR]}" || return 1
|
||||
SEPERATE_BOOT=true
|
||||
fi
|
||||
|
||||
select_swap || return 1
|
||||
@ -209,6 +209,8 @@ select_extra_partitions() {
|
||||
# mount it
|
||||
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
|
||||
[[ $EXTRA_MNT == "/usr" && $MKINIT_HOOKS != *usr* ]] && MKINIT_HOOKS="usr $MKINIT_HOOKS"
|
||||
done
|
||||
|
@ -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
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
format() {
|
||||
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"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user