From 549b105bd6608ee076456a233f21a1a0316cb2b6 Mon Sep 17 00:00:00 2001 From: Roxy Date: Wed, 5 Jul 2023 22:53:02 +0200 Subject: [PATCH] added os detection --- installer.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/installer.sh b/installer.sh index fe90b7d..59df511 100644 --- a/installer.sh +++ b/installer.sh @@ -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