added os detection

This commit is contained in:
Roxy 2023-07-05 22:53:02 +02:00
parent fcf5e9ac65
commit 549b105bd6
1 changed files with 21 additions and 11 deletions

View File

@ -2,23 +2,33 @@
set -e
# Install Ruby and the Ruby dependency 'webrick'
if ! command -v ruby &> /dev/null; then
echo "Installing Ruby..."
sudo apt-get update
sudo apt-get install -y ruby-full
fi
# Detect the operating system
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
# Install Ruby, Nginx, and Git
case $OS in
"CentOS Linux"|"Fedora")
sudo yum install -y ruby nginx git
;;
"Arch Linux")
sudo pacman -Syu --noconfirm ruby nginx git
;;
"Debian GNU/Linux"|"Ubuntu"|"Raspbian GNU/Linux")
sudo apt-get update
sudo apt-get install -y ruby nginx git
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Install the 'webrick' gem
if ! gem list webrick -i > /dev/null; then
echo "Installing webrick..."
gem install webrick
fi
# Install Nginx and enable the service
if ! command -v nginx &> /dev/null; then
echo "Installing Nginx..."
sudo apt-get install -y nginx
fi
echo "Enabling Nginx service..."
sudo systemctl enable nginx