From 8d3e3aebd6a9953649f83c9b4b9c1f48d77edb15 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 15 Sep 2019 16:59:17 -0700 Subject: [PATCH] Update --- archlabs-installer | 202 +++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 100 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 5c49891..6312f42 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -249,6 +249,7 @@ declare -A PKG_EXT=( # { # 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" _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 ..." @@ -1316,8 +1317,6 @@ select_extra_partitions() install_main() { - clear - tput cnorm install_base genfstab -U $MNT >$MNT/etc/fstab 2>$ERR errshow 1 "genfstab -U $MNT >$MNT/etc/fstab" @@ -1364,25 +1363,22 @@ install_main() install_base() { - if kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; then - printf "\nOne or more background install processes are still running, grabbing their output...\n" && cat /tmp/bg_out - while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do - sleep 1 - done - fi + clear + tput cnorm + while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do + clear + printf "\nOne or more background install processes are still running...\n" + sleep 1 + done trap - EXIT unset RSYNC_PID MIRROR_PID rm -rf $MNT/etc/mkinitcpio-archiso.conf 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 - if [[ $DIST != "ArchLabs" ]]; then - for f in $MNT/etc/{lsb-release,os-release}; do - sed -i "s/ArchLabs/$DIST/g" $MNT/etc/{lsb-release,os-release} - done - fi + [[ $DIST != "ArchLabs" ]] || sed -i "s/ArchLabs/$DIST/g" $MNT/etc/{lsb-release,os-release} if [[ $VM ]]; then 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/ 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 chrun "locale-gen" chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZ /etc/localtime" @@ -1485,10 +1481,10 @@ install_user() chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR 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 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 fi @@ -1662,7 +1658,7 @@ install_background() msg "Background Install" "\nInstall will now begin in the background\n" 1 rsync -a /run/archiso/sfs/airootfs/ $MNT/ & RSYNC_PID=$! - ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" >>/tmp/bg_out 2>&1 ) & + ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" ) & MIRROR_PID=$! # end the background processes before exiting trap "kill $RSYNC_PID $MIRROR_PID 2>/dev/null" EXIT @@ -2205,21 +2201,18 @@ ofn() die() { # cleanup and exit the installer cleanly with exit code $1 - # when ecode is 127 unmount /run/archiso/bootmnt and reboot - local ecode="$1" + local e="$1" # when e is 127 unmount /run/archiso/bootmnt and reboot trap - INT tput cnorm - if [[ -d $MNT ]] && command cd /; then + if [[ -d $MNT ]]; then umount_dir $MNT - if (( ecode == 127 )); then - umount_dir /run/archiso/bootmnt - sleep 0.5 - reboot -f + if (( e == 127 )); then + umount_dir /run/archiso/bootmnt && sleep 0.5 && reboot -f fi fi termcol - exit "$ecode" + exit $e } dlg() @@ -2272,36 +2265,64 @@ msg() live() { - select_keymap || { clear; die 0; } - net_connect || { msg "Not Connected" "\nRunning live requires an active internet connection.\n\nExiting..\n" 2; die 1; } - trap - INT - pacman -Syyu --noconfirm || die 1 - pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1 - for ses; do - case "$ses" in - dwm) - pacman -S git --needed --noconfirm || die 1 - mkdir -pv /root/suckless - for i in dwm dmenu st; do - git clone https://git.suckless.org/$i /root/suckless/$i && - cd /root/suckless/$i && - make PREFIX=/usr install - done - ;; - i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome) - pacman -S "$1" ${WM_EXT[$1]} xterm --needed --noconfirm || die 1 - ;; - *) - echo "error: invalid session for -l, --live, see -h, --help" - die 1 - ;; - esac - done - pacman -Scc --noconfirm - rm -rf /var/cache/pacman/pkg/* - cp -rfT /etc/skel /root || die 1 - sed -i "/exec/ c exec ${WM_SESSIONS[$1]}" /root/.xinitrc - startx + local e=0 + if ! select_keymap; then + clear + elif ! net_connect; then + msg "Not Connected" "\nRunning live requires an active internet connection.\n\nExiting..\n" 2 + e=1 + else + clear + pacman -Syyu --noconfirm || die 1 + pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1 + for ses; do + case "$ses" in + dwm) + pacman -S git --needed --noconfirm || die 1 + mkdir -pv /root/suckless + for i in dwm dmenu st; do + git clone https://git.suckless.org/$i /root/suckless/$i && cd /root/suckless/$i && make PREFIX=/usr install + done + ;; + i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome) + pacman -S "$ses" ${WM_EXT[$ses]} xterm --needed --noconfirm || die 1 + ;; + *) echo "error: invalid session for -l, --live, see -h, --help"; die 1 ;; + esac + done + pacman -Scc --noconfirm + rm -rf /var/cache/pacman/pkg/* + cp -rfT /etc/skel /root || die 1 + sed -i "/exec/ c exec ${WM_SESSIONS[$ses]}" /root/.xinitrc + 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 } @@ -2332,12 +2353,6 @@ debug() DEBUG=true } -sigint() -{ - printf "\n^C caught, cleaning up...\n" - die 1 -} - termcol() { local colors=( @@ -2411,14 +2426,18 @@ umount_dir() { mount | grep -q 'swap' && swapoff -a for dir; do - [[ -d $dir && "$(mount | grep "on $dir ")" ]] || continue - umount "$dir" 2>/dev/null || { sleep 0.5; umount -f "$dir" 2>/dev/null || umount -l "$dir"; } + if [[ -d $dir ]] && mount | grep -q "on $dir "; then + if ! umount "$dir" 2>/dev/null; then + sleep 0.5 + umount -f "$dir" 2>/dev/null || umount -l "$dir" + fi + fi done } 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' } @@ -2509,48 +2528,31 @@ if (( UID != 0 )); 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 die 1 -elif [[ $1 =~ (-h|--help) ]]; then - cat <<-EOF - usage: $0 [-hdl] [session] - - options: - -h, --help print this message and exit - -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 "$@" +else + case "$1" in + -d|--debug) debug ;; + -h|--help) usage "$0" ;; + -l|--live) shift; live "$@" ;; + esac fi # trap ^C to perform cleanup -trap sigint INT +trap 'printf "\n^C\n" && die 1' INT system_identify 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; } -net_connect || { msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2; die 1; } - - -while :; do - main -done +if ! select_keymap; then + clear; die 0 +elif ! net_connect; then + msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2 + die 1 +else + while :; do + main + done +fi # vim:fdm=marker:fmr={,}