From a8f1b9a1f35ac1f6bfe7c6c87525ffd032e4724f Mon Sep 17 00:00:00 2001 From: Matt C Date: Tue, 11 May 2021 18:06:28 -0400 Subject: [PATCH] use fun output format --- continue.sh | 108 +++++++++++++++++++++++++++--------------------- crystinstall.sh | 84 +++++++++++++++++++++---------------- 2 files changed, 110 insertions(+), 82 deletions(-) diff --git a/continue.sh b/continue.sh index 70ad106..5e35d3d 100644 --- a/continue.sh +++ b/continue.sh @@ -1,72 +1,86 @@ #!/bin/bash +inf() { + echo -e "\e[1m♠ $@\e[0m" +} + +err() { + echo -e "\e[1m\e[31m✗ $@\e[0m" +} + +response="" +prompt() { + printf "\e[1m\e[33m$@ : \e[0m" + read response +} + TZ="/usr/share/zoneinfo/FUCK/OFF" while [[ ! -f $TZ ]]; do - printf "Pick a time zone (Format: America/New_York , Europe/London, etc): " - read PT + prompt "Pick a time zone (Format: America/New_York , Europe/London, etc)" + PT="$response" TZ="/usr/share/zoneinfo/${PT}" done ln -sf $TZ /etc/localtime -echo "Set TZ to ${TZ}" -echo "Syncing hardware offset" +inf "Set TZ to ${TZ}" +inf "Syncing hardware offset" hwclock --systohc echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen echo "LANG=en_US.UTF-8" > /etc/locale.conf -printf "Do you need more locales than just en_US? (y/N): " -read MORE +prompt "Do you need more locales than just en_US? (y/N)" +MORE="$response" if [[ "$MORE" == "y" || "$MORE" == "Y" ]]; then - printf "Preferred editor: " - read PGRM + prompt "Preferred editor" + PGRM="$response" if [[ -x "$(command -v ${PGRM})" ]]; then - echo "Attempting to install ${PGRM}" + inf "Attempting to install ${PGRM}" pacman -Sy ${PGRM} --noconfirm fi - echo "When we open the file, please remove the leading # before any locales you need." - echo "Then, save and exit.\nPress enter." + inf "When we open the file, please remove the leading # before any locales you need." + inf "Then, save and exit.\nPress enter." read ${PGRM} /etc/locale.gen fi -echo "Generating selected locales." +inf "Generating selected locales." locale-gen echo echo -echo "en_US was set as system primary. After install, you can edit /etc/locale.conf to change the primary if desired." -echo "Press enter" -read +inf "en_US was set as system primary. After install, you can edit /etc/locale.conf to change the primary if desired." +inf "Press enter" +prompt "" if [[ -f /keymap ]]; then - echo "You set a custom keymap. We're making that change to the new system, too." + inf "You set a custom keymap. We're making that change to the new system, too." KMP=$(cat /keymap) rm /keymap echo "KEYMAP=${KMP}" > /etc/vconsole.conf fi -printf "System hostname: " -read HOSTNAME +prompt "System hostname" +HOSTNAME="$response" echo ${HOSTNAME} > /etc/hostname echo "127.0.0.1 localhost" > /etc/hosts -printf "Would you like IPV6? (y/N)" -read IPS +prompt "Would you like IPV6? (y/N)" +IPS="$response" if [[ "$IPS" == "y" || "$IPS" == "Y" ]]; then echo "::1 localhost" >> /etc/hosts fi echo "127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" >> /etc/hosts -echo "Password for root" +inf "Password for root" passwd -printf "Your username: " -read UN +prompt "Your username" +UN="$response" useradd -m ${UN} usermod -aG wheel ${UN} -echo "Set password for ${UN}" +inf "Set password for ${UN}" passwd ${UN} echo >> /etc/sudoers echo "# Enabled by Crystalinstall" >> /etc/sudoers @@ -88,16 +102,16 @@ systemctl enable NetworkManager pacman-key --init pacman-key --populate archlinux -printf "Would you like to install a DE profile? (y/N): " -read DEP +prompt "Would you like to install a DE profile? (y/N)" +DEP="$response" if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then - echo "- KDE" - echo "- GNOME" - echo "- i3" - echo "(We'll add more as people ask)" - printf ": " - read DE + inf "- KDE" + inf "- GNOME" + inf "- i3" + inf "(We'll add more as people ask)" + prompt "" + DE="$response" if [[ "$DE" == "KDE" ]]; then pacman -Sy --noconfirm plasma kde-applications sddm @@ -106,19 +120,19 @@ if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then pacman -Sy --noconfirm gnome gnome-extra DM="gdm" elif [[ "$DE" == "i3" ]]; then - echo "Choose either i3 or i3-gaps in below prompt. Rest of group is your preference (or not" - echo "Press enter" - read + inf "Choose either i3 or i3-gaps in below prompt. Rest of group is your preference (or not" + inf "Press enter" + prompt "" pacman -Sy i3 xorg-xinit xorg-server - printf "Would you like a display manager? If so, provide the package name: " - read ND + prompt "Would you like a display manager? If so, provide the package name" + ND="$response" if [[ "$ND" != "" ]]; then - echo "Ok, we'll install $ND" + inf "Ok, we'll install $ND" DM="$ND" pacman -Sy --noconfirm $DM else - echo "Ok, not installing a display manager." - echo "We're setting up a default .xinitrc for you, though" + inf "Ok, not installing a display manager." + inf "We're setting up a default .xinitrc for you, though" echo "exec i3" > /home/${UN}/.xinitrc chown $UN:$UN /home/${UN}/.xinitrc chmod +x /home/${UN}/.xinitrc @@ -127,20 +141,20 @@ if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then fi if [[ "$DM" != "" ]]; then - printf "Would you like to enable ${DM} for ${DE}? (Y/n)" - read useDM + prompt "Would you like to enable ${DM} for ${DE}? (Y/n)" + useDM="$response" if [[ "$useDM" != "n" ]]; then systemctl enable ${DM} fi fi fi -printf "Would you like to add more packages? (Y/n): " -read MP +prompt "Would you like to add more packages? (Y/n)" +MP="$response" if [[ "$MP" != "n" ]]; then - printf "Write package names: " - read PKGNS + prompt "Write package names" + PKGNS="$response" pacman -Sy --noconfirm ${PKGNS} fi -echo "Installation complete" \ No newline at end of file +inf "Installation complete" \ No newline at end of file diff --git a/crystinstall.sh b/crystinstall.sh index 9e23445..e274d09 100755 --- a/crystinstall.sh +++ b/crystinstall.sh @@ -1,56 +1,70 @@ #!/bin/bash +inf() { + echo -e "\e[1m♠ $@\e[0m" +} + +err() { + echo -e "\e[1m\e[31m✗ $@\e[0m" +} + +response="" +prompt() { + printf "\e[1m\e[33m$@ : \e[0m" + read response +} + if [[ "$EUID" != "0" ]]; then - echo "Run as root" + err "Run as root" exit 1 fi -printf "Do you need a keyboard layout other than standard US? (y/N): " -read KBD +prompt "Do you need a keyboard layout other than standard US? (y/N)" +KBD="$response" if [[ "$KBD" == "y" || "$KBD" == "Y" ]]; then - echo "We're going to show the list of keymaps in less. Do you know how to exit less? (Y/n): " - read UL + prompt "We're going to show the list of keymaps in less. Do you know how to exit less? (Y/n)" + UL="$response" if [[ "$UL" == "n" ]]; then - echo "Once we enter less, use arrows to scroll, and q to quit once you've found the right file." - echo "Press enter to go" + inf "Once we enter less, use arrows to scroll, and q to quit once you've found the right file." + inf "Press enter to go" read fi ls /usr/share/kbd/keymaps/**/*.map.gz | less - printf "Correct keymap (omit /usr/share/kbd/keymaps and the file extension): " - read KMP + prompt "Correct keymap (omit /usr/share/kbd/keymaps and the file extension)" + KMP="$response" loadkeys ${KMP} fi fdisk -l | grep Disk | grep sectors --color=never -printf "Would you like to partition manually? (y/N): " -read PMODE +prompt "Would you like to partition manually? (y/N)" +PMODE="$response" MANUAL="no" DISK="" if [[ "$PMODE" == "y" ]]; then MANUAL="yes" else - printf "Install target (will be WIPED COMPLETELY): " - read DISK + prompt "Install target (will be WIPED COMPLETELY)" + DISK="$response" fi if [[ $DISK == *"nvme"* ]]; then - echo "Seems like this is an NVME disk. Noting" + inf "Seems like this is an NVME disk. Noting" NVME="yes" else NVME="no" fi if ls /sys/firmware/efi/efivars > /dev/null; then - echo "Seems like this machine was booted with EFI. Noting" + inf "Seems like this machine was booted with EFI. Noting" EFI="yes" else EFI="no" fi -echo "Setting system clock via network" +inf "Setting system clock via network" timedatectl set-ntp true if [[ "$MANUAL" == "no" ]]; then @@ -70,7 +84,7 @@ if [[ "$MANUAL" == "no" ]]; then echo echo "w" ) | fdisk $DISK - echo "Partitioned ${DISK} as an EFI volume" + inf "Partitioned ${DISK} as an EFI volume" else ( echo "o" @@ -80,47 +94,47 @@ if [[ "$MANUAL" == "no" ]]; then echo echo "w" ) | fdisk $DISK - echo "Partitioned ${DISK} as an MBR volume" + inf "Partitioned ${DISK} as an MBR volume" fi if [[ "$NVME" == "yes" ]]; then if [[ "$EFI" == "yes" ]]; then - echo "Initializing ${DISK} as NVME EFI" + inf "Initializing ${DISK} as NVME EFI" mkfs.vfat ${DISK}p1 mkfs.ext4 ${DISK}p2 mount ${DISK}p2 /mnt mkdir -p /mnt/efi mount ${DISK}p1 /mnt/efi else - echo "Initializing ${DISK} as NVME MBR" + inf "Initializing ${DISK} as NVME MBR" mkfs.ext4 ${DISK}p1 mount ${DISK}p1 /mnt fi else if [[ "$EFI" == "yes" ]]; then - echo "Initializing ${DISK} as EFI" + inf "Initializing ${DISK} as EFI" mkfs.vfat ${DISK}1 mkfs.ext4 ${DISK}2 mount ${DISK}2 /mnt mkdir -p /mnt/efi mount ${DISK}1 /mnt/efi else - echo "Initializing ${DISK} as MBR" + inf "Initializing ${DISK} as MBR" mkfs.ext4 ${DISK}1 mount ${DISK}1 /mnt fi fi else - echo "You have chosen manual partitioning." - echo "We're going to drop to a shell for you to partition, but first, PLEASE READ these notes." - echo "Before you exit the shell, make sure to format and mount a partition for / at /mnt" + inf "You have chosen manual partitioning." + inf "We're going to drop to a shell for you to partition, but first, PLEASE READ these notes." + inf "Before you exit the shell, make sure to format and mount a partition for / at /mnt" if [[ "$EFI" == "yes" ]]; then mkdir -p /mnt/efi - echo "Additionally, since this machine was booted with UEFI, please make sure to make a 200MB or greater partition" - echo "of type VFAT and mount it at /mnt/efi" + inf "Additionally, since this machine was booted with UEFI, please make sure to make a 200MB or greater partition" + inf "of type VFAT and mount it at /mnt/efi" else - echo "Please give me the full path of the device you're planning to partition (needed for bootloader installation later)" - echo "Example: /dev/sda" + inf "Please give me the full path of the device you're planning to partition (needed for bootloader installation later)" + inf "Example: /dev/sda" printf ": " read DISK fi @@ -128,21 +142,21 @@ else CONFDONE="NOPE" while [[ "$CONFDONE" == "NOPE" ]]; do - echo "Press enter to go to a shell." + inf "Press enter to go to a shell." read bash - printf "All set (and partitions mounted?) (y/N): " - read STAT + prompt "All set (and partitions mounted?) (y/N)" + STAT="$response" if [[ "$STAT" == "y" ]]; then CONFDONE="YEP" fi done fi -echo "Setting up base CrystalUX System" +inf "Setting up base CrystalUX System" pacstrap /mnt base linux linux-firmware networkmanager grub crystal-grub-theme man-db man-pages texinfo nano sudo curl archlinux-keyring neofetch if [[ "$EFI" == "yes" ]]; then - echo "Installing EFI support package" + inf "Installing EFI support package" pacstrap /mnt efibootmgr fi @@ -168,6 +182,6 @@ fi arch-chroot /mnt /continue.sh rm /mnt/continue.sh -echo "Installation should now be complete. Please press enter to reboot :)" +inf "Installation should now be complete. Please press enter to reboot :)" read reboot \ No newline at end of file