Add reboot back with attempted fix, add shell choice, always create a new user

This commit is contained in:
natemaia 2018-11-10 20:26:03 -08:00
parent a37423ff21
commit b122c92e2e
4 changed files with 98 additions and 69 deletions

View File

@ -117,6 +117,10 @@ _ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name beg
_KernelTitle="Choose Kernel"
_KernelBody="\nSelect which kernel to use for the install."
# shell
_ShellTitle="Choose Login Shell"
_ShellBody="\nSelect which shell to use as the new user's login shell."
# Partitioning Menu
_PartTitle="Partitioning Tool"
_PartBody="\nWhole device auto partitioning is available for beginners.\n\nUEFI systems require a vfat/fat32 partition between 100-512M in size to be mounted at /boot or /boot/efi, additionally BIOS systems using LUKS require a separate /boot partition, between 100-512M and formatted as ext3 or ext4."

View File

@ -14,11 +14,11 @@
# globals {
# immutable values
readonly VER="1.7.14" # Installer version
readonly VER="1.7.15" # Installer version
readonly DIST="ArchLabs" # Linux distributor
readonly LIVE="liveuser" # Live session user
readonly MNT="/mnt/install" # Install mountpoint
readonly ERR="/tmp/errlog" # Built-in error log
readonly DBG="/tmp/debuglog" # Built-in error log
# mutable values
declare -g WARN=false
@ -45,6 +45,7 @@ declare -g INSTALL_WMS=""
declare -g KERNEL=""
declare -g WM_PACKAGES=""
declare -g PACKAGES=""
declare -g MYSHELL=""
declare -g MKINIT_HOOKS="shutdown"
# }
@ -307,7 +308,7 @@ select_login_method() {
WM_PACKAGES+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
EDIT_FILES[11]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf"
else
EDIT_FILES[11]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.zprofile /home/$NEWUSER/.xprofile"
EDIT_FILES[11]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
fi
}
@ -474,7 +475,6 @@ display_system_settings() {
------------ SYSTEM CONFIGURATION -------------
User: ${NEWUSER:-None}
Locale: ${LOCALE:-None}
Keymap: ${KEYMAP:-None}
Hostname: ${HOSTNAME:-None}
@ -483,6 +483,8 @@ display_system_settings() {
------------ LOGIN CONFIGURATION --------------
User: ${NEWUSER:-None}
Shell: ${MYSHELL:-None}
Session: ${LOGIN_WM:-None}
Autologin: ${AUTOLOGIN:-None}
Management: ${LOGIN_TYPE:-None}
@ -512,6 +514,11 @@ configure_system_settings() {
select_timezone || return 1
user_creation || return 1
if ! MYSHELL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_ShellTitle " --menu "$_ShellBody" 0 0 0 '/bin/zsh' '-' '/bin/bash' '-')"; then
return 1
fi
tput civis
if [[ $HAS_NETWORK == true ]]; then
if ! KERNEL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
@ -530,7 +537,7 @@ configure_system_settings() {
INSTALL_WMS='openbox'
LOGIN_WM='openbox-session'
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose"
EDIT_FILES[11]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.zprofile /home/$NEWUSER/.xprofile"
EDIT_FILES[11]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
fi
export CONFIG_DONE=true
@ -546,7 +553,7 @@ edit_system_configs() {
tput civis
local exitstr
[[ $DEBUG == true ]] && exitstr="View Log & Exit" || exitstr="Exit"
[[ $DEBUG == true ]] && exitstr="View Log & Reboot" || exitstr="Reboot"
SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \
@ -555,8 +562,8 @@ edit_system_configs() {
"9" "${BOOTLDR^}" "10" "Pacman.conf" "11" "${LOGIN_TYPE^}")
if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then
[[ $DEBUG == true ]] && more /tmp/debug-log
die
[[ $DEBUG == true ]] && more $DEBUG
die 127
else
local existing_files=""
for f in $(printf "%s" "${EDIT_FILES[$SELECTED]}"); do

View File

@ -28,11 +28,8 @@ install() {
# update the mirrorlist.. MUST be done before updating or it may be slow
oneshot mirrorlist_sort
# MUST be before bootloader and mkinitcpio
# MUST be before bootloader and running mkinitcpio
oneshot package_operations
# set up user login.. MUST be done after package operation
oneshot login_manager
else
chrun 'pacman -Rns archlabs-installer --noconfirm'
fi
@ -45,9 +42,12 @@ install() {
# hwclock setup, falls back to setting --directisa if the default fails
chrun "hwclock --systohc --utc" || chrun "hwclock --systohc --utc --directisa"
# create the user last to avoid referencing multiple $HOME locations for liveuser/newuser
# create the user
oneshot create_user
# set up user login.. MUST be done after package operation and user creation
oneshot login_manager
# drop off the user at the config editing menu
edit_system_configs
}
@ -57,7 +57,7 @@ install_base() {
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
# remove archiso init files and clean up install files
rm -rf $MNT/etc/{sudoers.d/g_wheel,mkinitcpio-archiso.conf,polkit-1/rules.d/49-nopasswd_global.rules}
rm -rf $MNT/etc/{sudoers.d/g_wheel,mkinitcpio-archiso.conf}
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \;
# cleanup system permissions
@ -140,35 +140,38 @@ create_user() {
# set root password
chrun "chpasswd <<< 'root:$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$ROOT_PASS")'"
# 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}
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
# remove welcome message
sed -i '/printf/d' $MNT/home/$LIVE/.zshrc
[[ $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}
[[ $INSTALL_WMS =~ (openbox|i3-gaps|bspwm) ]] || rm -rf $MNT/home/$LIVE/.config/polybar
chrun "mv -f /home/$LIVE /home/$NEWUSER"
fi
chrun "usermod -aG rfkill,wheel,network,storage,power,video,audio,lp,autologin $NEWUSER"
# Create the user, set password, then remove temporary password file
local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel'
chrun "groupadd -r autologin"
chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR
chrun "chpasswd <<< '$NEWUSER:$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$USER_PASS")'"
chrun "chown -Rf $NEWUSER:users /home/$NEWUSER"
# remove welcome message
[[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$NEWUSER/.config/{bspwm,sxhkd}
[[ $INSTALL_WMS =~ i3-gaps ]] || rm -rf $MNT/home/$NEWUSER/.config/i3
[[ $INSTALL_WMS =~ openbox ]] || rm -rf $MNT/home/$NEWUSER/.config/{openbox,skippy-xd,jgmenu,conky,tint2}
[[ $INSTALL_WMS =~ (openbox|i3-gaps|bspwm) ]] || rm -rf $MNT/home/$NEWUSER/.config/polybar
# for neovim copy the default vimrc and colorscheme to ~/.config/nvim
if [[ $PACKAGES =~ neovim ]]; then
mkdir -p $MNT/home/$NEWUSER/.config/nvim
cp -f $MNT/home/$NEWUSER/.vimrc $MNT/home/$NEWUSER/.config/nvim/init.vim
cp -rf $MNT/home/$NEWUSER/.vim/colors $MNT/home/$NEWUSER/.config/nvim/colors
fi
[[ $INSTALL_WMS =~ dwm ]] && suckless_install
return 0
}
login_manager() {
local service="$MNT/etc/systemd/system/getty@tty1.service.d"
# remove welcome message
sed -i '/printf/d' $MNT/root/.zshrc
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
rm -rf $service
for f in $MNT/home/$LIVE/.{xinitrc,zprofile}; do
sed -i '/^#\|^$/! s/^/# /' $f
done
chrun 'systemctl enable lightdm.service && systemctl set-default graphical.target'
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF
# LightDM GTK+ Configuration
@ -182,22 +185,29 @@ icon-theme-name=Adwaita
font-name=DejaVu Sans Mono 11
position=30%,end 50%,end
EOF
else # xinit login
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$LIVE/.xinitrc
if grep -q '#exec' $MNT/home/$LIVE/.zprofile; then
sed -i 's/#exec/exec/' $MNT/home/$LIVE/.zprofile
elif grep -q 'exec sudo archlabs-installer' $MNT/home/$LIVE/.zprofile; then
sed -i 's|exec sudo archlabs-installer|exec startx -- vt1 >/dev/null 2>&1|' $MNT/home/$LIVE/.zprofile
else
# xinit login
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$NEWUSER/.xinitrc
else
cat > $MNT/home/$LIVE/.zprofile << EOF
if [[ ! \$DISPLAY && \$XDG_VTNR -eq 1 ]]; then
printf "%s\n" "exec $LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc
fi
# automatic startx for login shells
[[ $MYSHELL == '/bin/bash' ]] && local loginrc=".bash_profile" || local loginrc=".zprofile"
EDIT_FILES[11]+="/home/$NEWUSER/$loginrc"
cat >> $MNT/home/$NEWUSER/$loginrc << EOF
# ~/$loginrc
# sourced by $(basename $MYSHELL) when used as a login shell
# automatically run startx when logging in on tty1
if [ -n "\$DISPLAY" ] && [ \$XDG_VTNR -eq 1 ]; then
exec startx -- vt1 >/dev/null 2>&1
fi
EOF
fi
if [[ $AUTOLOGIN == true ]]; then
sed -i "s/${LIVE}/${NEWUSER}/g" $service/autologin.conf
sed -i "s/root/${NEWUSER}/g" $service/autologin.conf
else
rm -rf $service
fi
@ -219,7 +229,7 @@ run_mkinitcpio() {
}
mirrorlist_sort() {
printf "%s\n\n" "Sorting the mirrorlist"
printf "\n\n%s\n\n" "Sorting the mirrorlist"
if hash reflector >/dev/null 2>&1; then
$MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist --verbose ||
reflector --score 100 -l 50 -f 10 \
@ -264,20 +274,17 @@ package_operations() {
chrun "pacman -S iputils --noconfirm; pacman -S base-devel git --needed --noconfirm"
chrun "pacman -S $inpkg --needed --noconfirm"
chrun "pacman -Rs $rmpkg --noconfirm"
# for neovim copy the default vimrc and colorscheme to ~/.config/nvim
if [[ $inpkg =~ neovim ]]; then
mkdir -p $MNT/home/$LIVE/.config/nvim
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
fi
# install and setup dwm
if [[ $INSTALL_WMS =~ dwm ]]; then
mkdir -pv $MNT/home/$LIVE/suckless
for i in dwm dmenu st; do
p="/home/$LIVE/suckless/$i"
chrun "git clone https://bitbucket.org/natemaia/$i $p && { cd $p; rm -f $p/config.h 2>/dev/null; make clean install && make clean; }"
done
fi
return 0
}
suckless_install() {
# install and setup dwm
printf "\n\n%s\n\n" "Installing and setting up dwm."
mkdir -pv $MNT/home/$NEWUSER/suckless
for i in dwm dmenu st; do
p="/home/$NEWUSER/suckless/$i"
chrun "git clone https://bitbucket.org/natemaia/$i $p && { cd $p; rm -f $p/config.h 2>/dev/null; make clean install && make clean; }"
done
printf "\n\n%s\n\n" "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h and recompile with 'sudo make clean install'"
sleep 2
}

View File

@ -31,7 +31,18 @@ ssd() {
die() {
local exitcode=0
(( $# == 0 )) || exitcode=$1
tput cnorm; unmount_install_partitions; exit $exitcode
tput cnorm
if [[ -d $MNT ]] && cd; then
fuser -km $MNT
unmount_install_partitions
if [[ $exitcode -eq 127 ]]; then
fuser -km /run/archiso/bootmnt
umount -l /run/archiso/bootmnt
systemctl -i reboot
fi
fi
exit $exitcode
}
sigint() {
@ -166,9 +177,9 @@ echeck() {
[[ $err != "" ]] && msgbox "$_ErrTitle" "$msg\n\nWith the following error message:\n\n$err"
msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoice"
if [[ -e /tmp/debug-log && $TERM == 'linux' ]]; then
if [[ -e $DBG && $TERM == 'linux' ]]; then
msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoiceConsole"
yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { more /tmp/debug-log; die; }
yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { more $DBG; die; }
else
yesno "$_ErrTitle" "$msg" "Exit" "Ignore & Continue" && die
fi
@ -198,13 +209,13 @@ yesno() {
debug() {
set -x
exec 3>| /tmp/debug-log
exec 3>| $DBG
BASH_XTRACEFD=3
if [[ $DISPLAY && $TERM != 'linux' ]]; then
if hash 'termite' >/dev/null 2>&1; then
termite -e "tail -f /tmp/debug-log" &
termite -e "tail -f $DBG" &
else
xterm -e "tail -f /tmp/debug-log" &
xterm -e "tail -f $DBG" &
fi
fi
export DEBUG=true