2023-03-19 18:22:50 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Detect the Linux distro
|
|
|
|
distro=$(lsb_release -si)
|
|
|
|
|
|
|
|
# Check if Ruby 3.0.5 and Bundler 2.4.6 are installed
|
|
|
|
if [ "$distro" == "Ubuntu" ]; then
|
2023-07-29 13:39:35 -06:00
|
|
|
if ! dpkg -s ruby-full | grep -q "Version: 3.2.2"; then
|
2023-03-19 18:22:50 -06:00
|
|
|
# Install rbenv and use it to install Ruby 3.0.5 and Bundler 2.4.6
|
|
|
|
if [[ $(id -u) -ne 0 ]]; then
|
2023-10-26 18:56:08 -06:00
|
|
|
echo "Please enter your password to install rbenv, Ruby 3.2.2, Bundler 2.4.17, and the Ruby development kit"
|
2023-03-19 18:22:50 -06:00
|
|
|
exec sudo "$0" "$@"
|
|
|
|
fi
|
|
|
|
apt update
|
|
|
|
apt install -y rbenv ruby-dev
|
|
|
|
rbenv init
|
2023-07-29 13:39:35 -06:00
|
|
|
rbenv install 3.2.2
|
|
|
|
rbenv global 3.2.2
|
|
|
|
gem install bundler -v 2.4.17
|
2023-03-19 18:22:50 -06:00
|
|
|
gem install rake rdoc
|
|
|
|
fi
|
|
|
|
elif [ "$distro" == "CentOS" ]; then
|
2023-07-29 13:39:35 -06:00
|
|
|
if ! rpm -q ruby | grep -q "3.2.2"; then
|
|
|
|
# Install rbenv and use it to install Ruby 3.2.2 and Bundler 2.4.17
|
2023-03-19 18:22:50 -06:00
|
|
|
if [[ $(id -u) -ne 0 ]]; then
|
2023-07-29 13:39:35 -06:00
|
|
|
echo "Please enter your password to install rbenv, Ruby 3.2.2, Bundler 2.4.17, and the Ruby development kit"
|
2023-03-19 18:22:50 -06:00
|
|
|
exec sudo "$0" "$@"
|
|
|
|
fi
|
|
|
|
yum install -y epel-release
|
|
|
|
yum install -y rbenv ruby-devel
|
|
|
|
rbenv init
|
2023-07-29 13:39:35 -06:00
|
|
|
rbenv install 3.2.2
|
|
|
|
rbenv global 3.2.2
|
|
|
|
gem install bundler -v 2.4.17
|
2023-03-19 18:22:50 -06:00
|
|
|
gem install rake rdoc
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-07-29 13:39:35 -06:00
|
|
|
# Create directories if they don't exist
|
2023-03-19 18:22:50 -06:00
|
|
|
if [[ $(id -u) -ne 0 ]]; then
|
2023-07-29 13:39:35 -06:00
|
|
|
echo "Please enter your password to create necessary directories"
|
2023-03-19 18:22:50 -06:00
|
|
|
exec sudo "$0" "$@"
|
|
|
|
fi
|
2023-07-29 13:39:35 -06:00
|
|
|
sudo mkdir -p /usr/bin/PixelRidge-Softworks/Ruby/
|
|
|
|
|
|
|
|
# Give execute permissions to the user
|
2024-06-10 21:56:12 -06:00
|
|
|
sudo chown -R "$(whoami)":"$(whoami)" /usr/bin/PixelRidge-Softworks/Ruby/
|
2023-07-29 13:39:35 -06:00
|
|
|
sudo chmod -R +x /usr/bin/PixelRidge-Softworks/Ruby/
|
|
|
|
|
|
|
|
# Clone the repository
|
2023-10-26 18:56:08 -06:00
|
|
|
sudo git clone https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Ru-b2-SQL-Backups.git /usr/bin/PixelRidge-Softworks/Ruby/
|
2023-03-19 18:22:50 -06:00
|
|
|
|
|
|
|
# Install required gems
|
2024-06-10 21:56:12 -06:00
|
|
|
cd /usr/bin/PixelRidge-Softworks/Ruby/Ru-b2-SQL-Backups || exit
|
2023-03-19 18:22:50 -06:00
|
|
|
bundle install
|
|
|
|
|
|
|
|
# Prompt user to run the program for the first time
|
|
|
|
read -p "Do you want to run the program for the first time? (y/n) " answer
|
|
|
|
if [[ $answer =~ ^[Yy]$ ]]; then
|
2024-06-10 21:56:12 -06:00
|
|
|
cd /usr/bin/PixelRidge-Softworks/Ruby/Ru-b2-SQL-Backups || exit
|
2023-07-29 13:39:35 -06:00
|
|
|
./rub2
|
2023-03-19 18:22:50 -06:00
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|