Create fallback config for systemd-boot

This commit is contained in:
natemaia
2019-01-12 16:56:00 -08:00
parent b4e5e00147
commit 7efdb466a7
4 changed files with 106 additions and 151 deletions

View File

@ -8,7 +8,7 @@
# Some ideas and code has been taken from other installers
# AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due
VER="1.8.16" # version
VER="1.8.21" # version
DIST="ArchLabs" # distributor
MNT="/mnt" # mountpoint
@ -135,7 +135,7 @@ cfg_menu()
tput civis
if ! LOCALE="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $((LINES - 10)) $LOCALES)"; then
--title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $((LINES - 20)) $LOCALES)"; then
return 1
fi
@ -202,7 +202,7 @@ select_keymap()
{
tput civis
if ! KEYMAP="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_PrepLayout " --menu "$_XMapBody" 0 0 $((LINES - 10)) \
--title " $_PrepLayout " --menu "$_XMapBody" 0 0 $((LINES - 20)) \
'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \
'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \
'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \
@ -230,7 +230,8 @@ select_keymap()
if [[ $CMAPS == *"$KEYMAP"* ]]; then
CMAP="$KEYMAP"
else
if ! CMAP="$(menubox "$_CMapTitle" "$_CMapBody" $CMAPS)"; then
if ! CMAP="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_CMapTitle " --menu "$_CMapBody" 0 0 $((LINES - 17)) $CMAPS)"; then
return 1
fi
fi
@ -260,7 +261,7 @@ select_timezone()
fi
if ! SUBZONE="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 10)) ${SUBZONES[$ZONE]})"; then
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 17)) ${SUBZONES[$ZONE]})"; then
return 1
fi
@ -630,7 +631,8 @@ partition()
"gparted -" \
"cfdisk" "-" \
"parted" "-" \
"$_PartWipe" "-")"; then
"$_PartWipe" "-" \
"$_Done" "-")"; then
return 1
fi
else
@ -639,13 +641,16 @@ partition()
"$_PartAuto" "-" \
"cfdisk" "-" \
"parted" "-" \
"$_PartWipe" "-")"; then
"$_PartWipe" "-" \
"$_Done" "-")"; then
return 1
fi
fi
tput civis
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then
if [[ $choice == "$_Done" || $choice == "" ]]; then
return 0
elif [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then
clear; tput cnorm; $choice $device
elif [[ $choice == "$_PartShowTree" ]]; then
msgbox "$_PrepShowDev" "\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT "$device")\n"
@ -868,10 +873,10 @@ mount_partition()
mkdir -p "$mountp"
if [[ $fs && ${FS_OPTS[$fs]} && $part != "$BOOT_PART" ]] && select_mount_opts "$part" "$fs"; then
mount -o $MNT_OPTS $part "$mountp" 2>$ERR
mount -o $MNT_OPTS "$part" "$mountp" 2>$ERR
errshow "mount -o $MNT_OPTS $part $mountp"
else
mount $part "$mountp" 2>$ERR
mount "$part" "$mountp" 2>$ERR
errshow "mount $part $mountp"
fi
@ -1113,7 +1118,7 @@ select_boot_partition()
BOOT_PART=""
else
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormBiosBody $BOOT_PART $_FormUefiBody2"
local msg="$_FormBiosBody $BOOT_PART $_FormBiosBody2"
if [[ $AUTO_BOOT_PART != "$BOOT_PART" ]] && yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format "$BOOT_PART" "ext4"
sleep 1
@ -1173,7 +1178,7 @@ install()
clear
tput cnorm
install_base
printf "\nGenerating system /etc/fstab\n\n"
printf "Generating system /etc/fstab\n"
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR
echeck "genfstab -U $MNT >$MNT/etc/fstab"
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
@ -1195,20 +1200,21 @@ install_base()
echeck "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/"
else
mirrorlist_sort
pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt)
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)"
fi
printf "\nRemoving archiso remains\n\n"
printf "Removing archiso remains\n"
rm -rf $MNT/etc/mkinitcpio-archiso.conf
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm -rf '{}' \;
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
if [[ $VM ]]; then
printf "\nRemoving xorg configs in /etc/X11/xorg.conf.d/ to avoid conflict in VMs\n\n"
printf "Removing xorg configs in /etc/X11/xorg.conf.d/ to avoid conflict in VMs\n"
rm -rfv $MNT/etc/X11/xorg.conf.d/*?.conf
sleep 1
elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
printf "\nCreating intel GPU 'TearFree' config in /etc/X11/xorg.conf.d/20-intel.conf\n\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
Section "Device"
Identifier "Intel Graphics"
@ -1219,18 +1225,18 @@ EOF
fi
if [[ -e /run/archiso/sfs/airootfs ]]; then
printf "\nCopying vmlinuz and ucode to /boot\n\n"
printf "Copying vmlinuz and ucode to /boot\n"
[[ $KERNEL != 'linux-lts' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
[[ $UCODE && ! $VM ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/${UCODE}.img
fi
printf "\nCopying network settings to /etc\n\n"
printf "Copying network settings to /etc\n"
cp -fv /etc/resolv.conf $MNT/etc/
if [[ -e /etc/NetworkManager/system-connections ]]; then
cp -rvf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
fi
printf "\nSetting locale to $LOCALE\n\n"
printf "Setting locale to $LOCALE\n"
cat > $MNT/etc/locale.conf << EOF
LANG=$LOCALE
EOF
@ -1238,17 +1244,17 @@ EOF
LANG=$LOCALE
EOF
sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${LOCALE}/${LOCALE}/g" $MNT/etc/locale.gen
chrun "echo && locale-gen" 2>/dev/null
printf "\nSetting timezone: $ZONE/$SUBZONE\n\n"
chrun "locale-gen" 2>/dev/null
printf "Setting timezone: $ZONE/$SUBZONE\n"
chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime" 2>/dev/null
if [[ $BROADCOM_WL == true ]]; then
printf "\nBlacklisting modules for broadcom wireless: bmca\n\n"
printf "Blacklisting modules for broadcom wireless: bmca\n"
echo 'blacklist bcma' >> $MNT/etc/modprobe.d/blacklist.conf
rm -f $MNT/etc/modprobe/
fi
printf "\nCreating keyboard configurations for keymap: $KEYMAP\n\n"
printf "Creating keyboard configurations for keymap: $KEYMAP\n"
cat > $MNT/etc/X11/xorg.conf.d/00-keyboard.conf <<EOF
# Use localectl(1) to instruct systemd-localed to update it.
Section "InputClass"
@ -1270,7 +1276,7 @@ EOF
KEYMAP=$CMAP
FONT=$FONT
EOF
printf "\nSetting system hostname: $HOSTNAME\n\n"
printf "Setting system hostname: $HOSTNAME\n"
cat > $MNT/etc/hostname << EOF
$HOSTNAME
EOF
@ -1286,11 +1292,10 @@ EOF
create_user()
{
printf "\nCreating user $NEWUSER, setting passwords, and setting shell\n\n"
printf "Creating user $NEWUSER, setting passwords, and setting shell\n"
# set root password, shell if needed
chrun "chpasswd <<< 'root:$ROOT_PASS'"
cp -rf /etc/skel/. $MNT/root/
if [[ $MYSHELL != *zsh ]]; then
chrun "usermod -s $MYSHELL root"
if [[ $MYSHELL == "/usr/bin/mksh" ]]; then
@ -1312,8 +1317,10 @@ create_user()
cp -rfv $MNT/home/$NEWUSER/.vim/colors $MNT/home/$NEWUSER/.config/nvim/colors
fi
[[ $INSTALL_WMS =~ dwm ]] && suckless_install
[[ $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
sed -i '/super/d' $HOME/.xprofile /root/.xprofile
fi
return 0
}
@ -1323,7 +1330,7 @@ setup_xinit()
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$NEWUSER/.xinitrc
else
printf "%s\n" "exec $LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc
printf "exec $LOGIN_WM\n" > $MNT/home/$NEWUSER/.xinitrc
fi
# automatic startx for login shells
@ -1402,7 +1409,7 @@ EOF
login_manager()
{
printf "\nSetting up $LOGIN_TYPE\n\n"
printf "Setting up $LOGIN_TYPE\n"
SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d"
# remove welcome message
@ -1435,13 +1442,13 @@ run_mkinitcpio()
[[ $LUKS ]] && add="encrypt"
[[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; }
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
chrun "mkinitcpio -p $KERNEL" 2>$ERR
echeck "mkinitcpio -p $KERNEL"
}
mirrorlist_sort()
{
printf "\n%s\n\n" "Sorting the mirrorlist"
printf "Sorting the mirrorlist\n"
if hash reflector >/dev/null 2>&1; then
$MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist --verbose ||
reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
@ -1465,22 +1472,22 @@ package_operations()
# update first to avoid database access errors
chrun "pacman -Syyu --noconfirm"
if ! [[ $INSTALL_WMS == 'plasma' || $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
chrun "pacman -S archlabs-ksuperkey --noconfirm --needed"
if [[ $BOOTLDR == 'grub' ]]; then
chrun "pacman -Rns $rmpkg grub --noconfirm"
else
chrun "pacman -Rns $rmpkg --noconfirm"
fi
if [[ $BOOTLDR != 'grub' ]]; then
chrun "pacman -Rns grub --noconfirm"
fi
chrun "pacman -Rns $rmpkg --noconfirm"
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 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 [[ $LOGIN_TYPE == 'xinit' ]]; then
chrun "pacman -S xorg-xinit --needed --noconfirm"
fi
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
if ! [[ $INSTALL_WMS == 'plasma' || $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
chrun "pacman -S archlabs-ksuperkey --noconfirm --needed"
fi
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
return 0
}
@ -1488,7 +1495,7 @@ package_operations()
suckless_install()
{
# install and setup dwm
printf "\n%s\n\n" "Installing and setting up dwm."
printf "Installing and setting up dwm\n"
mkdir -pv $MNT/home/$NEWUSER/suckless
for i in dwm dmenu st; do
@ -1498,13 +1505,12 @@ suckless_install()
if (( e == 0 )); then
chrun "cd $p; rm -f config.h; make clean install; make clean"
else
printf "\n\nFailed to clone $i repo\n\n"
printf "Failed to clone $i repo\n"
fi
done
if [[ -d /home/$NEWUSER/suckless/dwm ]]; then
printf "\n\n%s" "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h"
printf "\n%s\n\n" "You can then recompile it with 'sudo make clean install'"
printf "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h\n"
printf "You can then recompile it with 'sudo make clean install'\n"
sleep 2
fi
}
@ -1607,6 +1613,12 @@ title $DIST Linux
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img")
initrd /initramfs-$KERNEL.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF
cat > ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries/${DIST}-fallback.conf << EOF
title $DIST Linux Fallback
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img")
initrd /initramfs-$KERNEL-fallback.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF
# add pacman hook to update the bootloader when systemd receives an update
mkdir -p $MNT/etc/pacman.d/hooks
@ -1679,8 +1691,8 @@ install_bootloader()
fi
prerun_$BOOTLDR
printf "\nInstalling and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n\n"
chrun "${BCMDS[$BOOTLDR]}"
printf "Installing and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n"
chrun "${BCMDS[$BOOTLDR]}" 2>$ERR
echeck "${BCMDS[$BOOTLDR]}"
if [[ -d $MNT/hostrun ]]; then
@ -2018,10 +2030,7 @@ luks_open()
return 1
fi
if ! luks_pass "$_LuksOpen" "${LUKS_NAME:-cryptroot}"; then
return 1
fi
luks_pass "$_LuksOpen" "${LUKS_NAME:-cryptroot}" || return 1
infobox "$_LuksOpen" "$_LuksOpenWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup open --type luks $LUKS_PART $LUKS_NAME"
@ -2169,7 +2178,7 @@ src()
{
# source file ($1), if it fails we die with an error message
if ! . "$1" 2>/dev/null; then
printf "\nFailed to source file %s\n" "$1"
printf "Failed to source file %s\n" "$1"
die 1
fi
return 0
@ -2219,7 +2228,7 @@ die()
sigint()
{
# used to trap SIGINT and cleanly exit the program
printf "\nCTRL-C caught\nCleaning up...\n"
printf "CTRL-C caught\nCleaning up...\n"
die 1
}
@ -2227,29 +2236,21 @@ print4()
{
# takes an arbitrary number of input fields and prints them out in fourths on separate lines
local str="$*"
if [[ ${#str} -gt $((COLUMNS / 2)) ]]; then
str="$(awk -v q="$(awk '{print int(NF / 4)}' <<< "$str")" '{
pkgs1=pkgs2=pkgs3=pkgs4=""
for (i=1; i<q; i++) {
if (i == 1) {
pkgs1=$i
} else {
pkgs1=pkgs1" "$i
}
}
for (i=q; i<q * 2; i++) {
pkgs2=pkgs2" "$i
}
for (i=q * 2; i<q * 3; i++) {
pkgs3=pkgs3" "$i
}
for (i=q * 3; i<NF; i++) {
pkgs4=pkgs4" "$i
}
printf "%s\n %s\n %s\n %s", pkgs1, pkgs2, pkgs3, pkgs4
if [[ ${#str} -gt $((COLUMNS - 5)) ]]; then
str="$(awk '{
p1=p2=p3=p4=""
p1=$1
q=int(NF / 4)
for (i=2; i<=q; i++) { p1=p1" "$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*3; i<=NF; i++) { p4=p4" "$i }
printf "%s\n\t%s\n\t%s\n\t%s", p1, p2, p3, p4
}' <<< "$str")"
printf "%s\n" "$str"
elif [[ $str ]]; then
printf "%s\n" "$str"
fi
printf "%s\n" "$str"
}
system_devices()
@ -2389,7 +2390,7 @@ echeck()
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
if [[ $err ]]; then
msgbox "$_ErrTitle" "\nERROR: $err"
msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the following message: $err"
else
msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n"
fi
@ -2484,7 +2485,8 @@ select_language()
{
tput civis
local lang
lang=$(menubox "Select Language" "\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" \
lang=$(menubox "Select Language" \
"\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" \
"1" "English (en_**)" \
"2" "Español (es_ES)" \
"3" "Português [Brasil] (pt_BR)" \
@ -2597,8 +2599,8 @@ CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
}' | sort)"
# make sure these are defined for some dialog size calculation
: "${LINES=$(tput lines)}"
: "${COLUMNS=$(tput cols)}"
[[ $LINES ]] || LINES=$(tput lines)
[[ $COLUMNS ]] || COLUMNS=$(tput cols)
# various associative arrays
# {
@ -2641,7 +2643,7 @@ declare -A WM_EXT=(
[gnome]=""
[plasma]="kdebase-meta"
[bspwm]="sxhkd archlabs-skel-bspwm rofi archlabs-polybar"
[xfce4]="xfce4-goodies xfce4-pulseaudio-plugin archlabs-skel-xfce4"
[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"
[openbox]="obconf archlabs-skel-openbox jgmenu archlabs-polybar tint2 conky rofi"
)