You've already forked al-installer
Clean up boot, move funtion to file it's used in
This commit is contained in:
@ -6,49 +6,6 @@
|
||||
# this file is not meant to be run directly
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
select_boot_setup() {
|
||||
# choose bootloader and by extension mountpoint (if needed)
|
||||
tput civis
|
||||
BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"
|
||||
[[ $? != 0 || $BOOTLDR == "" ]] && return 1
|
||||
|
||||
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 [[ $BOOTLDR == 'systemd-boot' ]]; then
|
||||
FILES[9]="/boot/loader/entries/$DIST.conf"
|
||||
elif [[ $BOOTLDR == 'syslinux' ]]; then
|
||||
if [[ $SYS == 'BIOS' ]]; then
|
||||
FILES[9]="/boot/syslinux/syslinux.cfg"
|
||||
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 || ${BCMDS[$BOOTLDR]} == "" ]] && return 1
|
||||
else
|
||||
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"
|
||||
fi
|
||||
else
|
||||
FILES[9]="/etc/default/grub"
|
||||
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
local ttype
|
||||
[[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
|
||||
else
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
|
||||
fi
|
||||
|
||||
BCMDS[grub]="${BCMDS[grub]} && grub-mkconfig -o /boot/grub/grub.cfg"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
shim_secure_boot() {
|
||||
# still a W.I.P
|
||||
local shim_file="shim64.efi"
|
||||
@ -192,13 +149,15 @@ install_bootloader() {
|
||||
fi
|
||||
|
||||
# remove old UEFI boot entries
|
||||
[[ $SYS == 'UEFI' ]] && find $MNT${BMNTS[$SYS-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \
|
||||
-name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
find ${MNT}${BMNTS[$SYS-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \
|
||||
-name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# sets up the bootloader configs
|
||||
# sets up the bootloader configs and BCMD (boot command)
|
||||
prep_for_$BOOTLDR
|
||||
|
||||
# run the bootloader command
|
||||
# install/setup the bootloader by running the BCMD (boot command)
|
||||
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
||||
check_for_errors "${BCMDS[$BOOTLDR]}"
|
||||
|
||||
|
@ -7,33 +7,37 @@
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
install_main() {
|
||||
# unpack the whole filesystem to install directory $MNT
|
||||
clear && tput cnorm
|
||||
|
||||
# unpack the file system
|
||||
oneshot install_base
|
||||
|
||||
# generate /etc/fstab and touch it up if we used a swapfile
|
||||
genfstab -U $MNT > $MNT/etc/fstab 2>$ERR
|
||||
check_for_errors "genfstab -U $MNT > $MNT/etc/fstab"
|
||||
|
||||
# touch up /etc/fstab if we used a swapfile
|
||||
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
||||
|
||||
# update the mirrorlist
|
||||
# MUST be 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
|
||||
# update the mirrorlist.. MUST be done before updating or it may be slow
|
||||
$MIRROR_CMD --verbose --save $MNT/etc/pacman.d/mirrorlist ||
|
||||
reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
|
||||
|
||||
oneshot update_system # MUST be before bootloader and mkinitcpio
|
||||
# MUST be before bootloader and mkinitcpio
|
||||
oneshot package_operations
|
||||
|
||||
[[ $LOGIN_TYPE == 'lightdm' ]] && oneshot setup_lightdm
|
||||
# set up user login
|
||||
oneshot login_manager
|
||||
|
||||
# MUST be done after installing the packages
|
||||
run_mkinitcpio
|
||||
install_bootloader
|
||||
|
||||
chroot_cmd "hwclock --systohc --utc" || chroot_cmd "hwclock --systohc --utc --directisa"
|
||||
oneshot create_user
|
||||
|
||||
oneshot create_user # create the user last to avoid referencing multiple $HOME locations
|
||||
return 0
|
||||
}
|
||||
|
||||
install_base() {
|
||||
clear
|
||||
tput cnorm
|
||||
echo -e "\nUnpacking base file system --- Total: ~ 2.8G\n\n"
|
||||
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
||||
|
||||
@ -61,7 +65,7 @@ EndSection
|
||||
EOF
|
||||
fi
|
||||
|
||||
# copy the kernel image fofr the regular kernel
|
||||
# copy the kernel image for the regular kernel
|
||||
[[ $KERNEL != 'linux-lts' ]] && cp -f $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
|
||||
|
||||
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
|
||||
@ -114,137 +118,126 @@ EOF
|
||||
}
|
||||
|
||||
create_user() {
|
||||
local _home="$MNT/home/$LIVE"
|
||||
local service="$MNT/etc/systemd/system/getty@tty1.service.d"
|
||||
|
||||
# set root password
|
||||
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
|
||||
|
||||
# edit the required files in /etc/ to swap the liveuser account name
|
||||
# edit the group and passwd files in /etc/ to swap the liveuser account
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
|
||||
# fix up some user files that reference the liveuser
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/home/$LIVE/.config/gtk-3.0/bookmarks \
|
||||
$MNT/home/$LIVE/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js
|
||||
|
||||
# set standard groups for the new user
|
||||
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
|
||||
|
||||
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
||||
[[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
|
||||
rm -rf $_home/.{zprofile,xinitrc}
|
||||
rm -rf $service
|
||||
else
|
||||
if [[ $AUTOLOGIN == true ]]; then
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $service/autologin.conf
|
||||
else
|
||||
rm -rf $service
|
||||
fi
|
||||
sed -i "s/openbox-session/${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 $_home/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js
|
||||
|
||||
! [[ $INSTALL_WMS =~ openbox ]] && rm -rf $_home/.config/{openbox,skippy-xd,jgmenu,conky,tint2}
|
||||
! [[ $INSTALL_WMS =~ bspwm ]] && rm -rf $_home/.config/{bspwm,sxhkd}
|
||||
! [[ $INSTALL_WMS =~ i3-gaps ]] && rm -rf $_home/.config/i3
|
||||
[[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$LIVE/.config/{bspwm,sxhkd}
|
||||
[[ $INSTALL_WMS =~ i3-gaps ]] || rm -rf $MNT/home/$LIVE/.config/i3
|
||||
[[ $INSTALL_WMS =~ openbox ]] || rm -rf $MNT/home/$LIVE/.config/{openbox,skippy-xd,jgmenu,conky,tint2}
|
||||
|
||||
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
|
||||
chroot_cmd "usermod -aG $groups $NEWUSER"
|
||||
chroot_cmd "usermod -aG rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin $NEWUSER"
|
||||
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd"
|
||||
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
run_mkinitcpio() {
|
||||
local add=""
|
||||
|
||||
# setup a keyfile for LUKS.. Only when choosing grub and system is UEFI
|
||||
[[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
|
||||
[[ $LUKS -eq 1 && $LVM -eq 0 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
|
||||
|
||||
# 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")"
|
||||
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $MNT/etc/mkinitcpio.conf
|
||||
|
||||
local conf="$MNT/etc/mkinitcpio.conf"
|
||||
|
||||
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $conf
|
||||
|
||||
tput civis
|
||||
chroot_cmd "mkinitcpio -p $KERNEL" 2>$ERR
|
||||
check_for_errors "mkinitcpio -p $KERNEL"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
update_system() {
|
||||
tput cnorm
|
||||
local inpkg="base-devel git"
|
||||
local rmpkg="archlabs-installer"
|
||||
local vbx="virtualbox-guest-modules-arch"
|
||||
package_operations() {
|
||||
local inpkg="$EXTRA_PACKAGES" # add the packages chosen during setup
|
||||
local rmpkg="archlabs-installer" # always remove the installer
|
||||
local vbx="virtualbox-guest-modules-arch" # save retyping this multiple times
|
||||
|
||||
# the LTS kernel uses different packages
|
||||
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
|
||||
inpkg="$inpkg linux-lts"
|
||||
# if the system is a VM then install the needed packages otherwise remove the guest utils
|
||||
[[ $VM ]] && inpkg="$inpkg virtualbox-guest-dkms linux-lts-headers" || rmpkg="$rmpkg virtualbox-guest-utils"
|
||||
elif ! [[ $VM ]]; then
|
||||
# if the system is not a VM then remove the guest utils
|
||||
rmpkg="$rmpkg $vbx virtualbox-guest-utils"
|
||||
fi
|
||||
|
||||
# for gnome and cinnamon we don't need the xfce provided stuff
|
||||
# for only gnome or cinnamon we don't need the xfce provided stuff
|
||||
[[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]] && rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
|
||||
|
||||
# when not using grub bootloader remove it's package and configurations
|
||||
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
|
||||
elif [[ $BOOTLDR != 'syslinux' ]]; then
|
||||
# do the same when not using syslinux as the bootloader
|
||||
find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
|
||||
# iputils, base-devel, and git are all needed and should always be installed separately
|
||||
local base="pacman -S iputils git --noconfirm; pacman -S base-devel --needed --noconfirm"
|
||||
local install="pacman -S $inpkg --needed --noconfirm"
|
||||
local remove="pacman -Rs $rmpkg --noconfirm"
|
||||
|
||||
chroot_cmd "pacman -Syyu --noconfirm; pacman -S iputils --noconfirm; $install; $remove" 2>/dev/null
|
||||
chroot_cmd "pacman -Syyu --noconfirm; $base; $install; $remove" 2>/dev/null
|
||||
|
||||
# for neovim copy the default vimrc and colorscheme to ~/.config/nvim
|
||||
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
|
||||
mkdir -p $MNT/home/$LIVE/.config/nvim
|
||||
cp -f $MNT/home/$LIVE/.vimrc $MNT/home/$LIVE/.config/nvim/init.vim
|
||||
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home/$LIVE/.config/nvim/colors
|
||||
fi
|
||||
|
||||
# install and setup dwm
|
||||
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"
|
||||
for prog in dwm dmenu st; do
|
||||
chroot_cmd "git clone https://bitbucket.org/natemaia/$prog /home/$LIVE/suckless/$prog && cd /home/$LIVE/suckless/$prog"
|
||||
[[ -e $MNT/home/$LIVE/suckless/$prog/config.h ]] && rm -f $MNT/home/$LIVE/suckless/$prog/config.h
|
||||
chroot_cmd "make clean install && make clean"
|
||||
done
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_lightdm() {
|
||||
local cfg="$MNT/etc/lightdm/lightdm-gtk-greeter.conf"
|
||||
login_manager() {
|
||||
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
|
||||
rm -rf $MNT/etc/systemd/system/getty@tty1.service.d
|
||||
for file in $MNT/home/$LIVE/.{xinitrc,zprofile}; do
|
||||
awk '{if($0 && $0 !~ "^#") print "# "$0; else print $0}' $file > $file
|
||||
done
|
||||
chroot_cmd 'systemctl enable lightdm.service && systemctl set-default graphical.target'
|
||||
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF
|
||||
# LightDM GTK+ Configuration
|
||||
|
||||
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-Dark' $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
|
||||
[greeter]
|
||||
active-monitor=0
|
||||
default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
|
||||
background=/usr/share/backgrounds/archlabs/archlabs.jpg
|
||||
theme-name=ArchLabs-dARK
|
||||
icon-theme-name=Adwaita
|
||||
font-name=DejaVu Sans Mono 11
|
||||
position=30%,end 50%,end
|
||||
EOF
|
||||
if [[ $AUTOLOGIN == true ]]; then
|
||||
chroot_cmd "groupadd -r nopasswdlogin && usermod -aG nopasswdlogin $NEWUSER"
|
||||
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
|
||||
else # xinit login
|
||||
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$LIVE/.xinitrc
|
||||
sed -i 's|exec sudo archlabs-installer|exec startx -- vt1 &>/dev/null|' $MNT/home/$LIVE/.zprofile
|
||||
if [[ $AUTOLOGIN == true ]]; then
|
||||
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/systemd/system/getty@tty1.service.d/autologin.conf
|
||||
else
|
||||
rm -rf $MNT/etc/systemd/system/getty@tty1.service.d
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -376,6 +376,47 @@ select_swap() {
|
||||
return 0
|
||||
}
|
||||
|
||||
select_boot_setup() {
|
||||
# choose bootloader and by extension mountpoint (if needed)
|
||||
tput civis
|
||||
BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"
|
||||
[[ $? != 0 || $BOOTLDR == "" ]] && return 1
|
||||
|
||||
# grub on BIOS needs an install device, NOT partition eg. /dev/sda
|
||||
if [[ $SYS == 'BIOS' && $BOOTLDR == 'grub' && $BOOT_DEVICE == "" ]]; then
|
||||
select_device 'boot' || return 1
|
||||
fi
|
||||
|
||||
if [[ $BOOTLDR == 'systemd-boot' ]]; then
|
||||
FILES[9]="/boot/loader/entries/$DIST.conf"
|
||||
elif [[ $BOOTLDR == 'syslinux' ]]; then
|
||||
if [[ $SYS == 'BIOS' ]]; then
|
||||
FILES[9]="/boot/syslinux/syslinux.cfg"
|
||||
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 || ${BCMDS[$BOOTLDR]} == "" ]] && return 1
|
||||
else
|
||||
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"
|
||||
fi
|
||||
else
|
||||
FILES[9]="/etc/default/grub"
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
local ttype
|
||||
[[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
|
||||
else
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
|
||||
fi
|
||||
|
||||
BCMDS[grub]="${BCMDS[grub]} && grub-mkconfig -o /boot/grub/grub.cfg"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
select_mount_opts() {
|
||||
local part="$1"
|
||||
local fs="$2"
|
||||
|
Reference in New Issue
Block a user