From 9382a3a0815c9daa79a106cba169b8128c7de1fe Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 5 Oct 2017 17:36:14 -0700 Subject: [PATCH] huge function changes, cleaning up code, needs testing --- aur_packages.sh | 45 +++++++++++++++++++++++++-------------------- install_packages.sh | 21 +++++++++------------ le.sh | 1 + 3 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 le.sh diff --git a/aur_packages.sh b/aur_packages.sh index 1803e91..f353fc4 100755 --- a/aur_packages.sh +++ b/aur_packages.sh @@ -1,44 +1,49 @@ #!/bin/bash -RED='\033[0;31m' -BLUE='\033[0;34m' -NC='\033[0m' -printf "${BLUE}Changing directory to /home/$USER...\n${NC}" -cd /home/$USER -error() { dialog --title "Error!" --msgbox "We've run into a fatal-ish error. Check the LARBS.log file for more information" 10 60 ;} -#error() { dialog --title "Error!" --msgbox "We've run into a fatal-ish error. Check the LARBS.log file for more information" 10 60 && clear && exit ;} - -printf "${BLUE}Installing packer as an AUR manager...\n${NC}" +blue() { printf "\033[0;34m $* \033[0m\n" && (echo $* >> LARBS.log) ;} +red() { printf "\033[0;31m $* \033[0m\n" && (echo ERROR: $* >> LARBS.log) ;} +#Install an AUR package manually. aurinstall() { curl -O https://aur.archlinux.org/cgit/aur.git/snapshot/$1.tar.gz && tar -xvf $1.tar.gz && cd $1 && makepkg --noconfirm -si && cd .. && rm -rf $1 $1.tar.gz ;} -qm=$(pacman -Qm | awk '{print $1}') - +#aurcheck runs on each of its arguments, if the argument is not already installed, it either uses packer to install it, or installs it manually. aurcheck() { +qm=$(pacman -Qm | awk '{print $1}') for arg in "$@" do if [[ $qm = *"$arg"* ]]; then echo $arg is already installed. -else +else echo $arg not installed - printf "${BLUE}\nNow installing $arg...\n${NC}" - aurinstall $arg && printf "${BLUE}\n$arg now installed.\n${NC}" + blue Now installing $arg... + if [[ -e /usr/bin/packer ]] + then + (packer --noconfirm -S $arg && printf "${BLUE}\n$arg now installed.\n${NC}") || red Error installing $arg. + else + (aurinstall $arg && printf "${BLUE}\n$arg now installed.\n${NC}") || red Error installing $arg. + fi + fi done } -aurcheck packer || (echo "Error installing packer." >> LARBS.log && error) -printf "${BLUE}Installing AUR programs...\n${NC}" -printf "${BLUE}(May take some time.)\n${NC}" +blue Changing directory to /home/$USER... +cd /home/$USER || red Could not cd to /home/$USER. Does user and home directory exist? + +blue Installing AUR programs... + +blue \(This may take some time.\) #Add the needed gpg key for neomutt gpg --recv-keys 5FAF0A6EE7371805 -aurcheck i3-gaps vim-pathogen neofetch i3lock tamzen-font-git neomutt unclutter-xfixes-git urxvt-resize-font-git polybar-git python-pywal xfce-theme-blackbird || (echo "Error installing AUR packages. Check your internet connections and pacman keys." >> LARBS.log) +aurcheck packer i3-gaps vim-pathogen neofetch tamzen-font-git neomutt unclutter-xfixes-git urxvt-resize-font-git polybar-git python-pywal xfce-theme-blackbird +#Also installing i3lock, since i3-gaps was only just now installed. +sudo pacman -S i3lock #packer --noconfirm -S ncpamixer-git speedometer cli-visualizer -choices=$(cat choices) +choices=$(cat .choices) for choice in $choices do case $choice in @@ -57,7 +62,7 @@ do ;; esac done -browsers=$(cat browch) +browsers=$(cat .browch) for choice in $browsers do case $choice in diff --git a/install_packages.sh b/install_packages.sh index 89103d0..4b64eff 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -16,7 +16,7 @@ options=(1 "LaTeX packages" off 7 "transmission torrent client" off ) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) -echo $choices > /home/$USER/choices +echo $choices > /home/$USER/.choices clear brow=(dialog --separate-output --checklist "Select a browser (none or multiple possible):" 22 76 16) @@ -26,7 +26,7 @@ options=(1 "qutebrowser" off # any option can be set to default to "on" 4 "Waterfox" off ) browch=$("${brow[@]}" "${options[@]}" 2>&1 >/dev/tty) -echo $browch > /home/$USER/browch +echo $browch > /home/$USER/.browch clear #If this is the first run, install all core programs. @@ -92,22 +92,19 @@ do esac done +#Packages I may later add: #pacman --noconfirm --needed -S projectm-pulseaudio if [[ -e .firstrun ]] then - printf "${BLUE}Downloading next portion of script...\n${NC}" - curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/user.sh > /home/$USER/user.sh - printf "${BLUE}Running script as new user $USER...\n${NC}" - sudo -u $USER bash /home/$USER/user.sh || (echo "Error in the user install script. This might be because of a problem in your internet connection or pacman keyring or in an AUR package." >> LARBS.log && error) - cat /home$USER/LARBS.log >> LARBS.log && rm /home/$USER/LARBS.log + blue Downloading next portion of the script \(user.sh\)... + curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/user.sh > /home/$USER/user.sh && blue Running user.sh script as $(whoami)... + sudo -u $USER bash /home/$USER/user.sh || red Error when running user.sh... rm /home/$USER/user.sh else - printf "${BLUE}Downloading next portion of script...\n${NC}" - curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/aur_packages.sh > /home/$USER/aur_packages.sh - printf "${BLUE}Running script as new user $USER...\n${NC}" - sudo -u $USER bash /home/$USER/aur_packages.sh || (echo "Error in the user install script. This might be because of a problem in your internet connection or pacman keyring or in an AUR package." >> LARBS.log && error) - cat /home$USER/LARBS.log >> LARBS.log && rm /home/$USER/LARBS.log + blue Downloading next portion of the script \(aur_packages.sh\)... + curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/aur_packages.sh > /home/$USER/aur_packages.sh && blue Running aur_packages as $(whoami)... + sudo -u $USER bash /home/$USER/aur_packages.sh || red Error when running aur_packages... rm /home/$USER/aur_packages.sh fi diff --git a/le.sh b/le.sh new file mode 100644 index 0000000..f3fa487 --- /dev/null +++ b/le.sh @@ -0,0 +1 @@ +(cat asdf && echo asdfa) || dialog --title "Error found." --msgbox "Error installing $1." 5 50