You've already forked al-installer
Cleanup, fix missing/wrong dialogs, allow mounting old /home without overwriting
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# immutable variables {
|
||||
|
||||
readonly DIST="ArchLabs" # Linux distributor
|
||||
readonly VER="1.6.74" # Installer version
|
||||
readonly VER="1.6.75" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
@ -345,7 +345,7 @@ window_manager() {
|
||||
extra_packages() {
|
||||
local pkgs
|
||||
pkgs="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 30 \
|
||||
--title " $_ExtraPackages " --checklist "$_ExtraPackagesBody\n" 0 0 30 \
|
||||
"firefox" "A popular open-source graphical web browser from Mozilla" off \
|
||||
"chromium" "an open-source graphical web browser based on the Blink rendering engine" off \
|
||||
"opera" "Fast and secure, free of charge web browser from Opera Software" off \
|
||||
|
@ -6,14 +6,6 @@
|
||||
# this file is not meant to be run directly
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
shim_secure_boot() {
|
||||
# still a W.I.P
|
||||
local shim_file="shim64.efi"
|
||||
[[ $IS_64BIT != true ]] && shim_file="shim.efi"
|
||||
efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file
|
||||
return 0
|
||||
}
|
||||
|
||||
uefi_boot_fallback() {
|
||||
# some UEFI firmware requires a directory in the ESP and a generic bootx64.efi
|
||||
# see: https://wiki.archlinux.org/index.php/GRUB#UEFI
|
||||
@ -21,9 +13,9 @@ uefi_boot_fallback() {
|
||||
|
||||
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
|
||||
|
||||
local default
|
||||
local default="boot"
|
||||
default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d)"
|
||||
[[ $default ]] && default="$(basename $default)" || default="boot"
|
||||
[[ $default ]] && default="$(basename $default)"
|
||||
|
||||
# directory exists: remove everything inside, otherwise mkdir it
|
||||
[[ -d $esp/EFI/$default ]] && rm -rf $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
|
||||
@ -35,39 +27,30 @@ uefi_boot_fallback() {
|
||||
cp -f $esp/EFI/syslinux/syslinux.efi $esp/EFI/$default/bootx64.efi
|
||||
elif [[ $BOOTLDR == 'grub' ]]; then
|
||||
# grub uses different names for the stub depending on architecture
|
||||
if [[ $IS_64BIT != true ]]; then
|
||||
local grub_file="grubia32.efi"
|
||||
local boot_file="bootia32.efi"
|
||||
else
|
||||
local grub_file="grubx64.efi"
|
||||
local boot_file="bootx64.efi"
|
||||
fi
|
||||
cp -f $esp/EFI/$DIST/$grub_file $esp/EFI/$default/$boot_file
|
||||
local ext="ia32"
|
||||
[[ $IS_64BIT == true ]] && ext="x64"
|
||||
cp -f $esp/EFI/$DIST/grub${ext}.efi $esp/EFI/$default/boot${ext}.efi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
prep_for_grub() {
|
||||
local cfg="$MNT/etc/default/grub"
|
||||
|
||||
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g;
|
||||
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg
|
||||
|
||||
if [[ $LUKS -eq 1 ]]; then
|
||||
sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g;
|
||||
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg
|
||||
fi
|
||||
|
||||
if [[ $SYS == 'BIOS' && $LVM -eq 1 && $SEPERATE_BOOT == false ]]; then
|
||||
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
prep_for_systemd-boot() {
|
||||
# no LVM then systemd-boot uses PARTUUID
|
||||
! [[ $ROOT_PART =~ /dev/mapper ]] && ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||
[[ $ROOT_PART =~ /dev/mapper ]] || ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||
|
||||
# create the boot entry configs
|
||||
mkdir -p $MNT/boot/loader/entries
|
||||
@ -103,11 +86,8 @@ EOF
|
||||
prep_for_syslinux() {
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
local cfgdir="$MNT/boot/EFI/syslinux"
|
||||
if [[ $IS_64BIT == true ]]; then
|
||||
local cfgsrcdir="/usr/lib/syslinux/efi64/"
|
||||
else
|
||||
local cfgsrcdir="/usr/lib/syslinux/efi32/"
|
||||
fi
|
||||
local cfgsrcdir="/usr/lib/syslinux/efi32/"
|
||||
[[ $IS_64BIT == true ]] && cfgsrcdir="/usr/lib/syslinux/efi64/"
|
||||
else
|
||||
local cfgdir="$MNT/boot/syslinux"
|
||||
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
||||
@ -165,3 +145,11 @@ install_bootloader() {
|
||||
[[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]] && uefi_boot_fallback
|
||||
return 0
|
||||
}
|
||||
|
||||
shim_secure_boot() {
|
||||
# still a W.I.P
|
||||
local shim_file="shim.efi"
|
||||
[[ $IS_64BIT == true ]] && shim_file="shim64.efi"
|
||||
efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file
|
||||
return 0
|
||||
}
|
||||
|
@ -123,16 +123,19 @@ create_user() {
|
||||
|
||||
# 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
|
||||
|
||||
[[ $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 rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin $NEWUSER"
|
||||
if [[ -d $MNT/home/$NEWUSER ]]; then
|
||||
rm -rf $MNT/home/$LIVE
|
||||
else
|
||||
# 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
|
||||
[[ $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"
|
||||
fi
|
||||
chroot_cmd "usermod -aG rfkill,wheel,network,storage,power,video,audio,lp,autologin $NEWUSER"
|
||||
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd"
|
||||
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER"
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ format() {
|
||||
decr_count() {
|
||||
# remove a partition from the dialog list and decrement the number partitions left
|
||||
local p="$1"
|
||||
[[ $p ]] || return 1
|
||||
PARTS="$(sed "s~${p} [0-9]*[G-M]~~; s~${p} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
|
||||
(( COUNT > 0 )) && (( COUNT-- ))
|
||||
return 0
|
||||
@ -116,6 +117,7 @@ find_partitions() {
|
||||
|
||||
check_cryptlvm() {
|
||||
local part="$1"
|
||||
local dev=""
|
||||
local devs="$(lsblk -lno NAME,FSTYPE,TYPE)"
|
||||
|
||||
# Identify if $part is "crypt" (LUKS on LVM, or LUKS alone)
|
||||
@ -405,8 +407,8 @@ select_boot_setup() {
|
||||
else
|
||||
FILES[9]="/etc/default/grub"
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
local ttype
|
||||
[[ $IS_64BIT != true ]] && ttype='i386-efi' || ttype='x86_64-efi'
|
||||
local ttype="i386-efi"
|
||||
[[ $IS_64BIT == true ]] && ttype='x86_64-efi'
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=$ttype --bootloader-id=$DIST"
|
||||
else
|
||||
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
|
||||
|
@ -19,44 +19,31 @@ identify_system() {
|
||||
|
||||
if [[ -d /sys/firmware/efi ]]; then
|
||||
SYS="UEFI"
|
||||
# [[ $(mount) =~ $EFI ]] && mount -t efivarfs efivarfs $EFI >/dev/null 2>&1
|
||||
|
||||
local bitness
|
||||
bitness=$(cat /sys/firmware/efi/fw_platform_size)
|
||||
if [[ $bitness != "" && $bitness == 64 ]]; then
|
||||
IS_64BIT=true
|
||||
else
|
||||
IS_64BIT=false
|
||||
fi
|
||||
[[ $(cat /sys/firmware/efi/fw_platform_size) == 64 ]] && IS_64BIT=true
|
||||
else
|
||||
SYS="BIOS"
|
||||
fi
|
||||
|
||||
if [[ $IS_64BIT == true ]]; then
|
||||
readonly BT="$DIST Installer - $SYS (i686) - Version $VER"
|
||||
else
|
||||
readonly BT="$DIST Installer - $SYS (x86_64) - Version $VER"
|
||||
else
|
||||
readonly BT="$DIST Installer - $SYS (i686) - Version $VER"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_requirements() {
|
||||
local err=0
|
||||
if [[ $(whoami) != "root" ]]; then
|
||||
infobox "$_ErrTitle" "$_NotRoot\n$_Exit"
|
||||
err=1
|
||||
infobox "$_ErrTitle" "$_NotRoot\n$_Exit" && die 1
|
||||
elif ! grep -qw 'lm' /proc/cpuinfo; then
|
||||
infobox "$_ErrTitle" "$_Not64Bit\n$_Exit"
|
||||
err=1
|
||||
infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" && die 1
|
||||
elif ! (ping -c 1 archlinux.org || ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) >/dev/null 2>&1; then
|
||||
([[ $(systemctl is-active NetworkManager) == "active" ]] && hash nmtui >/dev/null 2>&1) && { tput civis; nmtui; }
|
||||
if ! (ping -c 1 archlinux.org || ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) >/dev/null 2>&1; then
|
||||
infobox "$_ErrTitle" "$_NoNetwork\n$_Exit"
|
||||
err=1
|
||||
infobox "$_ErrTitle" "$_NoNetwork\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ $err -eq 1 ]] && die 1 || return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
check_for_errors() {
|
||||
@ -83,16 +70,16 @@ check_for_errors() {
|
||||
}
|
||||
|
||||
check_install_ready() {
|
||||
[[ $(lsblk -o MOUNTPOINT) =~ $MNT && $CONFIG_DONE == true ]] && return 0
|
||||
|
||||
if ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then
|
||||
msgbox "$_ErrTitle" "$_ErrNoMount"
|
||||
MENU_HIGHLIGHT=4
|
||||
return 1
|
||||
elif [[ $CONFIG_DONE != true ]]; then
|
||||
else
|
||||
msgbox "$_ErrTitle" "$_ErrNoConfig"
|
||||
MENU_HIGHLIGHT=5
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
unmount_partitions() {
|
||||
@ -166,7 +153,6 @@ debug() {
|
||||
set -x
|
||||
exec 3>| /tmp/debug-log
|
||||
BASH_XTRACEFD=3
|
||||
|
||||
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
||||
if [[ $TERM_CMD == 'st' ]]; then
|
||||
$TERM_CMD -e tail -f /tmp/debug-log &
|
||||
|
Reference in New Issue
Block a user