This commit is contained in:
natemaia 2019-09-15 16:59:17 -07:00
parent ea9d419c6b
commit 8d3e3aebd6

View File

@ -249,6 +249,7 @@ declare -A PKG_EXT=(
# { # {
# Basics (somewhat in order) # Basics (somewhat in order)
_welcome="\nThis will help you get $DIST installed and setup on your system.\n\nIf you are unsure about a section the default option will be listed or\nthe first selected item will be the default.\n\n\nMenu Navigation:\n\n - Select items with the arrow keys or the option number.\n - Use [Space] to toggle check boxes and [Enter] to accept.\n - Switch between fields using [Tab] or the arrow keys.\n - Use [Page Up] and [Page Down] to jump whole pages\n - Press the highlighted key of an option to select it.\n"
_keymap="\nPick which keymap to use for the system from the list below\n\nThis is used once a graphical environment is running (Xorg).\n\nSystem default: us" _keymap="\nPick which keymap to use for the system from the list below\n\nThis is used once a graphical environment is running (Xorg).\n\nSystem default: us"
_vconsole="\nSelect the console keymap, the console is the tty shell you reach before starting a graphical environment (Xorg).\n\nIts keymap is seperate from the one used by the graphical environments, though many do use the same such as 'us' English.\n\nSystem default: us" _vconsole="\nSelect the console keymap, the console is the tty shell you reach before starting a graphical environment (Xorg).\n\nIts keymap is seperate from the one used by the graphical environments, though many do use the same such as 'us' English.\n\nSystem default: us"
_device="\nSelect a device to use from the list below.\n\nDevices (/dev) are the available drives on the system. /sda, /sdb, /sdc ..." _device="\nSelect a device to use from the list below.\n\nDevices (/dev) are the available drives on the system. /sda, /sdb, /sdc ..."
@ -1316,8 +1317,6 @@ select_extra_partitions()
install_main() install_main()
{ {
clear
tput cnorm
install_base install_base
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR genfstab -U $MNT >$MNT/etc/fstab 2>$ERR
errshow 1 "genfstab -U $MNT >$MNT/etc/fstab" errshow 1 "genfstab -U $MNT >$MNT/etc/fstab"
@ -1364,25 +1363,22 @@ install_main()
install_base() install_base()
{ {
if kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; then clear
printf "\nOne or more background install processes are still running, grabbing their output...\n" && cat /tmp/bg_out tput cnorm
while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do
sleep 1 clear
done printf "\nOne or more background install processes are still running...\n"
fi sleep 1
done
trap - EXIT trap - EXIT
unset RSYNC_PID MIRROR_PID unset RSYNC_PID MIRROR_PID
rm -rf $MNT/etc/mkinitcpio-archiso.conf rm -rf $MNT/etc/mkinitcpio-archiso.conf
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -delete find $MNT/usr/lib/initcpio -name 'archiso*' -type f -delete
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf sed -i 's/#\(Storage=\)volatile/\1auto/' $MNT/etc/systemd/journald.conf
find $MNT/boot -name '*-ucode.img' -delete find $MNT/boot -name '*-ucode.img' -delete
if [[ $DIST != "ArchLabs" ]]; then [[ $DIST != "ArchLabs" ]] || sed -i "s/ArchLabs/$DIST/g" $MNT/etc/{lsb-release,os-release}
for f in $MNT/etc/{lsb-release,os-release}; do
sed -i "s/ArchLabs/$DIST/g" $MNT/etc/{lsb-release,os-release}
done
fi
if [[ $VM ]]; then if [[ $VM ]]; then
find $MNT/etc/X11/xorg.conf.d/ -name '*.conf' -delete find $MNT/etc/X11/xorg.conf.d/ -name '*.conf' -delete
@ -1403,7 +1399,7 @@ install_base()
[[ -e /etc/NetworkManager/system-connections ]] && cp -rvf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/ [[ -e /etc/NetworkManager/system-connections ]] && cp -rvf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
echo "LANG=$MYLOCALE" > $MNT/etc/locale.conf echo "LANG=$MYLOCALE" > $MNT/etc/locale.conf
cp -f $MNT/etc/locale.conf $MNT/etc/default/locale cp -fv $MNT/etc/locale.conf $MNT/etc/default/locale
sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${MYLOCALE}/${MYLOCALE}/g" $MNT/etc/locale.gen sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${MYLOCALE}/${MYLOCALE}/g" $MNT/etc/locale.gen
chrun "locale-gen" chrun "locale-gen"
chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZ /etc/localtime" chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZ /etc/localtime"
@ -1485,10 +1481,10 @@ install_user()
chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR
errshow 1 "set root password" errshow 1 "set root password"
if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default, change it if something else was chosen if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default
chrun "usermod -s /bin/$MYSHELL root" 2>$ERR chrun "usermod -s /bin/$MYSHELL root" 2>$ERR
errshow 1 "usermod -s /bin/$MYSHELL root" errshow 1 "usermod -s /bin/$MYSHELL root"
# copy the default mkshrc to /root if mksh was picked # copy the default mkshrc to /root if it was selected
[[ $MYSHELL == 'mksh' ]] && cp -fv $MNT/etc/skel/.mkshrc $MNT/root/.mkshrc [[ $MYSHELL == 'mksh' ]] && cp -fv $MNT/etc/skel/.mkshrc $MNT/root/.mkshrc
fi fi
@ -1662,7 +1658,7 @@ install_background()
msg "Background Install" "\nInstall will now begin in the background\n" 1 msg "Background Install" "\nInstall will now begin in the background\n" 1
rsync -a /run/archiso/sfs/airootfs/ $MNT/ & rsync -a /run/archiso/sfs/airootfs/ $MNT/ &
RSYNC_PID=$! RSYNC_PID=$!
( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" >>/tmp/bg_out 2>&1 ) & ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" ) &
MIRROR_PID=$! MIRROR_PID=$!
# end the background processes before exiting # end the background processes before exiting
trap "kill $RSYNC_PID $MIRROR_PID 2>/dev/null" EXIT trap "kill $RSYNC_PID $MIRROR_PID 2>/dev/null" EXIT
@ -2205,21 +2201,18 @@ ofn()
die() die()
{ {
# cleanup and exit the installer cleanly with exit code $1 # cleanup and exit the installer cleanly with exit code $1
# when ecode is 127 unmount /run/archiso/bootmnt and reboot local e="$1" # when e is 127 unmount /run/archiso/bootmnt and reboot
local ecode="$1"
trap - INT trap - INT
tput cnorm tput cnorm
if [[ -d $MNT ]] && command cd /; then if [[ -d $MNT ]]; then
umount_dir $MNT umount_dir $MNT
if (( ecode == 127 )); then if (( e == 127 )); then
umount_dir /run/archiso/bootmnt umount_dir /run/archiso/bootmnt && sleep 0.5 && reboot -f
sleep 0.5
reboot -f
fi fi
fi fi
termcol termcol
exit "$ecode" exit $e
} }
dlg() dlg()
@ -2272,36 +2265,64 @@ msg()
live() live()
{ {
select_keymap || { clear; die 0; } local e=0
net_connect || { msg "Not Connected" "\nRunning live requires an active internet connection.\n\nExiting..\n" 2; die 1; } if ! select_keymap; then
trap - INT clear
pacman -Syyu --noconfirm || die 1 elif ! net_connect; then
pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1 msg "Not Connected" "\nRunning live requires an active internet connection.\n\nExiting..\n" 2
for ses; do e=1
case "$ses" in else
dwm) clear
pacman -S git --needed --noconfirm || die 1 pacman -Syyu --noconfirm || die 1
mkdir -pv /root/suckless pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1
for i in dwm dmenu st; do for ses; do
git clone https://git.suckless.org/$i /root/suckless/$i && case "$ses" in
cd /root/suckless/$i && dwm)
make PREFIX=/usr install pacman -S git --needed --noconfirm || die 1
done mkdir -pv /root/suckless
;; for i in dwm dmenu st; do
i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome) git clone https://git.suckless.org/$i /root/suckless/$i && cd /root/suckless/$i && make PREFIX=/usr install
pacman -S "$1" ${WM_EXT[$1]} xterm --needed --noconfirm || die 1 done
;; ;;
*) i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome)
echo "error: invalid session for -l, --live, see -h, --help" pacman -S "$ses" ${WM_EXT[$ses]} xterm --needed --noconfirm || die 1
die 1 ;;
;; *) echo "error: invalid session for -l, --live, see -h, --help"; die 1 ;;
esac esac
done done
pacman -Scc --noconfirm pacman -Scc --noconfirm
rm -rf /var/cache/pacman/pkg/* rm -rf /var/cache/pacman/pkg/*
cp -rfT /etc/skel /root || die 1 cp -rfT /etc/skel /root || die 1
sed -i "/exec/ c exec ${WM_SESSIONS[$1]}" /root/.xinitrc sed -i "/exec/ c exec ${WM_SESSIONS[$ses]}" /root/.xinitrc
startx printf "\n%s has been set as the login session in /root/.xinitrc, to start the session simply run\n\n\tstartx\n\n" "${WM_SESSIONS[$ses]}"
fi
die $e
}
usage()
{
cat <<-EOF
usage: $1 [-hdl] [session]
options:
-h, --help print this message and exit
-l, --live install and setup a live session
-d, --debug enable debugging and log output to $DBG
sessions:
i3-gaps - A fork of i3wm with more features including gaps
openbox - A lightweight, powerful, and highly configurable stacking wm
dwm - A dynamic WM for X that manages windows in tiled, floating, or monocle layouts
awesome - A customized Awesome WM session created by @elanapan
bspwm - A tiling wm that represents windows as the leaves of a binary tree
fluxbox - A lightweight and highly-configurable window manager
gnome - A desktop environment that aims to be simple and easy to use
cinnamon - A desktop environment combining traditional desktop with modern effects
plasma - A kde software project currently comprising a full desktop environment
xfce4 - A lightweight and modular desktop environment based on gtk+2/3
EOF
die 0 die 0
} }
@ -2332,12 +2353,6 @@ debug()
DEBUG=true DEBUG=true
} }
sigint()
{
printf "\n^C caught, cleaning up...\n"
die 1
}
termcol() termcol()
{ {
local colors=( local colors=(
@ -2411,14 +2426,18 @@ umount_dir()
{ {
mount | grep -q 'swap' && swapoff -a mount | grep -q 'swap' && swapoff -a
for dir; do for dir; do
[[ -d $dir && "$(mount | grep "on $dir ")" ]] || continue if [[ -d $dir ]] && mount | grep -q "on $dir "; then
umount "$dir" 2>/dev/null || { sleep 0.5; umount -f "$dir" 2>/dev/null || umount -l "$dir"; } if ! umount "$dir" 2>/dev/null; then
sleep 0.5
umount -f "$dir" 2>/dev/null || umount -l "$dir"
fi
fi
done done
} }
chk_connect() chk_connect()
{ {
msg "Network Connect" "\nVerifying network connection\n" 1 msg "Network Connect" "\nVerifying network connection\n" 0
curl -sIN --connect-timeout 5 'https://www.archlinux.org/' | sed '1q' | grep -q '200' curl -sIN --connect-timeout 5 'https://www.archlinux.org/' | sed '1q' | grep -q '200'
} }
@ -2509,48 +2528,31 @@ if (( UID != 0 )); then
elif ! grep -qwm 1 'lm' /proc/cpuinfo; then elif ! grep -qwm 1 'lm' /proc/cpuinfo; then
msg "Not x86_64 Architecture" "\nThis installer only supports x86_64 architectures.\n\nExiting..\n" 2 msg "Not x86_64 Architecture" "\nThis installer only supports x86_64 architectures.\n\nExiting..\n" 2
die 1 die 1
elif [[ $1 =~ (-h|--help) ]]; then else
cat <<-EOF case "$1" in
usage: $0 [-hdl] [session] -d|--debug) debug ;;
-h|--help) usage "$0" ;;
options: -l|--live) shift; live "$@" ;;
-h, --help print this message and exit esac
-d, --debug enable debugging and log to $DBG
-l, --live install and setup a live session
sessions:
i3-gaps - A fork of i3wm with more features including gaps
openbox - A lightweight, powerful, and highly configurable stacking wm
dwm - A dynamic WM for X that manages windows in tiled, floating, or monocle layouts
awesome - A customized Awesome WM session created by @elanapan
bspwm - A tiling wm that represents windows as the leaves of a binary tree
fluxbox - A lightweight and highly-configurable window manager
gnome - A desktop environment that aims to be simple and easy to use
cinnamon - A desktop environment combining traditional desktop with modern effects
plasma - A kde software project currently comprising a full desktop environment
xfce4 - A lightweight and modular desktop environment based on gtk+2/3
EOF
elif [[ $1 =~ (-d|--debug) ]]; then
debug
elif [[ $1 =~ (-l|--live) ]]; then
shift
live "$@"
fi fi
# trap ^C to perform cleanup # trap ^C to perform cleanup
trap sigint INT trap 'printf "\n^C\n" && die 1' INT
system_identify system_identify
system_devices system_devices
msg "Welcome to the $DIST Installer" "\nThis will help you get $DIST installed and setup on your system.\n\nIf you are unsure about a section the default option will be listed or\nthe first selected item will be the default.\n\n\nMenu Navigation:\n\n - Select items with the arrow keys or the option number.\n - Use [Space] to toggle options and [Enter] to confirm.\n - Switch between buttons using [Tab] or the arrow keys.\n - Use [Page Up] and [Page Down] to jump whole pages\n - Press the highlighted key of an option to select it.\n" msg "Welcome to the $DIST Installer" "$_welcome"
select_keymap || { clear; die 0; } if ! select_keymap; then
net_connect || { msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2; die 1; } clear; die 0
elif ! net_connect; then
msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2
while :; do die 1
main else
done while :; do
main
done
fi
# vim:fdm=marker:fmr={,} # vim:fdm=marker:fmr={,}