Clean up boot, move funtion to file it's used in
This commit is contained in:
parent
989a952751
commit
b5fa475863
22
install.sh
22
install.sh
@ -1,11 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
readonly SCRIPT_DIR="$(readlink -f ${0%/*})"
|
hash git >/dev/null 2>&1 || { echo "This requires git installed"; exit 1; }
|
||||||
|
git clone --depth=1 https://bitbucket.org/archlabslinux/installer
|
||||||
|
|
||||||
echo; echo "This requires root privileges"
|
echo
|
||||||
sudo mkdir -pv /usr/share/archlabs/{docs,lib,lang}
|
echo "Root access is needed to continue"
|
||||||
sudo cp -fv $SCRIPT_DIR/src/archlabs-installer /usr/bin/
|
echo
|
||||||
sudo cp -fv $SCRIPT_DIR/src/lib/*.sh /usr/share/archlabs/lib/
|
sudo mkdir -p /usr/share/archlabs/installer/lang
|
||||||
sudo cp -fv $SCRIPT_DIR/lang/*.trans /usr/share/archlabs/lang/
|
sudo mkdir -p /usr/share/archlabs/installer/lib
|
||||||
sudo cp -fv $SCRIPT_DIR/{LICENSE,README.md} /usr/share/archlabs/docs/
|
sudo mkdir -p /usr/share/archlabs/installer/docs
|
||||||
echo; echo "Install complete"
|
sudo cp -fv installer/src/archlabs-installer /usr/bin/
|
||||||
|
sudo cp -fv installer/src/lib/*.sh /usr/share/archlabs/installer/lib/
|
||||||
|
sudo cp -fv installer/lang/*.trans /usr/share/archlabs/installer/lang/
|
||||||
|
sudo cp -fv installer/{LICENSE,README.md} /usr/share/archlabs/installer/docs/
|
||||||
|
echo
|
||||||
|
echo "Install complete"
|
||||||
|
@ -12,25 +12,19 @@
|
|||||||
# immutable variables {
|
# immutable variables {
|
||||||
|
|
||||||
readonly DIST="ArchLabs" # Linux distributor
|
readonly DIST="ArchLabs" # Linux distributor
|
||||||
readonly VER="1.6.73" # Installer version
|
readonly VER="1.6.74" # Installer version
|
||||||
readonly LIVE="liveuser" # Live session user
|
readonly LIVE="liveuser" # Live session user
|
||||||
readonly MNT="/mnt/install" # Install mountpoint
|
readonly MNT="/mnt/install" # Install mountpoint
|
||||||
readonly ERR="/tmp/errlog" # Built-in error log
|
readonly ERR="/tmp/errlog" # Built-in error log
|
||||||
|
|
||||||
readonly EFI="/sys/firmware/efi/efivars"
|
readonly EFI="/sys/firmware/efi/efivars"
|
||||||
readonly TRN="/usr/share/archlabs/installer/lang"
|
readonly TRN="/usr/share/archlabs/installer/lang"
|
||||||
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
||||||
|
|
||||||
readonly VM="$(dmesg | grep -i "hypervisor")"
|
readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||||
|
|
||||||
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
||||||
|
|
||||||
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
||||||
|
|
||||||
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
||||||
|
|
||||||
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
||||||
|
|
||||||
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
||||||
|
|
||||||
if [[ $IGNORE_DEV ]]; then
|
if [[ $IGNORE_DEV ]]; then
|
||||||
@ -41,9 +35,9 @@ fi
|
|||||||
|
|
||||||
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
|
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
|
||||||
|
|
||||||
if [[ $(grep 'GenuineIntel' /proc/cpuinfo) ]]; then
|
if grep -q 'GenuineIntel' /proc/cpuinfo; then
|
||||||
readonly UCODE="intel-ucode.img"
|
readonly UCODE="intel-ucode.img"
|
||||||
elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) ]]; then
|
elif grep -q 'AuthenticAMD' /proc/cpuinfo; then
|
||||||
readonly UCODE="amd-ucode.img"
|
readonly UCODE="amd-ucode.img"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -52,11 +46,10 @@ declare -gA SUBZONES
|
|||||||
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
|
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
|
||||||
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
|
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
|
||||||
done
|
done
|
||||||
|
|
||||||
readonly SUBZONES # make it read only
|
readonly SUBZONES # make it read only
|
||||||
|
|
||||||
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
||||||
for t in st termite xterm; do
|
for t in termite st xterm; do
|
||||||
hash $t >/dev/null 2>&1 && { readonly TERM_CMD="$t"; break; }
|
hash $t >/dev/null 2>&1 && { readonly TERM_CMD="$t"; break; }
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -73,8 +66,7 @@ af Afghani fo Faroese ge Georgian ee Estonian kg Kyrgyz kz Kazakh lt Lithuanian
|
|||||||
mn Mongolian no Norwegian ro Romanian rs Serbian si Slovenian tj Tajik lk Sinhala tr Turkish
|
mn Mongolian no Norwegian ro Romanian rs Serbian si Slovenian tj Tajik lk Sinhala tr Turkish
|
||||||
uz Uzbek ie Irish pk Urdu mv Dhivehi epo Esperanto np Nepali et Amharic sn Wolof ml Bambara
|
uz Uzbek ie Irish pk Urdu mv Dhivehi epo Esperanto np Nepali et Amharic sn Wolof ml Bambara
|
||||||
tz Swahili ke Swahili bw Tswana ph Filipino id Indonesian my Malay tm Turkmen bt Dzongkha
|
tz Swahili ke Swahili bw Tswana ph Filipino id Indonesian my Malay tm Turkmen bt Dzongkha
|
||||||
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer
|
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer az Azerbaijani"
|
||||||
az Azerbaijani"
|
|
||||||
|
|
||||||
declare -Agr BMNTS=(
|
declare -Agr BMNTS=(
|
||||||
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
|
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
|
||||||
@ -149,7 +141,10 @@ init_variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source_file() {
|
source_file() {
|
||||||
. $1 2>/dev/null && return 0 || { echo -e "\nFailed to source library file $1"; die 1; }
|
if ! . $1 2>/dev/null; then
|
||||||
|
echo -e "\nFailed to source library file $1"; die 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
user_setup() {
|
user_setup() {
|
||||||
@ -183,7 +178,7 @@ user_setup() {
|
|||||||
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
|
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
|
||||||
# password was left empty or doesn't match
|
# password was left empty or doesn't match
|
||||||
if [[ $pass == "" ]]; then
|
if [[ $pass == "" ]]; then
|
||||||
msgbox "$_ErrTitle" "\nUser $_Password CANNOT be left empty.\n$_TryAgain"
|
msgbox "$_ErrTitle" "\nUser password CANNOT be left empty.\n$_TryAgain"
|
||||||
elif [[ "$rpass" != "$rpass2" ]]; then
|
elif [[ "$rpass" != "$rpass2" ]]; then
|
||||||
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
|
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
|
||||||
else
|
else
|
||||||
@ -251,7 +246,6 @@ setup_keymap() {
|
|||||||
|
|
||||||
# when a matching console map is not available open a selection dialog
|
# when a matching console map is not available open a selection dialog
|
||||||
if ! [[ $CONSOLE_MAPS =~ "$KEYMAP -" ]]; then
|
if ! [[ $CONSOLE_MAPS =~ "$KEYMAP -" ]]; then
|
||||||
tput civis
|
|
||||||
CONSOLE_MAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
CONSOLE_MAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
|
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
|
||||||
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
|
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
|
||||||
@ -362,7 +356,7 @@ extra_packages() {
|
|||||||
"emacs" "An extensible, customizable, self-documenting real-time display editor" off \
|
"emacs" "An extensible, customizable, self-documenting real-time display editor" off \
|
||||||
"neovim" "A fork of Vim aiming to improve user experience, plugins, and GUIs." off \
|
"neovim" "A fork of Vim aiming to improve user experience, plugins, and GUIs." off \
|
||||||
"mousepad" "A simple text editor" off \
|
"mousepad" "A simple text editor" off \
|
||||||
"urxvt" "A unicode enabled rxvt-clone terminal emulator" off \
|
"rxvt-unicode" "A unicode enabled rxvt-clone terminal emulator" off \
|
||||||
"termite" "A minimal VTE-based terminal emulator" off \
|
"termite" "A minimal VTE-based terminal emulator" off \
|
||||||
"tilix" "A tiling terminal emulator for Linux using GTK+ 3" off \
|
"tilix" "A tiling terminal emulator for Linux using GTK+ 3" off \
|
||||||
"terminator" "Terminal emulator that supports tabs and grids" off \
|
"terminator" "Terminal emulator that supports tabs and grids" off \
|
||||||
@ -372,7 +366,7 @@ extra_packages() {
|
|||||||
"pcmanfm" "A fast and lightweight file manager based in Lxde" off \
|
"pcmanfm" "A fast and lightweight file manager based in Lxde" off \
|
||||||
"gnome-disk-utility" "Disk Management Utility" off \
|
"gnome-disk-utility" "Disk Management Utility" off \
|
||||||
"gnome-system-monitor" "View current processes and monitor system state" off \
|
"gnome-system-monitor" "View current processes and monitor system state" off \
|
||||||
"steam steam-native-runtime" "A popular game distribution platform by Valve" off \
|
"steam" "A popular game distribution platform by Valve" off \
|
||||||
"vlc" "A free and open source cross-platform multimedia player" off \
|
"vlc" "A free and open source cross-platform multimedia player" off \
|
||||||
"mpd" "A flexible, powerful, server-side application for playing music" off \
|
"mpd" "A flexible, powerful, server-side application for playing music" off \
|
||||||
"ncmpcpp" "An mpd client and almost exact clone of ncmpc with some new features" off \
|
"ncmpcpp" "An mpd client and almost exact clone of ncmpc with some new features" off \
|
||||||
@ -427,10 +421,14 @@ extra_packages() {
|
|||||||
[[ $pkgs =~ mpd ]] && pkgs="$pkgs mpc"
|
[[ $pkgs =~ mpd ]] && pkgs="$pkgs mpc"
|
||||||
[[ $pkgs =~ mupdf ]] && pkgs="$pkgs mupdf-tools"
|
[[ $pkgs =~ mupdf ]] && pkgs="$pkgs mupdf-tools"
|
||||||
[[ $pkgs =~ qt5ct ]] && pkgs="$pkgs qt5-styleplugins"
|
[[ $pkgs =~ qt5ct ]] && pkgs="$pkgs qt5-styleplugins"
|
||||||
|
[[ $pkgs =~ steam ]] && pkgs="$pkgs steam-native-runtime"
|
||||||
[[ $pkgs =~ zathura ]] && pkgs="$pkgs zathura-pdf-poppler"
|
[[ $pkgs =~ zathura ]] && pkgs="$pkgs zathura-pdf-poppler"
|
||||||
[[ $pkgs =~ noto-fonts ]] && pkgs="$pkgs noto-fonts-emoji"
|
[[ $pkgs =~ noto-fonts ]] && pkgs="$pkgs noto-fonts-emoji"
|
||||||
[[ $pkgs =~ cairo-dock ]] && pkgs="$pkgs cairo-dock-plug-ins"
|
[[ $pkgs =~ cairo-dock ]] && pkgs="$pkgs cairo-dock-plug-ins"
|
||||||
[[ $pkgs =~ kdenlive ]] && pkgs="$pkgs kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
|
[[ $pkgs =~ kdenlive ]] && pkgs="$pkgs kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
|
||||||
|
if [[ $INSTALL_WMS =~ dwm ]] && ! [[ $pkgs =~ ttf-hack ]]; then
|
||||||
|
pkgs="$pkgs ttf-hack"
|
||||||
|
fi
|
||||||
if [[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]; then
|
if [[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]; then
|
||||||
pkgs="$pkgs qt5ct qt5-styleplugins"
|
pkgs="$pkgs qt5ct qt5-styleplugins"
|
||||||
fi
|
fi
|
||||||
@ -553,7 +551,7 @@ edit_configs() {
|
|||||||
[[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f"
|
[[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $existing_files != "" ]]; then
|
if [[ $existing_files ]]; then
|
||||||
vim -O $existing_files
|
vim -O $existing_files
|
||||||
else
|
else
|
||||||
msgbox "$_ErrTitle" "$_NoFileErr"
|
msgbox "$_ErrTitle" "$_NoFileErr"
|
||||||
|
@ -6,49 +6,6 @@
|
|||||||
# this file is not meant to be run directly
|
# this file is not meant to be run directly
|
||||||
# sourcing this file in a non bash shell is not advised
|
# 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() {
|
shim_secure_boot() {
|
||||||
# still a W.I.P
|
# still a W.I.P
|
||||||
local shim_file="shim64.efi"
|
local shim_file="shim64.efi"
|
||||||
@ -192,13 +149,15 @@ install_bootloader() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# remove old UEFI boot entries
|
# remove old UEFI boot entries
|
||||||
[[ $SYS == 'UEFI' ]] && find $MNT${BMNTS[$SYS-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 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
|
-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
|
prep_for_$BOOTLDR
|
||||||
|
|
||||||
# run the bootloader command
|
# install/setup the bootloader by running the BCMD (boot command)
|
||||||
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
||||||
check_for_errors "${BCMDS[$BOOTLDR]}"
|
check_for_errors "${BCMDS[$BOOTLDR]}"
|
||||||
|
|
||||||
|
@ -7,33 +7,37 @@
|
|||||||
# sourcing this file in a non bash shell is not advised
|
# sourcing this file in a non bash shell is not advised
|
||||||
|
|
||||||
install_main() {
|
install_main() {
|
||||||
# unpack the whole filesystem to install directory $MNT
|
clear && tput cnorm
|
||||||
|
|
||||||
|
# unpack the file system
|
||||||
oneshot install_base
|
oneshot install_base
|
||||||
|
|
||||||
|
# generate /etc/fstab and touch it up if we used a swapfile
|
||||||
genfstab -U $MNT > $MNT/etc/fstab 2>$ERR
|
genfstab -U $MNT > $MNT/etc/fstab 2>$ERR
|
||||||
check_for_errors "genfstab -U $MNT > $MNT/etc/fstab"
|
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
|
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
||||||
|
|
||||||
# update the mirrorlist
|
# update the mirrorlist.. MUST be done before updating or it may be slow
|
||||||
# MUST be done before updating or it may be slow
|
$MIRROR_CMD --verbose --save $MNT/etc/pacman.d/mirrorlist ||
|
||||||
local cmdtail="--verbose --save $MNT/etc/pacman.d/mirrorlist"
|
reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
|
||||||
$MIRROR_CMD $cmdtail || reflector --score 100 -l 50 -f 10 --sort rate $cmdtail
|
|
||||||
|
|
||||||
oneshot update_system # MUST be before bootloader and mkinitcpio
|
# 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
|
run_mkinitcpio
|
||||||
install_bootloader
|
install_bootloader
|
||||||
|
|
||||||
chroot_cmd "hwclock --systohc --utc" || chroot_cmd "hwclock --systohc --utc --directisa"
|
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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_base() {
|
install_base() {
|
||||||
clear
|
|
||||||
tput cnorm
|
|
||||||
echo -e "\nUnpacking base file system --- Total: ~ 2.8G\n\n"
|
echo -e "\nUnpacking base file system --- Total: ~ 2.8G\n\n"
|
||||||
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ EndSection
|
|||||||
EOF
|
EOF
|
||||||
fi
|
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
|
[[ $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
|
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
|
||||||
@ -114,137 +118,126 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_user() {
|
create_user() {
|
||||||
local _home="$MNT/home/$LIVE"
|
|
||||||
local service="$MNT/etc/systemd/system/getty@tty1.service.d"
|
|
||||||
|
|
||||||
# set root password
|
# set root password
|
||||||
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
|
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}
|
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
|
[[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$LIVE/.config/{bspwm,sxhkd}
|
||||||
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
|
[[ $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}
|
||||||
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
|
|
||||||
|
|
||||||
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
|
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 "echo '$NEWUSER:$USER_PASS' | chpasswd"
|
||||||
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER"
|
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER"
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_mkinitcpio() {
|
run_mkinitcpio() {
|
||||||
|
local add=""
|
||||||
|
|
||||||
# setup a keyfile for LUKS.. Only when choosing grub and system is UEFI
|
# 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
|
# new hooks needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
|
||||||
local add
|
|
||||||
(( LVM == 1 )) && add="lvm2"
|
(( LVM == 1 )) && add="lvm2"
|
||||||
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
|
(( 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
|
chroot_cmd "mkinitcpio -p $KERNEL" 2>$ERR
|
||||||
check_for_errors "mkinitcpio -p $KERNEL"
|
check_for_errors "mkinitcpio -p $KERNEL"
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_system() {
|
package_operations() {
|
||||||
tput cnorm
|
local inpkg="$EXTRA_PACKAGES" # add the packages chosen during setup
|
||||||
local inpkg="base-devel git"
|
local rmpkg="archlabs-installer" # always remove the installer
|
||||||
local rmpkg="archlabs-installer"
|
local vbx="virtualbox-guest-modules-arch" # save retyping this multiple times
|
||||||
local vbx="virtualbox-guest-modules-arch"
|
|
||||||
|
|
||||||
|
# the LTS kernel uses different packages
|
||||||
if [[ $KERNEL == 'linux-lts' ]]; then
|
if [[ $KERNEL == 'linux-lts' ]]; then
|
||||||
rmpkg="$rmpkg $vbx linux"
|
rmpkg="$rmpkg $vbx linux"
|
||||||
inpkg="linux-lts"
|
inpkg="$inpkg linux-lts"
|
||||||
if [[ $VM ]]; then
|
# if the system is a VM then install the needed packages otherwise remove the guest utils
|
||||||
inpkg="$inpkg virtualbox-guest-dkms linux-lts-headers"
|
[[ $VM ]] && inpkg="$inpkg virtualbox-guest-dkms linux-lts-headers" || rmpkg="$rmpkg virtualbox-guest-utils"
|
||||||
else
|
|
||||||
rmpkg="$rmpkg virtualbox-guest-utils"
|
|
||||||
fi
|
|
||||||
elif ! [[ $VM ]]; then
|
elif ! [[ $VM ]]; then
|
||||||
|
# if the system is not a VM then remove the guest utils
|
||||||
rmpkg="$rmpkg $vbx virtualbox-guest-utils"
|
rmpkg="$rmpkg $vbx virtualbox-guest-utils"
|
||||||
fi
|
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)"
|
[[ $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
|
if [[ $BOOTLDR != 'grub' ]]; then
|
||||||
rmpkg="$rmpkg grub"
|
rmpkg="$rmpkg grub"
|
||||||
rm -f $MNT/etc/default/grub
|
rm -f $MNT/etc/default/grub
|
||||||
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||||
elif [[ $BOOTLDR != 'syslinux' ]]; then
|
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
|
find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||||
fi
|
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"
|
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
|
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
|
||||||
mkdir -p $MNT/home/$LIVE/.config/nvim
|
mkdir -p $MNT/home/$LIVE/.config/nvim
|
||||||
cp -f $MNT/home/$LIVE/.vimrc $MNT/home/$LIVE/.config/nvim/init.vim
|
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
|
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home/$LIVE/.config/nvim/colors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# install and setup dwm
|
||||||
if [[ $INSTALL_WMS =~ dwm ]]; then
|
if [[ $INSTALL_WMS =~ dwm ]]; then
|
||||||
mkdir -pv $MNT/home/$LIVE/suckless
|
mkdir -pv $MNT/home/$LIVE/suckless
|
||||||
for prog in dwm st dmenu; do
|
for prog in dwm dmenu st; do
|
||||||
local cmd="git clone https://bitbucket.org/natemaia/$prog /home/$LIVE/suckless/$prog"
|
chroot_cmd "git clone https://bitbucket.org/natemaia/$prog /home/$LIVE/suckless/$prog && cd /home/$LIVE/suckless/$prog"
|
||||||
chroot_cmd "$cmd; cd /home/$LIVE/suckless/$prog && make clean install && make clean"
|
[[ -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
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_lightdm() {
|
login_manager() {
|
||||||
local cfg="$MNT/etc/lightdm/lightdm-gtk-greeter.conf"
|
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'
|
chroot_cmd 'systemctl enable lightdm.service && systemctl set-default graphical.target'
|
||||||
|
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF
|
||||||
|
# LightDM GTK+ Configuration
|
||||||
|
|
||||||
sed -i '/#background=/ c background=/usr/share/backgrounds/archlabs/archlabs.jpg' $cfg
|
[greeter]
|
||||||
sed -i '/#theme-name=/ c theme-name=ArchLabs-dARK' $cfg
|
active-monitor=0
|
||||||
sed -i '/#icon-theme-name=/ c icon-theme-name=ArchLabs-Dark' $cfg
|
default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
|
||||||
sed -i '/#position=/ c position=34%,end 66%,end' $cfg
|
background=/usr/share/backgrounds/archlabs/archlabs.jpg
|
||||||
sed -i '/#font-name=/ c font-name=DejaVu Sans Mono 11' $cfg
|
theme-name=ArchLabs-dARK
|
||||||
sed -i '/\[greeter]/ a default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png' $cfg
|
icon-theme-name=Adwaita
|
||||||
sed -i '/\[greeter]/ a active-monitor=0' $cfg
|
font-name=DejaVu Sans Mono 11
|
||||||
|
position=30%,end 50%,end
|
||||||
|
EOF
|
||||||
if [[ $AUTOLOGIN == true ]]; then
|
if [[ $AUTOLOGIN == true ]]; then
|
||||||
chroot_cmd 'groupadd -r nopasswdlogin'
|
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 '/#%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-session=/ c autologin-session=${LOGIN_WM}" $MNT/etc/lightdm/lightdm.conf
|
||||||
sed -i "/#autologin-user=/ c autologin-user=${NEWUSER}" $MNT/etc/lightdm/lightdm.conf
|
sed -i "/#autologin-user=/ c autologin-user=${NEWUSER}" $MNT/etc/lightdm/lightdm.conf
|
||||||
fi
|
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
|
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() {
|
select_mount_opts() {
|
||||||
local part="$1"
|
local part="$1"
|
||||||
local fs="$2"
|
local fs="$2"
|
||||||
|
Reference in New Issue
Block a user