Reorganize and remove the shade throwing

This commit is contained in:
VetheonGames 2024-01-08 18:00:34 -07:00
parent d2f6ad273d
commit e941857450

View File

@ -1,5 +1,21 @@
#!/bin/bash #!/bin/bash
# Default values for non-interactive mode
INSTALL_GO="Y"
INSTALL_WGET="Y"
INSTALL_GIT="Y"
WRITE_PKGLIST="Y"
# Check if the script is running interactively
if [[ $- == *i* ]]; then
# The script is running interactively, so prompt the user for input
echo "We are about to write a new pkg.list"
echo "Do you want us to proceed?"
echo "(reply 'n' if you already have a pkg.list)"
read -p "Proceed? [Y/n] " -n 1 -r -e -i "Y" WRITE_PKGLIST
echo
fi
# Check if the ~/.allpac directory already exists # Check if the ~/.allpac directory already exists
if [ -d "$HOME/.allpac" ]; then if [ -d "$HOME/.allpac" ]; then
echo "The AllPac directory ~/.allpac already exists." echo "The AllPac directory ~/.allpac already exists."
@ -9,12 +25,7 @@ fi
mkdir -p "$HOME/.allpac/cache" "$HOME/.allpac/logs" "$HOME/.allpac/bin" mkdir -p "$HOME/.allpac/cache" "$HOME/.allpac/logs" "$HOME/.allpac/bin"
echo "We are about to write a new pkg.list" if [[ $WRITE_PKGLIST =~ ^[Yy]$ ]] || [[ -z $WRITE_PKGLIST ]]; then
echo "Do you want us to proceed?"
echo "(reply 'n' if you already have a pkg.list)"
read -p "Proceed? [Y/n] " -n 1 -r -e -i "Y" REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
echo "Writing new pkg.list..." echo "Writing new pkg.list..."
sleep 2 sleep 2
touch ~/.allpac/pkg.list touch ~/.allpac/pkg.list
@ -30,30 +41,12 @@ required_version="go1.21.5"
echo "Checking if Go is installed..." echo "Checking if Go is installed..."
if [[ "$go_version" != *"$required_version"* ]]; then if [[ "$go_version" != *"$required_version"* ]]; then
echo "Required Go version is not installed." echo "Required Go version is not installed."
if [[ $- == *i* ]]; then
read -p "Do you want to install Go? (this will also perform a general system update with pacman) [Y/n] " -n 1 -r -e -i "Y" REPLY read -p "Do you want to install Go? [Y/n] " -n 1 -r -e -i "Y" INSTALL_GO
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then fi
echo " " if [[ $INSTALL_GO =~ ^[Yy]$ ]] || [[ -z $INSTALL_GO ]]; then
echo "Running 'sudo pacman -Syu go' instead of 'pacman -Sy'..." echo "Installing Go..."
echo " "
echo "So, because the Arch Developers won't make Pacman alert you of this, I guess AllPac has to..."
echo " "
sleep 2
echo "Running 'pacman -Sy' syncs the package database, but doesn't update all the packages on the system"
echo "This can cause a lot of problems if something gets updated but something that depends on it doesn't."
echo " "
echo "It's called a 'Partial Upgrade' and it can break your system"
echo "If you wanna install a package and you don't use AllPac, always just run 'pacman -Syu {package}'"
echo " "
sleep 2
echo "On the other hand;"
echo "Running 'pacman -S' will install a package, but not update the package database. So you might not get the newest version. Which can be it's own issue."
echo " "
sleep 2
echo "That's all it took to explain the issue properly Scimmia..."
echo "Arch Linux Forums users/devs are toxic."
sleep 4
sudo pacman -Syu go sudo pacman -Syu go
else else
echo "Go not installed. Exiting." echo "Go not installed. Exiting."
@ -63,14 +56,14 @@ fi
sleep 2 sleep 2
# Check if wget is installed
echo "Checking if wget is installed..." echo "Checking if wget is installed..."
if ! command -v wget &>/dev/null; then if ! command -v wget &>/dev/null; then
echo "wget is not installed." echo "wget is not installed."
if [[ $- == *i* ]]; then
read -p "Do you want to install wget? [Y/n] " -n 1 -r -e -i "Y" REPLY read -p "Do you want to install wget? [Y/n] " -n 1 -r -e -i "Y" INSTALL_WGET
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then fi
if [[ $INSTALL_WGET =~ ^[Yy]$ ]] || [[ -z $INSTALL_WGET ]]; then
sudo pacman -Syu wget sudo pacman -Syu wget
else else
echo "wget not installed. Exiting." echo "wget not installed. Exiting."
@ -80,17 +73,14 @@ fi
sleep 2 sleep 2
echo "wget is installed!"
echo "Compatible Go version is installed!"
echo "Checking if Git is installed..." echo "Checking if Git is installed..."
if ! command -v git &>/dev/null; then if ! command -v git &>/dev/null; then
echo "Git is not installed." echo "Git is not installed."
if [[ $- == *i* ]]; then
read -p "Do you want to install Git? [Y/n] " -n 1 -r -e -i "Y" REPLY read -p "Do you want to install Git? [Y/n] " -n 1 -r -e -i "Y" INSTALL_GIT
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then fi
if [[ $INSTALL_GIT =~ ^[Yy]$ ]] || [[ -z $INSTALL_GIT ]]; then
sudo pacman -Syu git sudo pacman -Syu git
else else
echo "Git not installed. Exiting." echo "Git not installed. Exiting."
@ -100,39 +90,25 @@ fi
sleep 2 sleep 2
echo "Git is installed!"
echo "Cloning AllPac Repository from Git..." echo "Cloning AllPac Repository from Git..."
sleep 2
git clone https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git || { echo "Failed to clone repository. Exiting."; exit 1; } git clone https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git || { echo "Failed to clone repository. Exiting."; exit 1; }
echo "Descending into cloned repo..." echo "Descending into cloned repo..."
sleep 2
cd AllPac/cmd/ || { echo "Failed to change directory. Exiting."; exit 1; } cd AllPac/cmd/ || { echo "Failed to change directory. Exiting."; exit 1; }
echo "Ensuring we have up to date dependencies..." echo "Ensuring we have up to date dependencies..."
go mod tidy || { echo "Failed to tidy dependencies. Exiting."; exit 1; } go mod tidy || { echo "Failed to tidy dependencies. Exiting."; exit 1; }
sleep 2
echo "Building binary..." echo "Building binary..."
go build -o ~/.allpac/bin/allpac || { echo "Failed to build binary. Exiting."; exit 1; } go build -o ~/.allpac/bin/allpac || { echo "Failed to build binary. Exiting."; exit 1; }
sleep 2
echo "Binary built!"
updater_url="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh"
echo "Downloading updater script..." echo "Downloading updater script..."
wget -O ~/.allpac/bin/allpac-updater.sh "$updater_url" || { echo "Failed to download updater script. Exiting."; exit 1; } wget -O ~/.allpac/bin/allpac-updater.sh "$updater_url" || { echo "Failed to download updater script. Exiting."; exit 1; }
sleep 2
echo "Setting updater script permissions..." echo "Setting updater script permissions..."
chmod u+rwx ~/.allpac/bin/allpac-updater.sh chmod u+rwx ~/.allpac/bin/allpac-updater.sh
sleep 2
echo "Detecting your shell and updating the configuration..." echo "Detecting your shell and updating the configuration..."
# Determine the shell the user is using
if [[ "$SHELL" == *"bash"* ]]; then if [[ "$SHELL" == *"bash"* ]]; then
shell_rc="$HOME/.bashrc" shell_rc="$HOME/.bashrc"
elif [[ "$SHELL" == *"zsh"* ]]; then elif [[ "$SHELL" == *"zsh"* ]]; then
@ -143,9 +119,7 @@ else
exit 1 exit 1
fi fi
# Check if the alias already exists in the shell configuration file
if ! grep -q "alias allpac-update-system=" "$shell_rc"; then if ! grep -q "alias allpac-update-system=" "$shell_rc"; then
# Alias not found, add it to the shell configuration file
echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" >> "$shell_rc" echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" >> "$shell_rc"
echo "Alias added to $shell_rc" echo "Alias added to $shell_rc"
else else