huge function changes, cleaning up code, needs testing

This commit is contained in:
Luke 2017-10-05 17:36:14 -07:00
parent 6b10393671
commit 9382a3a081
3 changed files with 35 additions and 32 deletions

View File

@ -1,44 +1,49 @@
#!/bin/bash #!/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 ;} blue() { printf "\033[0;34m $* \033[0m\n" && (echo $* >> LARBS.log) ;}
#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 ;} red() { printf "\033[0;31m $* \033[0m\n" && (echo ERROR: $* >> LARBS.log) ;}
printf "${BLUE}Installing packer as an AUR manager...\n${NC}"
#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 ;} 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() { aurcheck() {
qm=$(pacman -Qm | awk '{print $1}')
for arg in "$@" for arg in "$@"
do do
if [[ $qm = *"$arg"* ]]; then if [[ $qm = *"$arg"* ]]; then
echo $arg is already installed. echo $arg is already installed.
else else
echo $arg not installed echo $arg not installed
printf "${BLUE}\nNow installing $arg...\n${NC}" blue Now installing $arg...
aurinstall $arg && printf "${BLUE}\n$arg now installed.\n${NC}" 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 fi
done done
} }
aurcheck packer || (echo "Error installing packer." >> LARBS.log && error)
printf "${BLUE}Installing AUR programs...\n${NC}" blue Changing directory to /home/$USER...
printf "${BLUE}(May take some time.)\n${NC}" 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 #Add the needed gpg key for neomutt
gpg --recv-keys 5FAF0A6EE7371805 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 #packer --noconfirm -S ncpamixer-git speedometer cli-visualizer
choices=$(cat choices) choices=$(cat .choices)
for choice in $choices for choice in $choices
do do
case $choice in case $choice in
@ -57,7 +62,7 @@ do
;; ;;
esac esac
done done
browsers=$(cat browch) browsers=$(cat .browch)
for choice in $browsers for choice in $browsers
do do
case $choice in case $choice in

View File

@ -16,7 +16,7 @@ options=(1 "LaTeX packages" off
7 "transmission torrent client" off 7 "transmission torrent client" off
) )
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
echo $choices > /home/$USER/choices echo $choices > /home/$USER/.choices
clear clear
brow=(dialog --separate-output --checklist "Select a browser (none or multiple possible):" 22 76 16) 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 4 "Waterfox" off
) )
browch=$("${brow[@]}" "${options[@]}" 2>&1 >/dev/tty) browch=$("${brow[@]}" "${options[@]}" 2>&1 >/dev/tty)
echo $browch > /home/$USER/browch echo $browch > /home/$USER/.browch
clear clear
#If this is the first run, install all core programs. #If this is the first run, install all core programs.
@ -92,22 +92,19 @@ do
esac esac
done done
#Packages I may later add:
#pacman --noconfirm --needed -S projectm-pulseaudio #pacman --noconfirm --needed -S projectm-pulseaudio
if [[ -e .firstrun ]] if [[ -e .firstrun ]]
then then
printf "${BLUE}Downloading next portion of script...\n${NC}" blue Downloading next portion of the script \(user.sh\)...
curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/user.sh > /home/$USER/user.sh curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/user.sh > /home/$USER/user.sh && blue Running user.sh script as $(whoami)...
printf "${BLUE}Running script as new user $USER...\n${NC}" sudo -u $USER bash /home/$USER/user.sh || red Error when running user.sh...
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
rm /home/$USER/user.sh rm /home/$USER/user.sh
else else
printf "${BLUE}Downloading next portion of script...\n${NC}" 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 curl https://raw.githubusercontent.com/LukeSmithxyz/larbs/master/aur_packages.sh > /home/$USER/aur_packages.sh && blue Running aur_packages as $(whoami)...
printf "${BLUE}Running script as new user $USER...\n${NC}" sudo -u $USER bash /home/$USER/aur_packages.sh || red Error when running aur_packages...
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
rm /home/$USER/aur_packages.sh rm /home/$USER/aur_packages.sh
fi fi

1
le.sh Normal file
View File

@ -0,0 +1 @@
(cat asdf && echo asdfa) || dialog --title "Error found." --msgbox "Error installing $1." 5 50