Re order password errors in mkuser()

This commit is contained in:
natemaia 2019-01-13 19:42:44 -08:00
parent 7efdb466a7
commit 2cee0cd38f
3 changed files with 163 additions and 182 deletions

View File

@ -11,14 +11,7 @@
#### Requirements #### Requirements
- `coreutils` `coreutils`, `parted`, `rsync`, `dialog`, `vim`, `chpasswd`, `curl`, `arch-chroot`
- `parted` for partition creation.
- `rsync` for unpacking the squashfs.
- `dialog` for all user input/output.
- `vim` for editing files post install.
- `chpasswd` to set root and user passwords.
- `curl` for network check and mirrorlist download
- `arch-chroot` to perform operations in a chroot.
#### Manual Installation #### Manual Installation
@ -26,6 +19,7 @@
``` ```
sh -c "$(curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/install.sh)" sh -c "$(curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/install.sh)"
``` ```
--- ---
A packaged version can also be found in our repos: A packaged version can also be found in our repos:
[stable](https://bitbucket.org/archlabslinux/archlabs_repo/src/master/x86_64/) [stable](https://bitbucket.org/archlabslinux/archlabs_repo/src/master/x86_64/)

View File

@ -3,16 +3,15 @@
# Generic # Generic
_Done="Done" _Done="Done"
_Skip="Skip/None"
_ErrTitle="Installation Error"
_NoFileErr="\nFile does not exist.\n"
_PassErr="\nThe passwords entered do not match.\n"
_OnlyOne="\nOnly one partition available"
_Pass2="\nRe-enter the password for"
_TryAgain="Please try again.\n"
_Exit="Exiting.\n"
_Back="Back" _Back="Back"
_Name="Name:" _Name="Name:"
_Skip="Skip/None"
_Exit="Exiting.\n"
_ErrTitle="Installation Error"
_TryAgain="Please try again.\n"
_Pass2="\nRe-enter the password for"
_NoFileErr="\nFile does not exist.\n"
_OnlyOne="\nOnly one partition available"
# Welcome # Welcome
_WelTitle="Welcome to" _WelTitle="Welcome to"
@ -53,9 +52,9 @@ _ErrChoiceConsole="\nUnmount the partitions and exit to view the error log or ke
# timezone # timezone
_TimeZTitle="Set Timezone" _TimeZTitle="Set Timezone"
_TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below"
_TimeSubZBody="\nSelect the nearest city to your location from the list below."
_TimeZQ="\nConfirm time zone:" _TimeZQ="\nConfirm time zone:"
_TimeSubZBody="\nSelect the nearest city to your location from the list below."
_TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below"
# bootloader # bootloader
_MntBootBody="\nSelect which bootloader to use." _MntBootBody="\nSelect which bootloader to use."
@ -216,6 +215,7 @@ _ExtErrBody="\nCannot mount partition due to a problem with the mountpoint name.
_PartErrBody="\nBIOS systems require at least one partition (ROOT).\n\nUEFI systems require at least two (ROOT and EFI).\n" _PartErrBody="\nBIOS systems require at least one partition (ROOT).\n\nUEFI systems require at least two (ROOT and EFI).\n"
_UserErrTitle="User Name Error" _UserErrTitle="User Name Error"
_UserErrBody="\nIncorrect user name.\n\nPlease try again.\n" _UserErrBody="\nIncorrect user name.\n\nPlease try again.\n"
_PassErr="\nThe passwords entered do not match.\n"
_UserPassErr="\nThe user passwords entered do not match.\n" _UserPassErr="\nThe user passwords entered do not match.\n"
_RootPassErr="\nThe root passwords entered do not match.\n" _RootPassErr="\nThe root passwords entered do not match.\n"
_UserPassEmpty="\nThe user password cannot be left empty.\n" _UserPassEmpty="\nThe user password cannot be left empty.\n"

View File

@ -8,10 +8,70 @@
# Some ideas and code has been taken from other installers # Some ideas and code has been 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
VER="1.8.21" # version VER="1.8.28" # version
DIST="ArchLabs" # distributor DIST="ArchLabs" # distributor
MNT="/mnt" # mountpoint MNT="/mnt" # mountpoint
# Bulk defaults
# {
ERR="/tmp/errlog" # error log used internally
DBG="/tmp/debuglog" # debug log when passed -d
RUN="/run/archiso/bootmnt/arch/boot" # path for live /boot
BT="$DIST Installer - v$VER" # backtitle used for dialogs
VM="$(dmesg | grep -i "hypervisor")" # is the system a vm
ROOT_PART="" # root partition
BOOT_PART="" # boot partition
BOOT_DEVICE="" # device used for BIOS grub install
AUTO_BOOT_PART="" # filled with the boot partition from auto_partiton()
BOOTLDR="" # bootloader selected
EXTRA_MNT="" # holder for additional partitions while mounting
EXTRA_MNTS="" # when an extra partition is mounted append it's info
SWAP_PART="" # swap partition or file path
SWAP_SIZE="" # when using a swapfile use this size
NEWUSER="" # username for the primary user
USER_PASS="" # password for the primary user
ROOT_PASS="" # root password
LOGIN_WM="" # default login session
LOGIN_TYPE="" # login manager can be lightdm or xinit
INSTALL_WMS="" # space separated list of chosen wm/de
KERNEL="" # kernel can be linux or linux-lts
PACKAGES="" # list of all packages to install including WM_PACKAGES
WM_PACKAGES="" # full list of packages added during wm/de choice
MYSHELL="" # login shell for root and the primary user
UCODE="" # cpu manufacturer microcode filename (if any)
HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf
FONT="ter-i16n" # font used in the linux console
# sane baseline
BASE_PKGS="archlabs-scripts archlabs-skel-base archlabs-themes archlabs-dARK archlabs-icons archlabs-wallpapers "
BASE_PKGS+="base-devel xorg xorg-drivers sudo git gtk3 gtk-engines gtk-engine-murrine pavucontrol tumbler "
BASE_PKGS+="playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-base gst-plugins-good"
# sane extras for window managers
WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip "
WM_BASE_PKGS+="xdotool compton gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect"
LUKS="" # empty when not using luks encryption
LUKS_DEV="" # boot parameter string for LUKS
LUKS_PART="" # partition used for encryption
LUKS_PASS="" # encryption password
LUKS_UUID="" # encrypted partition UUID
LUKS_NAME="" # name used for encryption
LVM="" # empty when not using lvm
GROUP_PARTS=() # partitions used for volume group
VOL_GROUP_MB=0 # available space in volume group
WARN=false # issued mounting/partitioning warning
SEP_BOOT=false # separate boot partition for BIOS
AUTOLOGIN=false # enable autologin for xinit
CONFIG_DONE=false # basic configuration is finished
BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352
# }
main() main()
{ {
if [[ $CURRENT_MENU != "main" && $SAVED ]]; then if [[ $CURRENT_MENU != "main" && $SAVED ]]; then
@ -69,8 +129,11 @@ show_cfg()
{ {
local cmd="${BCMDS[$BOOTLDR]}" local cmd="${BCMDS[$BOOTLDR]}"
local mnt="${BMNTS[$SYS-$BOOTLDR]}" local mnt="${BMNTS[$SYS-$BOOTLDR]}"
local pkgs="${PACKAGES# }" local pkgs="${PACKAGES# } $BASE_PKGS"
[[ $PACKAGES =~ (openbox|bspwm|i3-gaps) || $INSTALL_WMS == *dwm* ]] && pkgs="${pkgs# } $WM_BASE_PKGS"
[[ $INSTALL_WMS == *dwm* ]] && pkgs="${pkgs# } dwm st dmenu"
pkgs="${pkgs# }" pkgs="${pkgs# }"
pkgs="${pkgs% }"
msgbox "$_PrepTitle" " msgbox "$_PrepTitle" "
---------- PARTITION CONFIGURATION ------------ ---------- PARTITION CONFIGURATION ------------
@ -184,12 +247,12 @@ mkuser()
elif [[ $pass == "" ]]; then elif [[ $pass == "" ]]; then
msgbox "$_ErrTitle" "$_UserPassEmpty\n$_TryAgain" msgbox "$_ErrTitle" "$_UserPassEmpty\n$_TryAgain"
mkuser || return 1 mkuser || return 1
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
mkuser || return 1
elif [[ "$pass" != "$pass2" ]]; then elif [[ "$pass" != "$pass2" ]]; then
msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain" msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain"
mkuser || return 1 mkuser || return 1
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
mkuser || return 1
fi fi
NEWUSER="$user" NEWUSER="$user"
@ -291,16 +354,13 @@ select_wm_or_de()
WM_PACKAGES="${WM_PACKAGES// / }" # remove double spaces WM_PACKAGES="${WM_PACKAGES// / }" # remove double spaces
WM_PACKAGES="${WM_PACKAGES# }" # remove leading space WM_PACKAGES="${WM_PACKAGES# }" # remove leading space
# packages needed for the selected WMs/DEs
for wm in $INSTALL_WMS; do for wm in $INSTALL_WMS; do
LOGIN_CHOICES+="$wm - " LOGIN_CHOICES+="$wm - "
[[ ${WM_EXT[$wm]} && $WM_PACKAGES != *"${WM_EXT[$wm]}"* ]] && WM_PACKAGES+=" ${WM_EXT[$wm]}" [[ ${WM_EXT[$wm]} && $WM_PACKAGES != *"${WM_EXT[$wm]}"* ]] && WM_PACKAGES+=" ${WM_EXT[$wm]}"
done done
# choose how to log in
select_login || return 1 select_login || return 1
# choose which WM/DE to start at login, only for xinit
if [[ $LOGIN_TYPE == 'xinit' ]]; then if [[ $LOGIN_TYPE == 'xinit' ]]; then
if [[ $WM_NUM -eq 1 ]]; then if [[ $WM_NUM -eq 1 ]]; then
LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}" LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}"
@ -313,8 +373,7 @@ select_wm_or_de()
AUTOLOGIN=false AUTOLOGIN=false
fi fi
# add packages to the main package list PACKAGES+=" ${WM_PACKAGES# }"
[[ $PACKAGES ]] && PACKAGES+=" ${WM_PACKAGES# }" || PACKAGES="${WM_PACKAGES# }"
} }
select_login() select_login()
@ -331,6 +390,7 @@ select_login()
else else
PACKAGES="${PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" PACKAGES="${PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}"
WM_PACKAGES="${WM_PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}" WM_PACKAGES="${WM_PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}"
WM_PACKAGES+=" xorg-xinit"
EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile" EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
fi fi
} }
@ -373,15 +433,10 @@ select_packages()
select_packages select_packages
fi fi
# add any extras for each package
for pkg in $PACKAGES; do for pkg in $PACKAGES; do
[[ ${PKG_EXT[$pkg]} && $PACKAGES != *"${PKG_EXT[$pkg]}"* ]] && PACKAGES+=" ${PKG_EXT[$pkg]}" [[ ${PKG_EXT[$pkg]} && $PACKAGES != *"${PKG_EXT[$pkg]}"* ]] && PACKAGES+=" ${PKG_EXT[$pkg]}"
done done
# add mksh to package list if it was chosen as the login shell
[[ $MYSHELL == *mksh ]] && PACKAGES+=" mksh" [[ $MYSHELL == *mksh ]] && PACKAGES+=" mksh"
# remove leading space
PACKAGES="${PACKAGES# }" PACKAGES="${PACKAGES# }"
return 0 return 0
} }
@ -1180,7 +1235,7 @@ install()
install_base install_base
printf "Generating system /etc/fstab\n" printf "Generating system /etc/fstab\n"
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR genfstab -U $MNT >$MNT/etc/fstab 2>$ERR
echeck "genfstab -U $MNT >$MNT/etc/fstab" errshow 1 "genfstab -U $MNT >$MNT/etc/fstab"
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
mirrorlist_sort mirrorlist_sort
package_operations package_operations
@ -1197,11 +1252,11 @@ install_base()
{ {
if [[ -e /run/archiso/sfs/airootfs/etc/skel ]]; then if [[ -e /run/archiso/sfs/airootfs/etc/skel ]]; then
rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR
echeck "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/" errshow 1 "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/"
else else
mirrorlist_sort mirrorlist_sort
pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt) 2>$ERR pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt) 2>$ERR
echeck "pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt)" errshow 1 "pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt)"
fi fi
printf "Removing archiso remains\n" printf "Removing archiso remains\n"
@ -1215,7 +1270,7 @@ install_base()
sleep 1 sleep 1
elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
printf "Creating intel GPU 'TearFree' config in /etc/X11/xorg.conf.d/20-intel.conf\n" printf "Creating intel GPU 'TearFree' config in /etc/X11/xorg.conf.d/20-intel.conf\n"
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"
Driver "intel" Driver "intel"
@ -1244,9 +1299,9 @@ EOF
LANG=$LOCALE LANG=$LOCALE
EOF EOF
sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${LOCALE}/${LOCALE}/g" $MNT/etc/locale.gen sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${LOCALE}/${LOCALE}/g" $MNT/etc/locale.gen
chrun "locale-gen" 2>/dev/null chrun "locale-gen"
printf "Setting timezone: $ZONE/$SUBZONE\n" printf "Setting timezone: $ZONE/$SUBZONE\n"
chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime" 2>/dev/null chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime"
if [[ $BROADCOM_WL == true ]]; then if [[ $BROADCOM_WL == true ]]; then
printf "Blacklisting modules for broadcom wireless: bmca\n" printf "Blacklisting modules for broadcom wireless: bmca\n"
@ -1294,7 +1349,6 @@ create_user()
{ {
printf "Creating user $NEWUSER, setting passwords, and setting shell\n" printf "Creating user $NEWUSER, setting passwords, and setting shell\n"
# set root password, shell if needed
chrun "chpasswd <<< 'root:$ROOT_PASS'" chrun "chpasswd <<< 'root:$ROOT_PASS'"
if [[ $MYSHELL != *zsh ]]; then if [[ $MYSHELL != *zsh ]]; then
chrun "usermod -s $MYSHELL root" chrun "usermod -s $MYSHELL root"
@ -1303,20 +1357,19 @@ create_user()
fi fi
fi fi
# Create the user, set password, and make sure the ownership of ~/ is correct
local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel'
chrun "groupadd -r autologin" chrun "groupadd -r autologin"
chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR
echeck "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" errshow 1 "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER"
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR
errshow 1 "Setting new users password"
# for neovim set up ~/.config/nvim if [[ $PACKAGES == *neovim* ]]; then
if [[ $PACKAGES =~ neovim ]]; then
mkdir -p $MNT/home/$NEWUSER/.config/nvim mkdir -p $MNT/home/$NEWUSER/.config/nvim
cp -fv $MNT/home/$NEWUSER/.vimrc $MNT/home/$NEWUSER/.config/nvim/init.vim cp -fv $MNT/home/$NEWUSER/.vimrc $MNT/home/$NEWUSER/.config/nvim/init.vim
cp -rfv $MNT/home/$NEWUSER/.vim/colors $MNT/home/$NEWUSER/.config/nvim/colors cp -rfv $MNT/home/$NEWUSER/.vim/colors $MNT/home/$NEWUSER/.config/nvim/colors
fi fi
[[ $INSTALL_WMS =~ dwm ]] && suckless_install [[ $INSTALL_WMS == *dwm* ]] && suckless_install
if [[ $INSTALL_WMS == 'plasma' || $LOGIN_WM == 'startkde' || $INSTALL_WMS == 'gnome' || $LOGIN_WM == 'gnome-session' ]] if [[ $INSTALL_WMS == 'plasma' || $LOGIN_WM == 'startkde' || $INSTALL_WMS == 'gnome' || $LOGIN_WM == 'gnome-session' ]]
then then
sed -i '/super/d' $HOME/.xprofile /root/.xprofile sed -i '/super/d' $HOME/.xprofile /root/.xprofile
@ -1392,7 +1445,8 @@ setup_lightdm()
{ {
rm -rf $SERVICE rm -rf $SERVICE
rm -rf $MNT/home/$NEWUSER/.{xinitrc,profile,zprofile,bash_profile} rm -rf $MNT/home/$NEWUSER/.{xinitrc,profile,zprofile,bash_profile}
chrun 'systemctl set-default graphical.target && systemctl enable lightdm.service' chrun 'systemctl set-default graphical.target && systemctl enable lightdm.service' 2>$ERR
errshow 1 "systemctl set-default graphical.target && systemctl enable lightdm.service"
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF
# LightDM GTK+ Configuration # LightDM GTK+ Configuration
@ -1443,7 +1497,7 @@ run_mkinitcpio()
[[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; } [[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; }
sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf
chrun "mkinitcpio -p $KERNEL" 2>$ERR chrun "mkinitcpio -p $KERNEL" 2>$ERR
echeck "mkinitcpio -p $KERNEL" errshow 1 "mkinitcpio -p $KERNEL"
} }
mirrorlist_sort() mirrorlist_sort()
@ -1460,34 +1514,30 @@ mirrorlist_sort()
package_operations() package_operations()
{ {
# add the packages chosen during setup local rmpkg="archlabs-installer"
if [[ $KERNEL == 'linux-lts' ]]; then
local inpkg="linux-lts $PACKAGES" if [[ $inpkg =~ (openbox|bspwm|i3) || $INSTALL_WMS == *dwm* ]]; then
local rmpkg="archlabs-installer linux" local inpkg="$PACKAGES $BASE_PKGS $WM_BASE_PKGS"
else else
local inpkg="$PACKAGES" local inpkg="$PACKAGES $BASE_PKGS"
local rmpkg="archlabs-installer"
fi
# update first to avoid database access errors
chrun "pacman -Syyu --noconfirm"
if [[ $BOOTLDR == 'grub' ]]; then
chrun "pacman -Rns $rmpkg grub --noconfirm"
else
chrun "pacman -Rns $rmpkg --noconfirm"
fi
chrun "pacman -S iputils --noconfirm"
chrun "pacman -S $inpkg archlabs-common archlabs-dARK archlabs-icons archlabs-scripts archlabs-skel-base archlabs-wallpapers gtk-engine-murrine gtk3 pavucontrol tumbler xorg-xinit base base-devel sudo git udisks2 mesa xorg-server xorg-apps xorg-drivers playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-base gst-plugins-good --needed --noconfirm"
if [[ $inpkg =~ (openbox|dwm|bspwm|i3) ]]; then
chrun "pacman -S arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip xdotool compton gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect --needed --noconfirm"
fi fi
if ! [[ $INSTALL_WMS == 'plasma' || $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then if ! [[ $INSTALL_WMS == 'plasma' || $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
chrun "pacman -S archlabs-ksuperkey --noconfirm --needed" inpkg+=" archlabs-ksuperkey"
fi fi
if [[ $KERNEL == 'linux-lts' ]]; then
inpkg+=" linux-lts"
rmpkg+=" linux"
fi
[[ $BOOTLDR == 'grub' ]] && inpkg+=" grub"
chrun "pacman -Syyu --noconfirm"
chrun "pacman -Rns $rmpkg --noconfirm"
chrun "pacman -S iputils --noconfirm"
chrun "pacman -S $inpkg --needed --noconfirm"
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
return 0 return 0
} }
@ -1548,14 +1598,12 @@ setup_grub()
BCMDS[grub]="${BCMDS[grub]} --bootloader-id=$DIST" BCMDS[grub]="${BCMDS[grub]} --bootloader-id=$DIST"
fi fi
BCMDS[grub]="mkdir -p /run/udev && BCMDS[grub]="mkdir -p /run/udev && mkdir -p /run/lvm &&
mkdir -p /run/lvm && mount --bind /hostrun/udev /run/udev &&
mount --bind /hostrun/udev /run/udev && mount --bind /hostrun/lvm /run/lvm &&
mount --bind /hostrun/lvm /run/lvm && ${BCMDS[grub]} &&
${BCMDS[grub]} && grub-mkconfig -o /boot/grub/grub.cfg &&
grub-mkconfig -o /boot/grub/grub.cfg && sleep 1 && umount /run/udev && umount /run/lvm"
umount /run/udev &&
umount /run/lvm"
return 0 return 0
} }
@ -1693,7 +1741,7 @@ install_bootloader()
prerun_$BOOTLDR prerun_$BOOTLDR
printf "Installing and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n" printf "Installing and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n"
chrun "${BCMDS[$BOOTLDR]}" 2>$ERR chrun "${BCMDS[$BOOTLDR]}" 2>$ERR
echeck "${BCMDS[$BOOTLDR]}" errshow 1 "${BCMDS[$BOOTLDR]}"
if [[ -d $MNT/hostrun ]]; then if [[ -d $MNT/hostrun ]]; then
umount $MNT/hostrun/udev >/dev/null 2>&1 umount $MNT/hostrun/udev >/dev/null 2>&1
@ -2170,7 +2218,7 @@ chrun()
json() json()
{ {
# get a value from http://api.ipstack.com in json format using my API key this includes: ip, geolocation, country name # extract a value from http://api.ipstack.com json output
curl -s "http://api.ipstack.com/$2" | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])" curl -s "http://api.ipstack.com/$2" | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])"
} }
@ -2236,7 +2284,7 @@ print4()
{ {
# takes an arbitrary number of input fields and prints them out in fourths on separate lines # takes an arbitrary number of input fields and prints them out in fourths on separate lines
local str="$*" local str="$*"
if [[ ${#str} -gt $((COLUMNS - 5)) ]]; then if [[ ${#str} -gt $((COLUMNS - 10)) ]]; then
str="$(awk '{ str="$(awk '{
p1=p2=p3=p4="" p1=p2=p3=p4=""
p1=$1 p1=$1
@ -2245,7 +2293,7 @@ print4()
for (i=q; i<=q*2; i++) { p2=p2" "$i } for (i=q; i<=q*2; i++) { p2=p2" "$i }
for (i=q*2; i<=q*3; i++) { p3=p3" "$i } for (i=q*2; i<=q*3; i++) { p3=p3" "$i }
for (i=q*3; i<=NF; i++) { p4=p4" "$i } for (i=q*3; i<=NF; i++) { p4=p4" "$i }
printf "%s\n\t%s\n\t%s\n\t%s", p1, p2, p3, p4 printf "%s\n %s\n %s\n %s", p1, p2, p3, p4
}' <<< "$str")" }' <<< "$str")"
printf "%s\n" "$str" printf "%s\n" "$str"
elif [[ $str ]]; then elif [[ $str ]]; then
@ -2350,18 +2398,12 @@ system_checks()
prechecks() prechecks()
{ {
if [[ $1 -ge 0 ]] && ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then if [[ $1 -ge 0 ]] && ! [[ $(lsblk -lno MOUNTPOINT) =~ $MNT ]]; then
msgbox "$_ErrTitle" "$_ErrNoMount" msgbox "$_ErrTitle" "$_ErrNoMount"; SELECTED=4; return 1
SELECTED=4
return 1
elif [[ $1 -ge 1 && ! $NEWUSER ]]; then elif [[ $1 -ge 1 && ! $NEWUSER ]]; then
msgbox "$_ErrTitle" "\nYou need to create a user first.\n" msgbox "$_ErrTitle" "\nYou need to create a user first.\n"; SELECTED=5; return 1
SELECTED=5
return 1
elif [[ $1 -ge 2 && $CONFIG_DONE != true ]]; then elif [[ $1 -ge 2 && $CONFIG_DONE != true ]]; then
msgbox "$_ErrTitle" "$_ErrNoConfig" msgbox "$_ErrTitle" "$_ErrNoConfig"; SELECTED=6; return 1
SELECTED=6
return 1
fi fi
return 0 return 0
} }
@ -2370,22 +2412,6 @@ errshow()
{ {
local last_exit_code=$? local last_exit_code=$?
(( last_exit_code == 0 )) && return 0 (( last_exit_code == 0 )) && return 0
local err
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
if [[ $err ]]; then
msgbox "$_ErrTitle" "\nERROR: $err"
else
msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n"
fi
}
echeck()
{
local last_exit_code=$?
(( last_exit_code == 0 )) && return 0
local err local err
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")" err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
@ -2395,9 +2421,10 @@ echeck()
msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n" msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n"
fi fi
[[ -e $DBG && $TERM == 'linux' ]] && less $DBG if [[ $1 == 1 ]]; then
[[ -e $DBG && $TERM == 'linux' ]] && less $DBG
die 1 die 1
fi
} }
debug() debug()
@ -2483,6 +2510,8 @@ yesno()
select_language() select_language()
{ {
LNG="/usr/share/archlabs/installer/lang" # translation file path
tput civis tput civis
local lang local lang
lang=$(menubox "Select Language" \ lang=$(menubox "Select Language" \
@ -2521,7 +2550,6 @@ select_language()
fi fi
[[ $TERM == 'linux' ]] && setfont $FONT >/dev/null 2>&1 [[ $TERM == 'linux' ]] && setfont $FONT >/dev/null 2>&1
export LANG="$LOC" export LANG="$LOC"
return 0 return 0
} }
@ -2530,55 +2558,6 @@ select_language()
# giant ugly variable container :P { # giant ugly variable container :P {
# BULK
# {
ERR="/tmp/errlog" # error log used internally
DBG="/tmp/debuglog" # debug log when passed -d
RUN="/run/archiso/bootmnt/arch/boot" # path for live /boot
LNG="/usr/share/archlabs/installer/lang" # translation file path
BT="$DIST Installer - v$VER" # backtitle used for dialogs
VM="$(dmesg | grep -i "hypervisor")" # is the system a vm
ROOT_PART="" # root partition
BOOT_PART="" # boot partition
BOOT_DEVICE="" # device used for BIOS grub install
AUTO_BOOT_PART="" # filled with the boot partition from auto_partiton()
BOOTLDR="" # bootloader selected
EXTRA_MNT="" # holder for additional partitions while mounting
EXTRA_MNTS="" # when an extra partition is mounted append it's info
SWAP_PART="" # swap partition or file path
SWAP_SIZE="" # when using a swapfile use this size
NEWUSER="" # username for the primary user
USER_PASS="" # password for the primary user
ROOT_PASS="" # root password
LOGIN_WM="" # default login session
LOGIN_TYPE="" # login manager can be lightdm or xinit
INSTALL_WMS="" # space separated list of chosen wm/de
KERNEL="" # kernel can be linux or linux-lts
WM_PACKAGES="" # full list of packages added during wm/de choice
PACKAGES="" # list of all packages to install including WM_PACKAGES
MYSHELL="" # login shell for root and the primary user
UCODE="" # cpu manufacturer microcode filename (if any)
HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf
LUKS="" # empty when not using luks encryption
LUKS_DEV="" # boot parameter string for LUKS
LUKS_PART="" # partition used for encryption
LUKS_PASS="" # encryption password
LUKS_UUID="" # encrypted partition UUID
LUKS_NAME="" # name used for encryption
LVM="" # empty when not using lvm
GROUP_PARTS=() # partitions used for volume group
VOL_GROUP_MB=0 # available space in volume group
WARN=false # issued mounting/partitioning warning
CONFIG_DONE=false # basic configuration is finished
SEP_BOOT=false # separate boot partition for BIOS
AUTOLOGIN=false # enable autologin for xinit
BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352
# }
# amount of RAM in the system in Mb # amount of RAM in the system in Mb
SYS_MEM="$(awk '/MemTotal/ { SYS_MEM="$(awk '/MemTotal/ {
print int($2 / 1024)"M" print int($2 / 1024)"M"
@ -2607,8 +2586,8 @@ CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
# command used to install each bootloader # command used to install each bootloader
declare -A BCMDS=( declare -A BCMDS=(
[syslinux]="syslinux-install_update -iam"
[grub]="grub-install --recheck --force" [grub]="grub-install --recheck --force"
[syslinux]="syslinux-install_update -iam"
[systemd-boot]="bootctl --path=/boot install" [systemd-boot]="bootctl --path=/boot install"
) )
@ -2643,24 +2622,24 @@ declare -A WM_EXT=(
[gnome]="" [gnome]=""
[plasma]="kdebase-meta" [plasma]="kdebase-meta"
[bspwm]="sxhkd archlabs-skel-bspwm rofi archlabs-polybar" [bspwm]="sxhkd archlabs-skel-bspwm rofi archlabs-polybar"
[xfce4]="xfce4-goodies xfce4-pulseaudio-plugin network-manager-applet volumeicon rofi archlabs-skel-xfce4 xdg-user-dirs"
[i3-gaps]="i3status perl-anyevent-i3 archlabs-skel-i3-gaps rofi archlabs-polybar" [i3-gaps]="i3status perl-anyevent-i3 archlabs-skel-i3-gaps rofi archlabs-polybar"
[openbox]="obconf archlabs-skel-openbox jgmenu archlabs-polybar tint2 conky rofi" [openbox]="obconf archlabs-skel-openbox jgmenu archlabs-polybar tint2 conky rofi"
[xfce4]="xfce4-goodies xfce4-pulseaudio-plugin network-manager-applet volumeicon rofi archlabs-skel-xfce4 xdg-user-dirs"
) )
# files the user can edit during the final stage of install # files the user can edit during the final stage of install
declare -A EDIT_FILES=( declare -A EDIT_FILES=(
[keyboard]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard"
[console]="/etc/vconsole.conf"
[locale]="/etc/locale.conf /etc/default/locale"
[hostname]="/etc/hostname /etc/hosts"
[sudoers]="/etc/sudoers"
[mkinitcpio]="/etc/mkinitcpio.conf"
[fstab]="/etc/fstab"
[crypttab]="/etc/crypttab"
[bootloader]="/boot/loader/entries/$DIST.conf"
[pacman]="/etc/pacman.conf"
[login]="" # login files.. Populated later once login method is chosen [login]="" # login files.. Populated later once login method is chosen
[fstab]="/etc/fstab"
[sudoers]="/etc/sudoers"
[crypttab]="/etc/crypttab"
[pacman]="/etc/pacman.conf"
[console]="/etc/vconsole.conf"
[mkinitcpio]="/etc/mkinitcpio.conf"
[hostname]="/etc/hostname /etc/hosts"
[bootloader]="/boot/loader/entries/$DIST.conf"
[locale]="/etc/locale.conf /etc/default/locale"
[keyboard]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard"
) )
# PKG_EXT: if you add a package to $PACKAGES in any dialog # PKG_EXT: if you add a package to $PACKAGES in any dialog
@ -2671,29 +2650,39 @@ declare -A PKG_EXT=(
[vlc]="qt4" [vlc]="qt4"
[mpd]="mpc" [mpd]="mpc"
[mupdf]="mupdf-tools" [mupdf]="mupdf-tools"
[qutebrowser]="qt5ct qt5-styleplugins"
[qt5ct]="qt5-styleplugins" [qt5ct]="qt5-styleplugins"
[vlc]="qt5ct qt5-styleplugins" [vlc]="qt5ct qt5-styleplugins"
[zathura]="zathura-pdf-poppler" [zathura]="zathura-pdf-poppler"
[noto-fonts]="noto-fonts-emoji" [noto-fonts]="noto-fonts-emoji"
[cairo-dock]="cairo-dock-plug-ins" [cairo-dock]="cairo-dock-plug-ins"
[qbittorrent]="qt5ct qt5-styleplugins" [qbittorrent]="qt5ct qt5-styleplugins"
[qutebrowser]="qt5ct qt5-styleplugins"
[kdenlive]="kdebase-meta dvdauthor frei0r-plugins breeze breeze-gtk qt5ct qt5-styleplugins" [kdenlive]="kdebase-meta dvdauthor frei0r-plugins breeze breeze-gtk qt5ct qt5-styleplugins"
) )
# mkfs command to format a partition as a given file system # mkfs command to format a partition as a given file system
declare -A FS_CMDS=( declare -A FS_CMDS=(
[ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q" [ext2]="mkfs.ext2 -q"
[f2fs]="mkfs.f2fs" [jfs]="mkfs.jfs -q" [xfs]="mkfs.xfs -f" [ext3]="mkfs.ext3 -q"
[nilfs2]="mkfs.nilfs2 -q" [ntfs]="mkfs.ntfs -q" [reiserfs]="mkfs.reiserfs -q" [ext4]="mkfs.ext4 -q"
[f2fs]="mkfs.f2fs"
[jfs]="mkfs.jfs -q"
[xfs]="mkfs.xfs -f"
[vfat]="mkfs.vfat -F32" [vfat]="mkfs.vfat -F32"
[nilfs2]="mkfs.nilfs2 -q"
[ntfs]="mkfs.ntfs -q"
[reiserfs]="mkfs.reiserfs -q"
) )
# mount options for a given file system # mount options for a given file system
declare -A FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]="" declare -A FS_OPTS=(
[ext4]="discard - off dealloc - off nofail - off noacl - off relatime - off noatime - off nobarrier - off nodelalloc - off" [vfat]=""
[ntfs]=""
[ext2]=""
[ext3]=""
[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"
[ext4]="discard - off dealloc - off nofail - off noacl - off relatime - off noatime - off nobarrier - off nodelalloc - off"
[xfs]="discard - off filestreams - off ikeep - off largeio - off noalign - off nobarrier - off norecovery - off noquota - off wsync - off" [xfs]="discard - off filestreams - off ikeep - off largeio - off noalign - off nobarrier - off norecovery - off noquota - off wsync - off"
[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"
@ -2712,9 +2701,7 @@ done
# initial prep # initial prep
#select_language #select_language
src $LNG/english.trans src /usr/share/archlabs/installer/lang/english.trans
FONT="ter-i16n"
LOC="en_US.UTF-8"
select_keymap select_keymap
system_checks system_checks