# Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
-VER="2.0.35" # installer version
+VER="2.0.49" # installer version
DIST="ArchLabs" # linux distributor
MNT="/mnt" # install mountpoint
ANS="/tmp/ans" # dialog answer file
-# --------------------------------------------- #
-# if you manually mount your partitions then you
-# need to set these values to avoid issues.
-# --------------------------------------------- #
+# ------------------------------------------------------ #
+# When manually mounting your partitions, you need
+# to set these values to avoid using the mount menu.
+# ------------------------------------------------------ #
-# root partition, eg/ /dev/sda2
+# root partition, eg. /dev/sda2
ROOT_PART=''
# boot partition, required on UEFI eg. /dev/sda1
BOOT_PART=''
-# device used for some bootloader install process, eg. /dev/sda
+# boot device, used for some bootloaders eg. /dev/sda
BOOT_DEV=''
# bootloader to use, can be:
# this will need to be 'boot' however a popular one for grub is 'boot/efi'
BOOTDIR='boot'
-# swap partition or file path
-SWAP_PART=''
+# ------------------------------------------------------ #
-# swap size, only used when creating a swapfile
-SWAP_SIZE=''
+# bulk default values {
-# --------------------------------------------- #
+# these values will be selected during the install, it is not recommended
+# to edit them here unless you know what you're doing.
-# bulk default values {
+UCODE='' # cpu microcode (if any), can be: amd-ucode, intel-ucode
+KERNEL='' # linux kernel, can be: linux, linux-lts, linux-zen, or linux-hardened
+MYSHELL='' # full path for the shell, eg. /usr/bin/zsh
+
+SWAP_PART='' # swap partition or file path
+SWAP_SIZE='' # swap size, only used when creating a swapfile
EXMNT='' # holder for additional partitions while mounting
EXMNTS='' # when an extra partition is mounted append it's info
FONT="ter-i16n" # font used for the linux console
HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf
-LOGINRC='' # login shell rc file, eg. .zprofile, .bash_profile, .profile
+LOGIN_TYPE='' # login manager can be: lightdm, xinit
LOGIN_WM='' # default login session to be placed in ~/.xinitrc
-INSTALL_WMS='' # space separated list of chosen wm/de
+LOGINRC='' # login shell rc file, eg. .zprofile, .bash_profile, .profile
-UCODE='' # cpu microcode (if any), eg. amd-ucode, intel-ucode
-KERNEL='' # can be linux, linux-lts, linux-zen, or linux-hardened
-MYSHELL='' # full path for the shell, eg. /usr/bin/zsh
+INSTALL_WMS='' # space separated list of chosen wm/de
-WM_PKGS='' # full list of packages added during wm/de choice
-PACKAGES='' # list of all packages to install including WM_PKGS
+WM_PKGS='' # full list of packages added during wm/de choice (not user edited)
+PACKAGES='' # list of all packages to install including WM_PKGS (not user edited)
USER_PKGS='' # packages selected by the user during install
NEWUSER='' # username for the new user
AUTO_BOOT_PART='' # boot value from auto partition
# iso base, pacstrap when running the installer from a stock arch iso
-ISO_BASE="arch-install-scripts b43-firmware b43-fwcutter broadcom-wl clonezilla dhclient dhcpcd ethtool "
+ISO_BASE="b43-firmware b43-fwcutter broadcom-wl clonezilla dhclient dhcpcd ethtool wpa_supplicant "
ISO_BASE+="exfat-utils f2fs-tools gptfdisk vim hdparm ipw2100-fw ipw2200-fw nfs-utils nilfs-utils ntfs-3g "
ISO_BASE+="pacman-contrib parted rsync sdparm smartmontools wget wireless_tools wpa_actiond xl2tpd dialog parted "
ISO_BASE+="alsa-firmware alsa-lib alsa-plugins pulseaudio pulseaudio-alsa networkmanager w3m htop wireless-regdb "
-ISO_BASE+="wpa_supplicant lm_sensors lsb-release p7zip pamixer reflector unrar ranger terminus-font ttf-dejavu archlabs-keyring"
+ISO_BASE+="lm_sensors lsb-release p7zip pamixer reflector unrar ranger terminus-font ttf-dejavu archlabs-keyring"
# archlabs base packages
AL_BASE_PKGS="archlabs-skel-base archlabs-fonts archlabs-themes archlabs-dARK archlabs-icons archlabs-wallpapers archlabs-scripts"
# giant ugly variable container :P {
# RAM in the system in MB
-SYS_MEM="$(awk '/MemTotal/ {
-print int($2 / 1024)"M"
-}' /proc/meminfo)"
+SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024) "M"}' /proc/meminfo)"
# locales from /etc/locale.gen
-LOCALES="$(awk '/\.UTF-8/ {
- gsub(/# .*|#/, "")
- if ($1) {
- print $1 " - "
- }
-}' /etc/locale.gen)"
+LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if ($1) {print $1 " - "}}' /etc/locale.gen)"
# linux console keyboard mappings
-CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
- gsub(/\.map\.gz|.*\//, "")
- print $1 " - "
-}' | sort)"
+CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " - "}' | sort)"
# terminal size definitions
-# {
[[ $LINES ]] || LINES=$(tput lines)
[[ $COLUMNS ]] || COLUMNS=$(tput cols)
-SHL=$((LINES - 20)) # }
+SHL=$((LINES - 20))
# associative arrays
# {
# commands used to install each bootloader (most get modified during runtime) {
declare -A BCMDS=(
-[refind-efi]='refind-install'
-[grub]='grub-install --recheck --force'
-[syslinux]='syslinux-install_update -i -a -m'
-[efistub]='efibootmgr -v -d /dev/sda -p 1 -c -l'
-[systemd-boot]='bootctl --path=/boot install'
+[refind-efi]='refind-install' # minor modification
+[grub]='grub-install --recheck --force' # heavily modified
+[syslinux]='syslinux-install_update -i -a -m' # modified on UEFI
+[efistub]='efibootmgr -v -d /dev/sda -p 1 -c -l' # heavily modified
+[systemd-boot]='bootctl --path=/boot install' # not modified
) # }
# executable name for each wm/de {
[dwm]='dwm'
[i3-gaps]='i3'
[bspwm]='bspwm'
+[awesome]='awesome'
[plasma]='startkde'
[xfce4]='startxfce4'
[gnome]='gnome-session'
[cinnamon]='cinnamon-session'
) # }
-# packages installed for each wm/de {
+# packages installed for each wm/de, most are depends of the skel packages {
declare -A WM_EXT=(
-[dwm]=''
-[gnome]=''
-[plasma]='kdebase-meta'
-[bspwm]='sxhkd archlabs-skel-bspwm rofi archlabs-polybar'
-[fluxbox]='archlabs-skel-fluxbox archlabs-polybar jgmenu rofi lxmenu-data'
-[i3-gaps]='i3status perl-anyevent-i3 archlabs-skel-i3-gaps rofi archlabs-polybar'
-[openbox]='obconf archlabs-skel-openbox jgmenu archlabs-polybar tint2 conky rofi lxmenu-data'
-[xfce4]='xfce4-goodies xfce4-pulseaudio-plugin network-manager-applet volumeicon rofi archlabs-skel-xfce4'
+[dwm]='' # NA
+[gnome]='' # NA
+[awesome]='' # NA
+[plasma]='kdebase-meta' # base plasma application set
+[bspwm]='' # see deps of bspwm-skel
+[fluxbox]='' # see deps of fluxbox-skel
+[i3-gaps]='' # see deps of i3-gaps-skel
+[openbox]='' # see deps of openbox-skel
+[xfce4]='xfce4-goodies' # see deps of xfce4-skel
) # }
# files that can be edited after install is complete {
declare -A EDIT_FILES=(
-[login]=''
+[login]='' # populated once we know the new username and shell
[fstab]='/etc/fstab'
[sudoers]='/etc/sudoers'
[crypttab]='/etc/crypttab'
[reiserfs]='mkfs.reiserfs -q'
) # }
-# mount options for each offered filesystem (if any {
+# mount options for each offered filesystem (if any) {
declare -A FS_OPTS=(
-[vfat]=''
-[ntfs]=''
-[ext2]=''
-[ext3]=''
+[vfat]='' # NA
+[ntfs]='' # NA
+[ext2]='' # NA
+[ext3]='' # NA
[jfs]='discard errors=continue errors=panic nointegrity'
[reiserfs]='acl nolog notail replayonly user_xattr off'
[ext4]='discard dealloc nofail noacl relatime noatime nobarrier nodelalloc'
# PKG_EXT: if you add a package to $PACKAGES in any dialog {
# and it uses/requires some additional packages,
# you can add them here to keep it simple: [package]="extra"
-# duplicates are removed with `uniq` before install
+# duplicates are not added
declare -A PKG_EXT=(
[vlc]='qt4'
[mpd]='mpc'
local pkgs="${USER_PKGS// / } ${PACKAGES// / }"
[[ $BOOT_PART ]] && mnt="/$BOOTDIR"
[[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu $pkgs"
+ pkgs="${pkgs// / }"
msg "Show Configuration" "
---------- PARTITION CONFIGURATION ------------
select_login()
{
- if (( WM_NUM == 1 )); then
- LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}"
- else
- dlg LOGIN_WM menu "Login Session" "$_login" $LOGIN_CHOICES || return 1
- LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}"
+ if [[ -z $LOGIN_TYPE ]]; then
+ dlg LOGIN_TYPE menu "Login Management" "\nSelect what kind of login management to use." \
+ "xinit" "Console login without a display manager" \
+ "lightdm" "Lightweight display manager with a gtk greeter" || return 1
fi
- local txt="\nDo you want autologin enabled for $NEWUSER?\n\nThe following two files will be created (disable autologin by remove them):\n\n - /home/$NEWUSER/$LOGINRC (this runs startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (this logs in $NEWUSER without a password)\n"
- yesno "Autologin" "$txt" && AUTOLOGIN=true || AUTOLOGIN=''
- EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
+ if [[ $LOGIN_TYPE == 'lightdm' ]]; then
+ AUTOLOGIN=''
+ LOGIN_PKGS="lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
+ EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf"
+ else
+ if (( WM_NUM == 1 )); then
+ LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}"
+ else
+ dlg LOGIN_WM menu "Login Management" "$_login" $LOGIN_CHOICES || return 1
+ LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}"
+ fi
+
+ local txt="\nDo you want autologin enabled for $NEWUSER?\n\n"
+ txt+="If so the following two files will be created (disable autologin by removing them):\n\n"
+ txt+="- /home/$NEWUSER/$LOGINRC (run startx when logging in on tty1)\n"
+ txt+="- /etc/systemd/system/getty@tty1.service.d/autologin.conf (login $NEWUSER without password)\n"
+ yesno "Autologin" "$txt" && AUTOLOGIN=true || AUTOLOGIN=''
+ LOGIN_PKGS="xorg-xinit"
+ EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
+ fi
}
select_config()
dlg INSTALL_WMS check "Sessions" "$_sessions\n" \
i3-gaps "A fork of i3wm with more features including gaps" "$(ofn i3-gaps "${INSTALL_WMS[*]}")" \
openbox "A lightweight, powerful, and highly configurable stacking wm" "$(ofn openbox "${INSTALL_WMS[*]}")" \
+ awesome "A customized Awesome WM session created by @elanapan" "$(ofn awesome "${INSTALL_WMS[*]}")" \
+ dwm "A dynamic WM for X that manages windows in tiled, floating, or monocle layouts" "$(ofn dwm "${INSTALL_WMS[*]}")" \
bspwm "A tiling wm that represents windows as the leaves of a binary tree" "$(ofn bspwm "${INSTALL_WMS[*]}")" \
- dwm "A fork of dwm, with more layouts and features" "$(ofn dwm "${INSTALL_WMS[*]}")" \
fluxbox "A lightweight and highly-configurable window manager" "$(ofn fluxbox "${INSTALL_WMS[*]}")" \
gnome "A desktop environment that aims to be simple and easy to use" "$(ofn gnome "${INSTALL_WMS[*]}")" \
cinnamon "A desktop environment combining traditional desktop with modern effects" "$(ofn cinnamon "${INSTALL_WMS[*]}")" \
done
select_login || return 1
+ [[ $WM_PKGS != *"$LOGIN_PKGS"* ]] && WM_PKGS+=" $LOGIN_PKGS"
while IFS=' ' read -r pkg; do
[[ $PACKAGES != *"$pkg"* ]] && PACKAGES+=" $pkg"
part_menu()
{
- check_background_install || return 0
+ is_bg_install || return 0
local device choice devhash
devhash="$(lsblk -f | base64)"
umount_dir $MNT
if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then
dlg choice menu "Edit Partitions" "$_part" \
"auto" "Whole device automatic partitioning" \
- "resize" "Resize an existing ext2/3/4 or ntfs partition" \
+ "shrink" "Shrink an existing ext2/3/4 or ntfs partition to make room for a new partition" \
"gparted" "GUI front end to parted" \
"cfdisk" "Curses based variant of fdisk" \
"parted" "GNU partition editor" \
else
dlg choice menu "Edit Partitions" "$_part" \
"auto" "Whole device automatic partitioning" \
- "resize" "Resize an existing ext2/3/4 or ntfs partition" \
+ "shrink" "Shrink an existing ext2/3/4 or ntfs partition to make room for a new partition" \
"cfdisk" "Curses based variant of fdisk" \
"parted" "GNU partition editor" \
"fdisk" "Dialog-driven creation and manipulation of partitions" \
if [[ $choice == 'done' ]]; then
return 0
- elif [[ $choice == 'resize' ]]; then
- part_resize "$device"
+ elif [[ $choice == 'shrink' ]]; then
+ part_shrink "$device"
elif [[ $choice == 'auto' ]]; then
local root_size txt table boot_fs
root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 {
sleep "${delay:-0}"
}
-part_resize()
+part_shrink()
{
part=""
typeset -i size num
part_find "${device##*/}[^ ]" || return 1
(( COUNT == 1 )) && part="$(awk '{print $1}' <<< "${PARTS[@]}" )"
- if (( COUNT == 1 )) || dlg part menu "Resize" "\nWhich partition on $device do you want to resize?" $PARTS && [[ $part ]]; then
+ if (( COUNT == 1 )) || dlg part menu "Resize" "\nWhich partition on $device do you want to resize?" $PARTS; then
fs=$(lsblk -lno FSTYPE "$part")
case "$fs" in
- ext[2-4]|ntfs)
+ ext*|ntfs)
msg "Resize" "\nGathering device size info.\n" 0
num="${part: -1}"
- end=$(parted -s "$device" print | awk '/^\s*'"$num"'/ {print $3}')
- devsize=$(parted -s "$device" print | awk '/Disk '"${device//\//\\/}"':/ {print $3}')
- mount "$part" $MNT >/dev/null 2>&1
- sleep 0.5
- min=$(df "$part" | awk '/'"${part//\//\\/}"'/ {print int($3 / 1024)}') # used
- max=$(df "$part" | awk '/'"${part//\//\\/}"'/ {print int($4 / 1024)}') # available
- umount $MNT >/dev/null 2>&1
+ end=$(parted -s "$device" unit KiB print | awk '/^\s*'"$num"'/ {print $3}') # part size in KiB
+ devsize=$(parted -s "$device" unit KiB print | awk '/Disk '"${device//\//\\/}"':/ {print $3}') # whole device size in KiB
+ mount "$part" $MNT >/dev/null 2>&1; sleep 0.5
+ min=$(df --output=used --block-size=MiB "$part" | awk 'NR == 2 {print int($1) + 256}')
+ max=$(df --output=avail --block-size=MiB "$part" | awk 'NR == 2 {print int($1)}')
+ umount_dir $MNT
tput cnorm
if dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Resize: $part " --rangebox "$_resize" 17 "$COLUMNS" "$min" "$max" $((max / 2)) 2>$ANS; then
- (( (size = $(< "$ANS")) + 1025 <= max )) || return 1
- size=$((( (size * 1024) / 4 ) * 4)) # 4K block alignment
+ size=$(< "$ANS")
+ size=$((size * 1024))
else
return 1
fi
clear
case "$fs" in
- ext[2-4])
+ ntfs)
+ if ntfsresize -fc "$part"; then
+ ntfsresize -ff --size $(( (size * 1024) / 1000 ))k "$part" 2>$ERR # k=10^3 bytes
+ errshow "ntfsresize -f -s $(( (size * 1024) / 1000 ))k $part" || return 1
+ else
+ msg "Resize" "\nThe ntfs partition $part cannot be resized because it is scheduled for a consistency check.\n\nTo do a consistency check in windows open command prompt as admin and run:\n\n\tchkdsk /f /r /x\n"
+ return 1
+ fi
+ ;;
+ *)
e2fsck -f "$part"; sleep 0.5
- resize2fs -f "$part" ${size}K 2>$ERR
+ resize2fs -f "$part" ${size}K 2>$ERR # K=2^10 bytes
errshow "resize2fs -f $part ${size}K" || return 1
;;
- ntfs)
- ntfsresize -fc -s ${size}k "$part" 2>$ERR
- errshow "ntfsresize -f -s ${size}k $part" || return 1
- ;;
esac
sleep 0.5
- (( size += 1024 ))
- parted "$device" resizepart "$num" ${size}Kib || return 1
+ parted "$device" resizepart "$num" ${size}KiB || return 1
+ (( size++ ))
sleep 0.5
- if (( ++size < (max * 1024) )); then
- if [[ $devsize == "$end" ]]; then
- parted -s "$device" mkpart primary ext4 ${size}Kib 100% 2>$ERR
- else
- parted -s "$device" mkpart primary ext4 ${size}Kib "$end" 2>$ERR
- fi
- errshow "parted -s $device mkpart primary ext4 ${size}Kib 100%" || return 1
+ if [[ $devsize == "$end" ]]; then
+ parted -s "$device" mkpart primary ext4 ${size}KiB 100% 2>$ERR
+ errshow "parted -s $device mkpart primary ext4 ${size}KiB 100%" || return 1
+ else
+ parted -s "$device" mkpart primary ext4 ${size}KiB ${end}KiB 2>$ERR
+ errshow "parted -s $device mkpart primary ext4 ${size}KiB ${end}KiB" || return 1
fi
- sleep 1
- msg "Resize Complete" "\n$part has been successfully resized to $(( (size - 1025) / 1024 ))M.\n"
- ;;
- *)
- msg "Invalid Filesystem: $fs" "\nCurrently resizing is only supported for ext2/3/4 and ntfs filesystems.\n\nFor unformatted partitions, cfdisk can be used without the need to resize the filesystem.\n"
+ msg "Resize Complete" "\n$part has been successfully resized to $((size / 1024))M.\n" 1
;;
+ "") msg "No Filesystem" "\nFor unformatted partitions, cfdisk can be used in the partition menu.\n" ;;
+ *) msg "Invalid Filesystem: $fs" "\nResizing only supports ext and ntfs.\n" ;;
esac
fi
}
select_menu()
{
- check_background_install || return 0
+ is_bg_install || return 0
lvm_detect
umount_dir $MNT
part_find 'part|lvm|crypt' || { SEL=2; return 1; }
install_boot
chrun "hwclock --systohc --utc" || chrun "hwclock --systohc --utc --directisa"
install_user
- install_xinit
+ install_login
chrun "chown -Rf $NEWUSER:users /home/$NEWUSER"
sleep 1
install_base()
{
if [[ $RSYNC_PID || $MIRROR_PID ]]; then
+ clear
+ printf "\nOne or more background install processes are still running, grabbing their output...\n"
+ sleep 2
while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do
- clear; printf "\nOne or more background install processes are still running...\n"; sleep 1
+ tail -n 1 /tmp/bg_out
+ sleep 0.5
done
trap - EXIT
unset RSYNC_PID MIRROR_PID
- elif [[ -d /run/archiso/sfs/airootfs/etc/skel ]]; then
+ elif hash rsync >/dev/null 2>&1 && [[ -d /run/archiso/sfs/airootfs/etc/skel ]]; then
rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR
errshow 1 "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/"
install_mirrorlist "$MNT/etc/pacman.d/mirrorlist"
else
mkdir -p /etc/pacman.d/mirrorlist
install_mirrorlist "/etc/pacman.d/mirrorlist"
- pacstrap $MNT base $ISO_BASE 2>$ERR
+ pacstrap "$MNT" base $ISO_BASE 2>$ERR
errshow 1 "pacstrap $MNT base $KERNEL $ISO_BASE"
- mkdir -p $MNT/etc/pacman.d/mirrorlist
- cp -f "/etc/pacman.d/mirrorlist" "$MNT/etc/pacman.d/mirrorlist"
+ mkdir -p "$MNT/etc/pacman.d/mirrorlist"
+ cp -f /etc/pacman.d/mirrorlist "$MNT/etc/pacman.d/mirrorlist"
chrun "pacman -Syyu --noconfirm && pacman -S $BASE_PKGS --needed --noconfirm"
fi
fi
if [[ $SYS == 'UEFI' ]]; then
+ # our old installs
find $MNT/$BOOTDIR/EFI/ -maxdepth 1 -mindepth 1 -iname "$DIST" -type d -delete
- find $MNT/$BOOTDIR/EFI/ -maxdepth 1 -mindepth 1 -iname 'boot' -type d -delete
+ # generic BOOT/ dir
+ find $MNT/$BOOTDIR/EFI/ -maxdepth 1 -mindepth 1 -iname 'BOOT' -type d -delete
fi
prerun_$BOOTLDR
errshow 1 "${BCMDS[$BOOTLDR]}"
if [[ -d $MNT/hostrun ]]; then
- umount $MNT/hostrun/udev >/dev/null 2>&1
- umount $MNT/hostrun/lvm >/dev/null 2>&1
+ # cleanup the bind mounts we made earlier for the grub-probe module
+ umount_dir $MNT/hostrun/{udev,lvm}
rm -rf $MNT/hostrun >/dev/null 2>&1
fi
{
chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR
errshow 1 "set root password"
- if [[ $MYSHELL != *zsh ]]; then
+ if [[ $MYSHELL != "/usr/bin/zsh" ]]; then
+ # root uses zsh by default, change it if something else was chosen
chrun "usermod -s $MYSHELL root" 2>$ERR
errshow 1 "usermod -s $MYSHELL root"
- [[ $MYSHELL == "/usr/bin/mksh" ]] && cp -fv $MNT/etc/skel/.mkshrc /root/.mkshrc
+ [[ $MYSHELL == '/usr/bin/mksh' ]] && cp -fv $MNT/etc/skel/.mkshrc $MNT/root/.mkshrc
fi
local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel'
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR
errshow 1 "set $NEWUSER password"
- if [[ $USER_PKGS == *neovim* ]]; then
+ if [[ $USER_PKGS == *neovim* && -d $MNT/home/$NEWUSER/.vim ]]; then
mkdir -p $MNT/home/$NEWUSER/.config/nvim
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
fi
[[ $INSTALL_WMS == *dwm* ]] && install_suckless
- [[ $LOGIN_WM =~ (startkde|gnome-session) ]] && sed -i '/super/d' $MNT/home/$NEWUSER/.xprofile /root/.xprofile
+ [[ $INSTALL_WMS == *awesome* ]] && install_awesome
+ [[ $WM_PKGS == *xfce* ]] && echo 'volumeicon &' >> $MNT/home/$NEWUSER/.xprofile
+ # remove some commands from ~/.xprofile when using KDE or Gnome as the login session
+ if [[ $LOGIN_WM =~ (startkde|gnome-session) || ($LOGIN_TYPE == 'lightdm' && $WM_PKGS =~ (plasma|gnome)) ]]; then
+ sed -i '/super/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
+ sed -i '/nitrogen/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
+ sed -i '/al-compositor/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
+ sed -i '/compton/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
+ fi
+
return 0
}
install_xinit()
{
- SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d"
- sed -i '/printf/d' $MNT/root/.zshrc
-
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' $MNT/home/$NEWUSER/.xinitrc; then
sed -i "/exec/ c exec ${LOGIN_WM}" $MNT/home/$NEWUSER/.xinitrc
else
# sourced by ${MYSHELL##*/} when used as a login shell
# automatically run startx when logging in on tty1
-[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx -- vt1
+if [ -z \$DISPLAY ] && [ \$XDG_VTNR -eq 1 ]; then
+ exec startx
+fi
EOF
else
rm -rf $SERVICE
- rm -rf $MNT/home/$NEWUSER/.{profile,zprofile,bash_profile}
+ fi
+}
+
+install_login()
+{
+ SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d"
+ sed -i '/printf/d' $MNT/root/.zshrc
+ install_${LOGIN_TYPE:-xinit}
+}
+
+install_lightdm()
+{
+ rm -rf $SERVICE
+ rm -rf $MNT/home/$NEWUSER/.{xinitrc,profile,zprofile,bash_profile}
+ 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
+# LightDM GTK+ Configuration
+
+[greeter]
+default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
+background=/usr/share/backgrounds/archlabs/archlabs.jpg
+theme-name=Adwaita-dark
+icon-theme-name=Adwaita
+font-name=DejaVu Sans Mono 11
+position=30%,end 50%,end
+EOF
+}
+
+install_awesome()
+{
+ # downloads and sets up @elenapan's awesome WM config hosted on github
+
+ if chrun "git clone https://github.com/elenapan/archlabs-awesome /home/$NEWUSER/archlabs-awesome"; then
+ cp -rT "/mnt/home/$NEWUSER/archlabs-awesome" "/mnt/home/$NEWUSER"
+ cp -rT "/mnt/home/$NEWUSER/archlabs-awesome" /mnt/etc/skel
+ rm -rf "/home/$NEWUSER/"{.git,archlabs-awesome,screenshots}
+ printf "You will need to instal pamac seperately if needed using: 'baph -i pamac-aur'\n"
+ sleep 3
+ else
+ printf "failed to clone awesome config repo\n"
fi
}
local rmpkg=""
local inpkg="$PACKAGES $USER_PKGS"
+ [[ -x $MNT/usr/bin/X ]] || inpkg+=" $BASE_PKGS"
+
if pacman -Qsq 'archlabs-installer' >/dev/null 2>&1; then
rmpkg+=" archlabs-installer"
elif [[ -e "$MNT/usr/bin/archlabs-installer" ]]; then
rm -f "$MNT/usr/bin/archlabs-installer"
fi
+ # add extras or missed packages gathered throughout the install
[[ $UCODE ]] && inpkg+=" $UCODE"
- [[ $MYSHELL == *mksh ]] && inpkg+=" mksh"
[[ $KERNEL == 'linux' ]] || { inpkg+=" $KERNEL"; rmpkg+=" linux"; }
- [[ $inpkg =~ (term|urxvt|tilix|alacritty|sakura|tilda|plasma|cinnamon) || $INSTALL_WMS == *dwm* ]] || inpkg+=" xterm"
- [[ $MYSHELL == '/usr/bin/zsh' ]] && inpkg+=" zsh-completions"
+ [[ $MYSHELL == "/usr/bin/mksh" ]] && inpkg+=" mksh"
+ if [[ $MYSHELL == '/usr/bin/zsh' ]]; then
+ inpkg+=" zsh-completions"
+ else
+ rmpkg+=" zsh"
+ fi
+
+ # packages only installed for certain WM/DE
[[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey"
[[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm|fluxbox) ]] && inpkg+=" $WM_BASE_PKGS"
+ # ensure a terminal gets installed
+ [[ $inpkg =~ (term|urxvt|tilix|alacritty|sakura|tilda|plasma|cinnamon) || $INSTALL_WMS == *dwm* ]] || inpkg+=" xterm"
+
+ # update fully first to avoid issues
chrun "pacman -Syyu --noconfirm"
+
+ # remove packages we no longer want
[[ $rmpkg ]] && chrun "pacman -Rns $rmpkg --noconfirm"
+
+ # for some reason the user has "no network" after install even though the
+ # system is connected, reinstalling iputils fixes it
chrun "pacman -S iputils --noconfirm"
+
+ # install all the packages chosen throughout the install
chrun "pacman -S $inpkg --needed --noconfirm" 2>$ERR
errshow 1 "pacman -S $inpkg --needed --noconfirm"
+ # extras for bootloaders
if [[ $BOOTLDR == 'grub' ]]; then
if [[ $SYS == 'BIOS' ]]; then
chrun "pacman -S grub os-prober --needed --noconfirm" 2>$ERR
chrun "pacman -S efibootmgr --needed --noconfirm" 2>$ERR
errshow 1 "pacman -S efibootmgr --needed --noconfirm"
fi
+
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
+
return 0
}
install_mirrorlist()
{
- mfile="$1"
+ local mfile="$1" # output mirrorlist file
if hash reflector >/dev/null 2>&1; then
reflector --score 120 -l 50 -f 5 --sort rate --save "$mfile"
elif hash rankmirrors >/dev/null 2>&1; then
- i="$(json 'ip' "check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip")"
- c="$(json 'country_code' "${i}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code")"
- if [[ $c && $c =~ (CA|US) ]]; then
- m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on"
- elif [[ $c ]]; then
- m="https://www.archlinux.org/mirrorlist/?country=${c}&use_mirror_status=on"
+ ip_add="$(curl -fsSL "http://api.ipstack.com/check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip" |
+ python -c "import sys, json; print(json.load(sys.stdin)['ip'])")"
+ country="$(curl -fsSL "http://api.ipstack.com/${ip_add}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code" |
+ python -c "import sys, json; print(json.load(sys.stdin)['country_code'])")"
+ if [[ "$country" ]]; then
+ if [[ $country =~ (CA|US) ]]; then
+ mirror="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on"
+ elif [[ $country =~ (AU|NZ) ]]; then
+ mirror="https://www.archlinux.org/mirrorlist/?country=AU&country=NZ&use_mirror_status=on"
+ else
+ mirror="https://www.archlinux.org/mirrorlist/?country=${country}&use_mirror_status=on"
+ fi
else
- m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on"
+ mirror="https://www.archlinux.org/mirrorlist/?country=all&use_mirror_status=on"
fi
- curl -s "$m" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -t -n 10 - | tail -n 10 >"$mfile"
+
+ curl -fsSL "$mirror" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 6 - >"$mfile"
fi
+
return 0
}
install_background()
{
if [[ -d /run/archiso/sfs/airootfs/etc/skel ]] && grep -qw "$MNT" /proc/mounts && (grep -qw "$MNT/$BOOTDIR" /proc/mounts || [[ $SYS == 'BIOS' && -z $LUKS ]]); then
- yesno "Background Install" "\nSome parts of the install can be done in the background now, base unpack, mirrorlist sort, system update, and base packages.\n\nDo you want to start the background process?\n" || return 0
+ yesno "Background Install" "\nBegin install in the background?\n" || return 0
rsync -a /run/archiso/sfs/airootfs/ $MNT/ &
RSYNC_PID=$!
- ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" && chrun "pacman -Syyu $BASE_PKGS --needed --noconfirm" ) >/dev/null 2>&1 &
+ ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" && sleep 1 && mkdir -p $MNT/var/lib/pacman && chrun "pacman -Syyu $BASE_PKGS --needed --noconfirm" >> /tmp/bg_out 2>&1 ) &
MIRROR_PID=$!
- trap "kill $RSYNC_PID 2>/dev/null; kill $MIRROR_PID 2>/dev/null" EXIT
+ # end the background processes before exiting
+ trap "kill $RSYNC_PID $MIRROR_PID 2>/dev/null" EXIT
fi
return 0
}
[[ $BOOT_DEV ]] || { part_device 1 || return 1; }
BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEV"
else
- if [[ $ROOT_PART == */dev/mapper/* && -z $LVM && -z $LUKS_PASS ]]; then
- luks_pass "$_luksopen" 1 || return 1
- fi
+ # if [[ $ROOT_PART == */dev/mapper/* && -z $LVM && -z $LUKS_PASS ]]; then
+ # luks_pass "$_luksopen" 1 || return 1
+ # fi
BCMDS[grub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1
grub-install --recheck --force --target=x86_64-efi --efi-directory=/$BOOTDIR --bootloader-id=$DIST"
grep -q /sys/firmware/efi/efivars /proc/mounts || mount -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1
fi
# setup for os-prober module
- mkdir -p /run/{lvm,udev}
- mkdir -p $MNT/hostrun/{lvm,udev}
+ mkdir -p /run/{lvm,udev} $MNT/hostrun/{lvm,udev}
mount --bind /run/lvm $MNT/hostrun/lvm
mount --bind /run/udev $MNT/hostrun/udev
BCMDS[systemd-boot]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1
efibootmgr -v -d $BOOT_DEV -p $BOOT_PART_NUM -c -L '${DIST} Linux' -l /vmlinuz-${KERNEL} \
-u 'root=$ROOT_PART_ID rw $([[ $UCODE ]] && printf 'initrd=\%s.img ' "$UCODE")initrd=\initramfs-${KERNEL}.img'"
- return 0
}
setup_syslinux()
EDIT_FILES[bootloader]="/boot/EFI/syslinux/syslinux.cfg"
BCMDS[syslinux]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1
efibootmgr -v -c -d $BOOT_DEV -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
-
fi
}
lvm_menu()
{
- check_background_install || return 1
+ is_bg_install || return 1
lvm_detect
local choice
dlg choice menu "Logical Volume Management" "$_lvmmenu" \
luks_menu()
{
local choice
- check_background_install || return 1
+ is_bg_install || return 1
dlg choice menu "LUKS Encryption" "$_luksmenu" \
"$_luksnew" "cryptsetup -q luksFormat" \
"$_luksopen" "cryptsetup open --type luks" \
die()
{
- local exitcode="$1"
+ local ecode="$1"
+
trap - INT
- trap - TSTP
tput cnorm
if [[ -d $MNT ]] && command cd /; then
umount_dir $MNT
- if (( exitcode == 127 )); then
- umount -l /run/archiso/bootmnt
+ if (( ecode == 127 )); then
+ umount_dir /run/archiso/bootmnt
sleep 0.5
- systemctl -i reboot
+ reboot -f
fi
fi
-
- # restore custom linux console 0-15 colors when not rebooting
- if [[ $TERM == 'linux' ]]; then
- colors=("\e]P0191919" "\e]P1D15355" "\e]P2609960" "\e]P3FFCC66"
- "\e]P4255A9B" "\e]P5AF86C8" "\e]P62EC8D3" "\e]P7949494" "\e]P8191919" "\e]P9D15355"
- "\e]PA609960" "\e]PBFF9157" "\e]PC4E88CF" "\e]PDAF86C8" "\e]PE2ec8d3" "\e]PFE1E1E1")
- printf "%b" "${colors[@]}" && clear && unset col
- fi
-
- exit "$exitcode"
+ termcol
+ exit "$ecode"
}
dlg()
tput civis
case "$dialog_type" in
- menu)
- dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --menu "$body" 0 0 $n "$@" 2>"$ANS" || return 1
- ;;
- check)
- dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --checklist "$body" 0 0 $n "$@" 2>"$ANS" || return 1
- ;;
+ menu) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --menu "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;;
+ check) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --checklist "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;;
input)
tput cnorm
local def="$1"
fi
}
-json()
-{
- curl -s "http://api.ipstack.com/$2" | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])"
-}
-
yesno()
{
local title="$1" body="$2" yes='Yes' no='No'
- (( $# >= 3 )) && local yes="$3"
- (( $# >= 4 )) && local no="$4"
+ (( $# >= 3 )) && yes="$3"
+ (( $# >= 4 )) && no="$4"
tput civis
if (( $# == 5 )); then
dialog --backtitle "$DIST Installer - $SYS - v$VER" --defaultno --title " $title " --yes-label "$yes" --no-label "$no" --yesno "$body\n" 0 0
print4()
{
local str="$*"
+
if [[ $COLUMNS -ge 110 && ${#str} -gt $((COLUMNS - 30)) ]]; then
str="$(awk '{
i = 2; p1 = p2 = p3 = p4 = ""; p1 = $1; q = int(NF / 4)
fi
}
+termcol()
+{
+ local colors=(
+ "\e]P0191919" # #191919
+ "\e]P1D15355" # #D15355
+ "\e]P2609960" # #609960
+ "\e]P3FFCC66" # #FFCC66
+ "\e]P4255A9B" # #255A9B
+ "\e]P5AF86C8" # #AF86C8
+ "\e]P62EC8D3" # #2EC8D3
+ "\e]P7949494" # #949494
+ "\e]P8191919" # #191919
+ "\e]P9D15355" # #D15355
+ "\e]PA609960" # #609960
+ "\e]PBFF9157" # #FF9157
+ "\e]PC4E88CF" # #4E88CF
+ "\e]PDAF86C8" # #AF86C8
+ "\e]PE2ec8d3" # #2ec8d3
+ "\e]PFE1E1E1" # #E1E1E1
+ )
+
+ [[ $TERM == 'linux' ]] && printf "%b" "${colors[@]}" && clear
+}
+
errshow()
{
- exit_code="$?"
- (( exit_code == 0 )) && return 0
+ [ $? -eq 0 ] && return 0
local fatal=0 err=""
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
+
(( $1 == 1 )) && { fatal=1; shift; }
+
local txt="\nThe command exited abnormally:\n\n$1\n\n"
if [[ $err ]]; then
txt+="With no error message:\n\n"
fi
- if (( fatal == 1 )); then
+ if (( fatal )); then
txt+="Errors at this stage are fatal and the install cannot continue.\n"
else
txt+="Errors at this stage are non-fatal and can be either fixed or ignored depending on the error.\n"
fi
-
msg "Install Error" "$txt"
- if (( fatal == 1 )); then
+ if (( fatal )); then
[[ -r $DBG && $TERM == 'linux' ]] && less "$DBG"
die 1
fi
prechecks()
{
- if [[ $1 -ge 0 ]] && ! grep -qw "$MNT" /proc/mounts; then
+ local i=1
+
+ if (( $1 >= 0 )) && ! grep -qw "$MNT" /proc/mounts; then
msg "Not Mounted" "\nPartition(s) must be mounted first.\n" 2
- SEL=4
- return 1
+ SEL=4 i=0
elif [[ $1 -ge 1 && -z $BOOTLDR ]]; then
msg "No Bootloader" "\nBootloader must be selected first.\n" 2
- SEL=5
- return 1
+ SEL=5 i=0
elif [[ $1 -ge 2 && (-z $NEWUSER || -z $USER_PASS) ]]; then
msg "No User" "\nA user must be created first.\n" 2
- SEL=6
- return 1
+ SEL=6 i=0
elif [[ $1 -ge 3 && -z $CONFIG_DONE ]]; then
msg "Not Configured" "\nSystem configuration must be done first.\n" 2
- SEL=7
- return 1
+ SEL=7 i=0
fi
- return 0
+ (( i )) # return code
}
umount_dir()
{
- swapoff -a
- [[ -d $1 ]] && umount -R "$1" >/dev/null 2>&1
- return 0
+ mount | grep -q 'swap' && swapoff -a
+ for dir; do
+ [[ -d $dir ]] || continue
+ umount "$dir" 2>/dev/null || { sleep 0.5; umount -f "$dir" 2>/dev/null || umount -l "$dir"; }
+ done
}
chk_connect()
else
if hash nmtui >/dev/null 2>&1; then
tput civis
- [[ $TERM == 'linux' ]] && printf "%b" "\e]P1191919" "\e]P4191919"
- nmtui-connect
- [[ $TERM == 'linux' ]] && printf "%b" "\e]P1D15355" "\e]P4255a9b"
+ if [[ $TERM == 'linux' ]]; then
+ printf "%b" "\e]P1191919" "\e]P4191919"
+ nmtui-connect
+ printf "%b" "\e]P1D15355" "\e]P4255a9b"
+ else
+ nmtui-connect
+ fi
chk_connect
else
return 1
fi
}
+is_bg_install()
+{
+ [[ $RSYNC_PID || $MIRROR_PID ]] || return 0
+ msg "Install Running" "\nA background install process is currently running.\n" 2
+ return 1
+}
+
system_devices()
{
IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
_prep+="\n - Basic system configuration, kernel, shell, login, packages, etc..\n\nOnce you're happy with the choices and the required steps are complete, the main install can be started."
}
-check_background_install()
-{
- [[ $RSYNC_PID || $MIRROR_PID ]] || return 0
- msg "Install Running" "\nA background install process is currently running.\n" 2
- return 1
-}
-
###############################################################################
# entry point
+# enable some nicer colours in the linux console
+termcol
+
if (( UID != 0 )); then
msg "Not Root" "\nThis installer must be run as root or using sudo.\n\nExiting..\n" 2
die 1