Simplify and cleanup a few things

This commit is contained in:
natemaia 2020-04-10 16:03:28 -07:00
parent 4d3c93c034
commit 516881ae41

View File

@ -7,7 +7,7 @@
# shellcheck disable=SC2086,SC2046
VER=2.1.24
VER=2.1.25
# default values {
@ -114,7 +114,7 @@ declare -A LOGIN_PKGS=(
# they can be added here eg. [package]="extra"
declare -A PKG_EXT=(
[vlc]='qt4' [mpd]='mpc' [mupdf]='mupdf-tools'
[rxvt-unicode]='urxvt-perls' [zathura]='zathura-pdf-poppler' [noto-fonts]='noto-fonts-emoji' [cairo-dock]='cairo-dock-plug-ins' [qt5ct]='qt5-styleplugins'
[zathura]='zathura-pdf-poppler' [noto-fonts]='noto-fonts-emoji' [cairo-dock]='cairo-dock-plug-ins' [qt5ct]='qt5-styleplugins'
[vlc]='qt5ct qt5-styleplugins' [qutebrowser]='qt5ct qt5-styleplugins' [qbittorrent]='qt5ct qt5-styleplugins' [transmission-qt]='qt5ct qt5-styleplugins'
[bluez]='bluez-libs bluez-utils bluez-tools bluez-plugins bluez-hid2hci' [kdenlive]='dvdauthor frei0r-plugins breeze breeze-gtk qt5ct qt5-styleplugins'
) # }
@ -255,7 +255,7 @@ select_show()
------------ USER CONFIGURATION ---------------
Username: ${NEWUSER:-none}
Login Shell: ${MYSHELL:-none}
Login Shell: ${NEWSHELL:-none}
Login Session: ${LOGIN_WM:-none}
Autologin: ${AUTOLOGIN:-none}
Login Type: ${LOGIN_TYPE:-none}
@ -307,7 +307,7 @@ select_config()
until [[ $CONFIG_DONE ]]; do
case $i in
0) dlg MYSHELL menu "Shell" "\nChoose which shell to use." \
0) dlg NEWSHELL menu "Shell" "\nChoose which shell to use." \
zsh 'A very advanced and programmable command interpreter (shell) for UNIX' \
bash 'The GNU Bourne Again shell, standard in many GNU/Linux distributions' \
mksh 'The MirBSD Korn Shell - an enhanced version of the public domain ksh' || return 1
@ -331,7 +331,7 @@ select_config()
(( i++ )) # progress through to the next choice
done
case $MYSHELL in
case $NEWSHELL in
bash) LOGINRC='.bash_profile' ;;
zsh) LOGINRC='.zprofile' ;;
mksh) LOGINRC='.profile' ;;
@ -1128,7 +1128,7 @@ select_mntopts()
opts+="$i - off "
done
yesno "$title" "\nPerform automatic mount with default options?\n" && return 1
yesno "$title" "\nPerform automatic mount with default options?\n" "Automatic" "Custom" && return 1
until [[ $MNT_OPTS ]]; do
dlg MNT_OPTS check "$title" "$_mount" $opts
[[ $MNT_OPTS ]] || return 1 # no options is auto mount
@ -1312,16 +1312,16 @@ install_user()
chrun "chpasswd <<< 'root:$ROOT_PASS'" 2> "$ERR" 2>&1
errshow 1 "chrun 'chpasswd <<< \"root:$ROOT_PASS\"'"
if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default
chrun "usermod -s /bin/$MYSHELL root" 2> "$ERR" 2>&1
errshow 1 "chrun 'usermod -s /bin/$MYSHELL root'"
if [[ $NEWSHELL != 'zsh' ]]; then # root uses zsh by default
chrun "usermod -s /bin/$NEWSHELL root" 2> "$ERR" 2>&1
errshow 1 "chrun 'usermod -s /bin/$NEWSHELL root'"
# copy the default mkshrc to /root if it was selected
[[ $MYSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc"
[[ $NEWSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc"
fi
echo "Creating new user $NEWUSER and setting password"
chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2> "$ERR" 2>&1
errshow 1 "chrun 'useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER'"
chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$NEWSHELL $NEWUSER" 2> "$ERR" 2>&1
errshow 1 "chrun 'useradd -m -u 1000 -g users -G $groups -s /bin/$NEWSHELL $NEWUSER'"
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2> "$ERR" 2>&1
errshow 1 "chrun 'chpasswd <<< \"$NEWUSER:$USER_PASS\"'"
@ -1357,15 +1357,18 @@ install_cleanup()
{
local user="$1"
# remove tint2 and jgmenu configs if bspwm and openbox aren't being installed
[[ $INSTALL_WMS =~ (bspwm|openbox) ]] || rm -rf "$MNT/home/$user/.config/"{jgmenu,tint2}
# remove tint2 configs if bspwm and openbox aren't being installed
[[ $INSTALL_WMS =~ (bspwm|openbox) ]] || rm -rf "$MNT/home/$user/.config/tint2"
# remove jgmenu configs if bspwm, fluxbox, and openbox aren't being installed
[[ $INSTALL_WMS =~ (fluxbox|bspwm|openbox) ]] || rm -rf "$MNT/home/$user/.config/jgmenu"
# remove geany configs if it wasn't installed
[[ $USER_PKGS != *geany* ]] && rm -rf "$MNT/home/$user/.config/geany"
# remove shell stuff for unused shells
[[ $MYSHELL != 'bash' ]] && rm -rf "$MNT/home/$user/.bash"*
[[ $MYSHELL != 'zsh' ]] && rm -rf "$MNT/home/$user/.z"*
[[ $NEWSHELL != 'bash' ]] && rm -rf "$MNT/home/$user/.bash"*
[[ $NEWSHELL != 'zsh' ]] && rm -rf "$MNT/home/$user/.z"*
# cleanup default jwmrc
if [[ $INSTALL_WMS == *jwm* ]]; then
@ -1445,7 +1448,7 @@ install_packages()
pacman -Qq archlabs-installer > /dev/null 2>&1 && rmpkg+="archlabs-installer "
if [[ $MYSHELL == 'zsh' ]]; then
if [[ $NEWSHELL == 'zsh' ]]; then
inpkg+="zsh-completions "
else
rmpkg+="zsh "
@ -1455,8 +1458,8 @@ install_packages()
# update and install crucial packages first to avoid issues
al_repo "$MNT/etc/pacman.conf"
chrun "pacman -Syyu $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -Syyu $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed'"
chrun "pacman -Syyu $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $NEWSHELL --noconfirm --needed" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -Syyu $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $NEWSHELL --noconfirm --needed'"
# remove the packages we don't want on the installed system
[[ $rmpkg ]] && chrun "pacman -Rnsc $rmpkg --noconfirm"
@ -2610,7 +2613,8 @@ dwm_xsession()
Name=Dwm
Comment=Dynamic Window Manager
Exec=dwm
Type=XSession
TryExec=dwm
Type=Application
EOF
}