Setup install script so that it can be ran unattended with curl again

This commit is contained in:
VetheonGames 2024-01-08 17:40:07 -07:00
parent 6fcf36f068
commit c61a8b97c6

View File

@ -12,9 +12,9 @@ mkdir -p "$HOME/.allpac/cache" "$HOME/.allpac/logs" "$HOME/.allpac/bin"
echo "We are about to write a new pkg.list" echo "We are about to write a new pkg.list"
echo "Do you want us to proceed?" echo "Do you want us to proceed?"
echo "(reply 'n' if you already have a pkg.list)" echo "(reply 'n' if you already have a pkg.list)"
read -p "Proceed? [Y/n] " -n 1 -r read -p "Proceed? [Y/n] " -n 1 -r -e -i "Y" REPLY
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then 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
@ -31,9 +31,9 @@ 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."
read -p "Do you want to install Go? (this will also perform a general system update with pacman) [Y/n] " -n 1 -r 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
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
echo " " echo " "
echo "Running 'sudo pacman -Syu go' instead of 'pacman -Sy'..." echo "Running 'sudo pacman -Syu go' instead of 'pacman -Sy'..."
echo " " echo " "
@ -68,9 +68,9 @@ 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."
read -p "Do you want to install wget? [Y/n] " -n 1 -r read -p "Do you want to install wget? [Y/n] " -n 1 -r -e -i "Y" REPLY
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
sudo pacman -Syu wget sudo pacman -Syu wget
else else
echo "wget not installed. Exiting." echo "wget not installed. Exiting."
@ -88,9 +88,9 @@ 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."
read -p "Do you want to install Git? [Y/n] " -n 1 -r read -p "Do you want to install Git? [Y/n] " -n 1 -r -e -i "Y" REPLY
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
sudo pacman -Syu git sudo pacman -Syu git
else else
echo "Git not installed. Exiting." echo "Git not installed. Exiting."
@ -130,13 +130,25 @@ echo "Setting updater script permissions..."
chmod u+rwx ~/.allpac/bin/allpac-updater.sh chmod u+rwx ~/.allpac/bin/allpac-updater.sh
sleep 2 sleep 2
echo "Creating a script in /etc/profile.d/ to add AllPac to the system path and set up alias for all users..." echo "Detecting your shell and updating the configuration..."
# Determine the shell the user is using
if [[ "$SHELL" == *"bash"* ]]; then
shell_rc="$HOME/.bashrc"
elif [[ "$SHELL" == *"zsh"* ]]; then
shell_rc="$HOME/.zshrc"
else
echo "Unsupported shell. Please manually add the following to your shell configuration:"
echo 'export PATH=$PATH:$HOME/.allpac/bin'
echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'"
exit 1
fi
# Add AllPac to the system path and set up alias in the user's shell configuration file
{ {
echo 'export PATH=$PATH:$HOME/.allpac/bin' echo 'export PATH=$PATH:$HOME/.allpac/bin'
echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'"
} | sudo tee -a /etc/profile.d/allpac.sh > /dev/null } >> "$shell_rc"
echo "Making '/etc/profile.d/allpac.sh' executable..."
sudo chmod +x /etc/profile.d/allpac.sh
echo "Cleaning up..." echo "Cleaning up..."
cd ../../ || exit cd ../../ || exit