From ade038053e61d19be5fe37a154e4309ab78766a3 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 6 Sep 2020 16:44:15 -0400 Subject: [PATCH] arch/artix only, zsh default, cleanup --- README.md | 3 ++- larbs.sh | 65 ++++++++++++++++++++++--------------------------------- progs.csv | 20 ----------------- 3 files changed, 28 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 96738c4..e4d49f3 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,8 @@ for people who read the csv or who want to install my dotfiles manually. Depending on your own build, you may want to tactically order the programs in your programs file. LARBS will install from the top to the bottom. -If you include commas in your program descriptions, be sure to include double quotes around the whole description to ensure correct parsing. +If you include commas in your program descriptions, be sure to include double +quotes around the whole description to ensure correct parsing. ### The script itself diff --git a/larbs.sh b/larbs.sh index 93b2dea..3e69316 100644 --- a/larbs.sh +++ b/larbs.sh @@ -21,17 +21,7 @@ esac done ### FUNCTIONS ### -if type xbps-install >/dev/null 2>&1; then - installpkg(){ xbps-install -y "$1" >/dev/null 2>&1 ;} - grepseq="\"^[PGV]*,\"" -elif type apt >/dev/null 2>&1; then - installpkg(){ apt-get install -y "$1" >/dev/null 2>&1 ;} - grepseq="\"^[PGU]*,\"" -else - distro="arch" - installpkg(){ pacman --noconfirm --needed -S "$1" >/dev/null 2>&1 ;} - grepseq="\"^[PGA]*,\"" -fi +installpkg(){ pacman --noconfirm --needed -S "$1" >/dev/null 2>&1 ;} error() { clear; printf "ERROR:\\n%s\\n" "$1"; exit;} @@ -44,7 +34,7 @@ welcomemsg() { \ getuserandpass() { \ # Prompts user for new username an password. name=$(dialog --inputbox "First, please enter a name for the user account." 10 60 3>&1 1>&2 2>&3 3>&1) || exit - while ! echo "$name" | grep "^[a-z_][a-z0-9_-]*$" >/dev/null 2>&1; do + while ! echo "$name" | grep -q "^[a-z_][a-z0-9_-]*$"; do name=$(dialog --no-cancel --inputbox "Username not valid. Give a username beginning with a letter, with only lowercase letters, - or _." 10 60 3>&1 1>&2 2>&3 3>&1) done pass1=$(dialog --no-cancel --passwordbox "Enter a password for that user." 10 60 3>&1 1>&2 2>&3 3>&1) @@ -67,9 +57,9 @@ preinstallmsg() { \ adduserandpass() { \ # Adds user `$name` with password $pass1. dialog --infobox "Adding user \"$name\"..." 4 50 - useradd -m -g wheel -s /bin/bash "$name" >/dev/null 2>&1 || + useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 || usermod -a -G wheel "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name" - repodir="/home/$name/.local/src"; mkdir -p "$repodir"; chown -R "$name":wheel $(dirname "$repodir") + repodir="/home/$name/.local/src"; mkdir -p "$repodir"; chown -R "$name":wheel "$(dirname "$repodir")" echo "$name:$pass1" | chpasswd unset pass1 pass2 ;} @@ -110,7 +100,7 @@ gitmakeinstall() { aurinstall() { \ dialog --title "LARBS Installation" --infobox "Installing \`$1\` ($n of $total) from the AUR. $1 $2" 5 70 - echo "$aurinstalled" | grep "^$1$" >/dev/null 2>&1 && return + echo "$aurinstalled" | grep -q "^$1$" && return sudo -u "$name" $aurhelper -S --noconfirm "$1" >/dev/null 2>&1 } @@ -121,12 +111,12 @@ pipinstall() { \ } installationloop() { \ - ([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) || curl -Ls "$progsfile" | sed '/^#/d' | eval grep "$grepseq" > /tmp/progs.csv + ([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) || curl -Ls "$progsfile" | sed '/^#/d' > /tmp/progs.csv total=$(wc -l < /tmp/progs.csv) aurinstalled=$(pacman -Qqm) while IFS=, read -r tag program comment; do n=$((n+1)) - echo "$comment" | grep "^\".*\"$" >/dev/null 2>&1 && comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")" + echo "$comment" | grep -q "^\".*\"$" && comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")" case "$tag" in "A") aurinstall "$program" "$comment" ;; "G") gitmakeinstall "$program" "$comment" ;; @@ -159,7 +149,7 @@ finalize(){ \ ### This is how everything happens in an intuitive format and order. # Check if user is root on Arch distro. Install dialog. -installpkg dialog || error "Are you sure you're running this as the root user and have an internet connection?" +installpkg dialog || error "Are you sure you're running this as the root user, are on an Arch-based distribution and have an internet connection?" # Welcome user and pick dotfiles. welcomemsg || error "User exited." @@ -175,36 +165,33 @@ preinstallmsg || error "User exited." ### The rest of the script requires no user input. -adduserandpass || error "Error adding username and/or password." - # Refresh Arch keyrings. refreshkeys || error "Error automatically refreshing Arch keyring. Consider doing so manually." -dialog --title "LARBS Installation" --infobox "Installing \`basedevel\` and \`git\` for installing other software required for the installation of other programs." 5 70 -installpkg curl -installpkg base-devel -installpkg git -installpkg ntp +for x in curl base-devel git ntp zsh; do + dialog --title "LARBS Installation" --infobox "Installing \`x\` which is required to install and configure other programs." 5 70 + installpkg "$x" +done dialog --title "LARBS Installation" --infobox "Synchronizing system time to ensure successful and secure installation of software..." 4 70 ntpdate 0.us.pool.ntp.org >/dev/null 2>&1 -[ "$distro" = arch ] && { \ - [ -f /etc/sudoers.pacnew ] && cp /etc/sudoers.pacnew /etc/sudoers # Just in case +adduserandpass || error "Error adding username and/or password." - # Allow user to run sudo without password. Since AUR programs must be installed - # in a fakeroot environment, this is required for all builds with AUR. - newperms "%wheel ALL=(ALL) NOPASSWD: ALL" +[ -f /etc/sudoers.pacnew ] && cp /etc/sudoers.pacnew /etc/sudoers # Just in case - # Make pacman and yay colorful and adds eye candy on the progress bar because why not. - grep "^Color" /etc/pacman.conf >/dev/null || sed -i "s/^#Color$/Color/" /etc/pacman.conf - grep "ILoveCandy" /etc/pacman.conf >/dev/null || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf +# Allow user to run sudo without password. Since AUR programs must be installed +# in a fakeroot environment, this is required for all builds with AUR. +newperms "%wheel ALL=(ALL) NOPASSWD: ALL" - # Use all cores for compilation. - sed -i "s/-j2/-j$(nproc)/;s/^#MAKEFLAGS/MAKEFLAGS/" /etc/makepkg.conf +# Make pacman and yay colorful and adds eye candy on the progress bar because why not. +grep -q "^Color" /etc/pacman.conf || sed -i "s/^#Color$/Color/" /etc/pacman.conf +grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf - manualinstall $aurhelper || error "Failed to install AUR helper." - } +# Use all cores for compilation. +sed -i "s/-j2/-j$(nproc)/;s/^#MAKEFLAGS/MAKEFLAGS/" /etc/makepkg.conf + +manualinstall $aurhelper || error "Failed to install AUR helper." # The command that does all the installing. Reads the progs.csv file and # installs each needed program the way required. Be sure to run this only after @@ -226,7 +213,7 @@ git update-index --assume-unchanged "/home/$name/LICENSE" systembeepoff # Make zsh the default shell for the user. -chsh -s /bin/zsh $name >/dev/null 2>&1 +chsh -s /bin/zsh "$name" >/dev/null 2>&1 sudo -u "$name" mkdir -p "/home/$name/.cache/zsh/" # dbus UUID must be generated for Artix runit. @@ -240,7 +227,7 @@ killall pulseaudio; sudo -u "$name" pulseaudio --start # This line, overwriting the `newperms` command above will allow the user to run # serveral important commands, `shutdown`, `reboot`, updating, etc. without a password. -[ "$distro" = arch ] && newperms "%wheel ALL=(ALL) ALL #LARBS +newperms "%wheel ALL=(ALL) ALL #LARBS %wheel ALL=(ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/packer -Syu,/usr/bin/packer -Syyu,/usr/bin/systemctl restart NetworkManager,/usr/bin/rc-service NetworkManager restart,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/yay,/usr/bin/pacman -Syyuw --noconfirm" # Last message! Install complete! diff --git a/progs.csv b/progs.csv index e91206d..d335f1c 100644 --- a/progs.csv +++ b/progs.csv @@ -2,14 +2,6 @@ ,xorg-server,"is the graphical server." ,xorg-xwininfo,"allows querying information about windows." ,xorg-xinit,"starts the graphical server." -V,xorg-minimal,"is the graphical server." -V,xorg-fonts,"is a font package." -V,xinit,"starts the graphical server." -V,xdg-utils,"are filetype utilities." -V,libX11-devel,"is required for the compilation of some programs." -V,libXft-devel,"is required for the compilation of some programs." -V,gcr-devel,"is required for the compilation of some programs." -V,fontconfig-devel,"is required for the compilation of some programs." ,ttf-linux-libertine,"provides the sans and serif fonts for LARBS." A,lf-git,"is an extensive terminal file manager that everyone likes." ,arandr,"is a UI for screen adjustment." @@ -17,10 +9,8 @@ A,lf-git,"is an extensive terminal file manager that everyone likes." ,calcurse,"is a lightweight terminal-based calendar." ,xcompmgr,"is for transparency and removing screen-tearing." ,xorg-xprop,"is a tool for detecting window properties." -V,xprop,"is a tool for detecting window properties." ,dosfstools,"allows your computer to access dos-like filesystems." ,libnotify,"allows desktop notifications." -V,dbus,"facilitates inter-process communication." ,dunst,"is a suckless notification system." ,exfat-utils,"allows management of FAT drives." ,sxiv,"is a minimalist image viewer." @@ -37,7 +27,6 @@ A,gtk-theme-arc-gruvbox-git,"gives the dark GTK theme used in LARBS." ,newsboat,"is a terminal RSS client." A,brave-bin,"is an elegant browser with built-in adblocking, tor and other features." ,noto-fonts-emoji,"is an emoji font." -V,font-symbola,"provides unicode and emoji symbols." ,ntfs-3g,"allows accessing NTFS partitions." ,pulseaudio-alsa,"is the audio system." ,pulsemixer,"is an audio controler." @@ -45,9 +34,7 @@ V,font-symbola,"provides unicode and emoji symbols." A,sc-im,"is an Excel-like terminal spreadsheet manager." ,maim,"can take quick screenshots at your request." ,abook,"is an offline addressbook usable by neomutt." -,socat,"is a socket utility." ,unclutter,"hides an inactive mouse." -V,unclutter-xfixes,"hides an inactive mouse." ,unrar,"extracts rar's." ,unzip,"unzips zips." ,lynx,"is a terminal browser." @@ -55,7 +42,6 @@ V,unclutter-xfixes,"hides an inactive mouse." ,xclip,"allows for copying and pasting from the command line." ,xdotool,"provides window action utilities on the command line." ,xorg-xdpyinfo,"aids with resolution determination and screen recording." -V,xdpyinfo,"aids with resolution determination and screen recording." ,youtube-dl,"can download any YouTube video (or playlist or channel) when given the link." ,zathura,"is a pdf viewer with vim-like bindings." ,zathura-pdf-mupdf,"allows mupdf pdf compatibility in zathura." @@ -67,13 +53,7 @@ V,xdpyinfo,"aids with resolution determination and screen recording." ,xorg-xbacklight,"enables changing screen brightness levels." A,zsh-fast-syntax-highlighting,"provides syntax highlighting in the shell." A,task-spooler,"queues commands or files for download." -V,ts,"queues commands or files for download." A,simple-mtpfs-git,"enables the mounting of cell phones." -V,simple-mtpfs,"enables the mounting of cell phones." -V,setxkbmap,"allows LARBS's unique keyboard bindings." -V,xmodmap,"allows LARBS's unique keyboard bindings." -V,xsetroot,"sets status bar and other X properies." -V,xset,"allows speeding up the X rate." G,https://github.com/LukeSmithxyz/dwmblocks.git,"serves as the modular status bar." G,https://github.com/lukesmithxyz/dmenu.git,"runs commands and provides a UI for selection." G,https://github.com/lukesmithxyz/st.git,"is my custom build of suckless's terminal emulator."