From aab6018e412f0fc2d5688ec1a7cc2d16b2b9cb9f Mon Sep 17 00:00:00 2001 From: natemaia Date: Mon, 19 Aug 2019 19:19:40 -0700 Subject: [PATCH] Remove some uneeded sections, minor cleanup --- archlabs-installer | 123 +++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 71 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 9527074..f2c2043 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,7 +5,7 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due -VER="2.0.52" # installer version +VER="2.0.53" # installer version DIST="ArchLabs" # linux distributor MNT="/mnt" # install mountpoint ANS="/tmp/ans" # dialog answer file @@ -59,7 +59,7 @@ LOGINRC='' # login shell rc file, eg. .zprofile, .bash_profile, .profile INSTALL_WMS='' # space separated list of chosen wm/de -WM_PKGS='' # full list of packages added during wm/de choice (not user edited) +WM_PKGS='' # 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 @@ -216,6 +216,12 @@ declare -A FS_OPTS=( [f2fs]='discard fastboot flush_merge data_flush inline_xattr inline_data noinline_data inline_dentry no_heap noacl nobarrier norecovery noextent_cache disable_roll_forward disable_ext_identify' ) # } +# packages installed for each login option { +declare -A LOGIN_PKGS=( +[xinit]='xorg-xinit' +[lightdm]='lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice' +) # } + # 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" @@ -358,6 +364,7 @@ select_show() local mnt="none" local cmd="${BCMDS[$BOOTLDR]}" local pkgs="${USER_PKGS// / } ${PACKAGES// / }" + local exmnt="${EXMNT:-none}" [[ $BOOT_PART ]] && mnt="/$BOOTDIR" [[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu $pkgs" pkgs="${pkgs// / }" @@ -367,17 +374,14 @@ select_show() Root: ${ROOT_PART:-none} Boot: ${BOOT_PART:-${BOOT_DEV:-none}} - Swap: ${SWAP_PART:-none} Size: ${SWAP_SIZE:-none} + Extra: ${EXMNTS:-$exmnt} + Hooks: ${HOOKS:-none} LVM: ${LVM:-none} LUKS: ${LUKS:-none} - Extra: ${EXMNTS:-${EXMNT:-none}} - Hooks: ${HOOKS:-none} - - ---------- BOOTLOADER CONFIGURATION ----------- Bootloader: ${BOOTLDR:-none} @@ -395,18 +399,18 @@ select_show() ------------ USER CONFIGURATION -------------- - User: ${NEWUSER:-none} - Shell: ${MYSHELL:-none} - Session: ${LOGIN_WM:-none} - Autologin: ${AUTOLOGIN:-none} - Login Method: ${LOGIN_TYPE:-none} + User: ${NEWUSER:-none} + Shell: ${MYSHELL:-none} + Session: ${LOGIN_WM:-none} + Autologin: ${AUTOLOGIN:-none} + DM or xinit: ${LOGIN_TYPE:-none} ------------ PACKAGES AND MIRRORS ------------- Kernel: ${KERNEL:-none} Sessions: ${INSTALL_WMS:-none} - Packages: $(print4 "${pkgs:-none}") + Packages: ${USER_PKGS// / } ${PACKAGES// / } " } @@ -420,7 +424,6 @@ select_login() 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 @@ -435,7 +438,6 @@ select_login() 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 } @@ -607,7 +609,6 @@ select_sessions() done select_login || return 1 - [[ $WM_PKGS != *"$LOGIN_PKGS"* ]] && WM_PKGS+=" $LOGIN_PKGS" while IFS=' ' read -r pkg; do [[ $PACKAGES != *"$pkg"* ]] && PACKAGES+=" $pkg" @@ -1089,6 +1090,7 @@ part_mountconf() select_menu() { + msg "Info" "\nGathering device info.\n" 0 is_bg_install || return 0 lvm_detect umount_dir $MNT @@ -1555,17 +1557,17 @@ install_user() install_xinit() { - 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 + 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 - printf "exec %s\n" "$LOGIN_WM" >> $MNT/home/$NEWUSER/.xinitrc + printf "exec %s\n" "$LOGIN_WM" >> "$MNT/home/$NEWUSER/.xinitrc" fi [[ ${EDIT_FILES[login]} == *"$LOGINRC"* ]] || EDIT_FILES[login]+=" /home/$NEWUSER/$LOGINRC" if [[ $AUTOLOGIN ]]; then sed -i "s/root/${NEWUSER}/g" $SERVICE/autologin.conf - cat > $MNT/home/$NEWUSER/$LOGINRC < "$MNT/home/$NEWUSER/$LOGINRC" <$ERR errshow 1 "systemctl set-default graphical.target && systemctl enable lightdm.service" cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF @@ -1623,56 +1624,53 @@ install_awesome() install_packages() { local rmpkg="" - local inpkg="$PACKAGES $USER_PKGS" - - [[ -x $MNT/usr/bin/X ]] || inpkg+=" $BASE_PKGS" + local inpkg="$BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $PACKAGES $USER_PKGS $UCODE " if pacman -Qsq 'archlabs-installer' >/dev/null 2>&1; then - rmpkg+=" archlabs-installer" + 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" - [[ $KERNEL == 'linux' ]] || { inpkg+=" $KERNEL"; rmpkg+=" linux"; } - [[ $MYSHELL == "/usr/bin/mksh" ]] && inpkg+=" mksh" + # add extra packages chosen throughout the install if [[ $MYSHELL == '/usr/bin/zsh' ]]; then - inpkg+=" zsh-completions" + inpkg+="zsh-completions " else - rmpkg+=" zsh" + rmpkg+="zsh " + [[ $MYSHELL == '/usr/bin/mksh' ]] && inpkg+="mksh " + fi + if [[ $KERNEL != 'linux' ]]; then + inpkg+="$KERNEL " + rmpkg+="linux " 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" + # gnome, plasma, and cinnamon have their own superkey bind and ksuperkey conflicts + [[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+="archlabs-ksuperkey " - # ensure a terminal gets installed + # window manager only packages + [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm|fluxbox) ]] && inpkg+="$WM_BASE_PKGS " + + # ensure a terminal gets installed if one wasn't chosen or a DE that installs one [[ $inpkg =~ (term|urxvt|tilix|alacritty|sakura|tilda|plasma|cinnamon) || $INSTALL_WMS == *dwm* ]] || inpkg+=" xterm" - # update fully first to avoid issues + # update first to avoid issues chrun "pacman -Syyu --noconfirm" - # remove packages we no longer want + # remove the packages we don't want on the installed system [[ $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 + # reinstalling iputils fixes the network issue for non-root users chrun "pacman -S iputils --noconfirm" - # install all the packages chosen throughout the install + # install the packages chosen throughout the install chrun "pacman -S $inpkg --needed --noconfirm" 2>$ERR errshow 1 "pacman -S $inpkg --needed --noconfirm" - # extras for bootloaders + # bootloader packages if [[ $BOOTLDR == 'grub' ]]; then - if [[ $SYS == 'BIOS' ]]; then - chrun "pacman -S grub os-prober --needed --noconfirm" 2>$ERR - errshow 1 "pacman -S grub os-prober --needed --noconfirm" - else - chrun "pacman -S grub os-prober efibootmgr --needed --noconfirm" 2>$ERR - errshow 1 "pacman -S grub os-prober efibootmgr --needed --noconfirm" - fi + [[ $SYS == 'UEFI' ]] && local efib="efibootmgr" + chrun "pacman -S os-prober grub $efib --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S os-prober grub $efib --needed --noconfirm" elif [[ $BOOTLDR == 'refind-efi' ]]; then chrun "pacman -S refind-efi efibootmgr --needed --noconfirm" 2>$ERR errshow 1 "pacman -S refind-efi efibootmgr --needed --noconfirm" @@ -1681,6 +1679,7 @@ install_packages() errshow 1 "pacman -S efibootmgr --needed --noconfirm" fi + # allow members of the wheel group to run commands as root sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers return 0 @@ -1688,7 +1687,7 @@ install_packages() install_suckless() { - mkdir -pv $MNT/home/$NEWUSER/suckless + mkdir -pv "$MNT/home/$NEWUSER/suckless" for i in dwm dmenu st; do if chrun "git clone https://git.suckless.org/$i /home/$NEWUSER/suckless/$i"; then @@ -1698,7 +1697,7 @@ install_suckless() fi done - if [[ -d $MNT/home/$NEWUSER/suckless/dwm && -x $MNT/usr/bin/dwm ]]; then + if [[ -x $MNT/usr/bin/dwm ]]; then printf "To configure dwm edit %s\n" "/home/$NEWUSER/suckless/dwm/config.h" printf "You can then recompile it with 'sudo make clean install'\n" sleep 2 @@ -1725,7 +1724,7 @@ install_mirrorlist() 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" + reflector --score 80 -l 40 -f 5 --sort rate --save "$mfile" elif hash rankmirrors >/dev/null 2>&1; then 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'])")" @@ -1774,6 +1773,7 @@ setup_grub() [[ $BOOT_DEV ]] || { part_device 1 || return 1; } BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEV" else + # since we're not using the keyfile this is dead code # if [[ $ROOT_PART == */dev/mapper/* && -z $LVM && -z $LUKS_PASS ]]; then # luks_pass "$_luksopen" 1 || return 1 # fi @@ -2442,25 +2442,6 @@ sigint() die 1 } -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) - for (; i <= q; i++) { p1 = p1 " " $i } - for (; i <= q * 2; i++) { p2 = p2 " " $i } - for (; i <= q * 3; i++) { p3 = p3 " " $i } - for (; i <= NF; i++) { p4 = p4 " " $i } - printf "%s\n %s\n %s\n %s", p1, p2, p3, p4 - }' <<< "$str")" - printf "%s\n" "$str" - elif [[ $str ]]; then - printf "%s\n" "$str" - fi -} - termcol() { local colors=(