From 8770225722efb8e82930acebf4144441cf7c2374 Mon Sep 17 00:00:00 2001 From: Fabio Matos Date: Tue, 16 Apr 2024 18:05:34 +0000 Subject: [PATCH 1/3] Install Script - Added compatibility with Fedora --- README.md | 3 ++- ionet-setup.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 288d171..e2ebc7a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ The `ionet-setup.sh` script performs a series of operations: - Ubuntu (20.04, 22.04, 18.04) - Debian (10, 11) +- Fedora (38, 39) ## Contributions @@ -45,4 +46,4 @@ Contributions to this script are welcome. Please ensure that any pull requests o ## Support -For support, please open an issue or contact our support team on [discord](https://discord.gg/kqFzFK7fg2) +For support, please open an issue or contact our support team on [discord](https://discord.gg/kqFzFK7fg2) \ No newline at end of file diff --git a/ionet-setup.sh b/ionet-setup.sh index 97e7858..1faf26c 100644 --- a/ionet-setup.sh +++ b/ionet-setup.sh @@ -2,8 +2,10 @@ set -euxo pipefail + export DEBIAN_FRONTEND=noninteractive -sudo dpkg --set-selections <<< "cloud-init install" || true + +# @dev Removed the selection state of `cloud-init` package, as it is dispensable and prevents errors on other Distros # Set Gloabal Variables # Detect OS @@ -170,6 +172,34 @@ else exit 1 ;; + # @dev Added the following code lines to install dependencies in Fedora distros + "fedora") + case $VERSION in + "38"|"39") + # Commands specific to Fedora + # @dev Remove uncompatible versions of docker + sudo dnf remove moby-engine -y || true + sudo dnf update -y + sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm -y || true + sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm -y || true + sudo dnf makecache -y + sudo dnf update -y + sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y || true + sudo dnf autoremove -y + ;; + + *) + echo "This version of Fedora is not supported in this script." + exit 1 + ;; + esac + ;; + + *) + echo "Your Linux distribution is not supported." + exit 1 + ;; + "Windows_NT") # For Windows Subsystem for Linux (WSL) with Ubuntu if grep -q Microsoft /proc/version; then @@ -201,6 +231,17 @@ fi # Check if Docker is installed if command -v docker &>/dev/null; then echo "Docker is already installed." +# @dev Added the following code lines to install dependencies in Fedora distros +elif [["$DISTRO" == "fedora"]]; then + echo "Docker is not installed. Proceeding with installations..." + sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo || true + sudo dnf update -y || true + sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y || true + # @dev One assumes that if docker isn't installed, we'll install every docker related dependecies + curl -s -L https://nvidia.github.io/libnvidia-container/centos8/libnvidia-container.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo || true + sudo dnf update -y || true + sudo dnf install nvidia-docker2 -y || true + sudo dnf autoremove -y else echo "Docker is not installed. Proceeding with installations..." # Install Docker-ce keyring @@ -226,9 +267,15 @@ fi # Check if docker-compose is installed if command -v docker-compose &>/dev/null; then echo "Docker-compose is already installed." +# @dev Added the following code lines to install dependencies in Fedora distros +elif [["$DISTRO" == "fedora"]]; then + echo "Docker-compose is not installed. Proceeding with installations..." + sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo || true + sudo dnf update -y + sudo dnf install docker-compose-plugin -y || true + sudo dnf autoremove -y else echo "Docker-compose is not installed. Proceeding with installations..." - # Install docker-compose subcommand sudo apt -y install docker-compose-plugin sudo ln -sv /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose @@ -239,17 +286,27 @@ fi if [[ ! -z "$NVIDIA_PRESENT" ]]; then if sudo docker run --gpus all nvidia/cuda:11.0.3-base-ubuntu18.04 nvidia-smi &>/dev/null; then echo "nvidia-docker is enabled and working. Exiting script." + # @dev Added the following code lines to install dependencies in Fedora distros + elif [["$DISTRO" == "fedora"]]; then + echo "nvidia-docker is not installed. Proceeding with installations..." + # @dev Tested the following repo and it works fine in Fedora 38 and 39 + curl -s -L https://nvidia.github.io/libnvidia-container/centos8/libnvidia-container.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo || true + sudo dnf update -y || true + sudo dnf install nvidia-docker2 -y || true + sudo dnf autoremove -y else echo "nvidia-docker does not seem to be enabled. Proceeding with installations..." distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit - sudo systemctl restart docker + sudo systemctl restart docker sudo docker run --gpus all nvidia/cuda:11.0.3-base-ubuntu18.04 nvidia-smi fi fi -sudo apt-mark hold nvidia* libnvidia* + +# @dev Removed the hold option for the apt package + # Add docker group and user to group docker sudo groupadd docker || true sudo usermod -aG docker $USER || true @@ -278,4 +335,4 @@ EOF' # Restart Docker to apply changes. sudo systemctl restart docker -echo "Workaround applied. Docker has been configured to use 'cgroupfs' as the cgroup driver." +echo "Workaround applied. Docker has been configured to use 'cgroupfs' as the cgroup driver." \ No newline at end of file From 940064916acce3ade017cd3904e727e24efe369e Mon Sep 17 00:00:00 2001 From: Fabio Matos Date: Wed, 17 Apr 2024 17:50:25 +0000 Subject: [PATCH 2/3] Instal Script Updated --- ionet-setup.sh | 409 +++++++++++++++++++++++++------------------------ 1 file changed, 206 insertions(+), 203 deletions(-) mode change 100644 => 100755 ionet-setup.sh diff --git a/ionet-setup.sh b/ionet-setup.sh old mode 100644 new mode 100755 index 1faf26c..8b6ae48 --- a/ionet-setup.sh +++ b/ionet-setup.sh @@ -2,27 +2,26 @@ set -euxo pipefail - export DEBIAN_FRONTEND=noninteractive # @dev Removed the selection state of `cloud-init` package, as it is dispensable and prevents errors on other Distros # Set Gloabal Variables - # Detect OS - OS="$(uname)" - case $OS in - "Linux") - # Detect Linux Distro - if [ -f /etc/os-release ]; then - . /etc/os-release - DISTRO=$ID - VERSION=$VERSION_ID - else - echo "Your Linux distribution is not supported." - exit 1 - fi - ;; - esac +# Detect OS +OS="$(uname)" +case $OS in +"Linux") + # Detect Linux Distro + if [ -f /etc/os-release ]; then + . /etc/os-release + DISTRO=$ID + VERSION=$VERSION_ID + else + echo "Your Linux distribution is not supported." + exit 1 + fi + ;; +esac # Detect if an Nvidia GPU is present NVIDIA_PRESENT=$(lspci | grep -i nvidia || true) @@ -31,195 +30,196 @@ NVIDIA_PRESENT=$(lspci | grep -i nvidia || true) if [[ -z "$NVIDIA_PRESENT" ]]; then echo "No NVIDIA device detected on this system." else -# Check if nvidia-smi is available and working + # Check if nvidia-smi is available and working if command -v nvidia-smi &>/dev/null; then echo "CUDA drivers already installed as nvidia-smi works." + if [ "$DISTRO" = "fedora" ]; then + # @dev Remove uncompatible versions of docker + if command -v docker &>/dev/null; then + sudo dnf remove moby-engine -y || true + fi + fi else - # Depending on Distro - case $DISTRO in - "ubuntu") - case $VERSION in - "20.04") - # Commands specific to Ubuntu 20.04 - sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get autoremove -y; apt-get autoclean -y' - sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get autoremove -y; apt-get autoclean -y' - sudo apt install linux-headers-$(uname -r) -y - sudo apt del 7fa2af80 || true - sudo apt remove 7fa2af80 || true - sudo apt install build-essential cmake gpg unzip pkg-config software-properties-common ubuntu-drivers-common -y - sudo apt install libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev -y || true - sudo apt install libjpeg-dev libpng-dev libtiff-dev -y || true - sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y || true - sudo apt install libxvidcore-dev libx264-dev -y || true - sudo apt install libopenblas-dev libatlas-base-dev liblapack-dev gfortran -y || true - sudo apt install libhdf5-serial-dev -y || true - sudo apt install python3-dev python3-tk python-imaging-tk curl cuda-keyring gnupg-agent dirmngr alsa-utils -y || true - sudo apt install libgtk-3-dev -y || true - sudo apt update -y - sudo dirmngr /dev/null; then + sudo dnf remove moby-engine -y || true fi + sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm -y || true + sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm -y || true + sudo dnf update -y + sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y || true + sudo dnf autoremove -y ;; *) - echo "Your OS is not supported." + echo "This version of Fedora is not supported in this script." exit 1 ;; + esac + ;; + + *) + echo "Your Linux distribution is not supported." + exit 1 + ;; + + "Windows_NT") + # For Windows Subsystem for Linux (WSL) with Ubuntu + if grep -q Microsoft /proc/version; then + wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb + sudo dpkg -i cuda-keyring_1.1-1_all.deb + sudo apt-get update + sudo apt-get -y install cuda + else + echo "This bash script can't be executed on Windows directly unless using WSL with Ubuntu. For other scenarios, consider using a PowerShell script or manual installation." + exit 1 + fi + ;; + + *) + echo "Your OS is not supported." + exit 1 + ;; esac - echo "System will now reboot !!! Please re-run this script after restart to complete installation !" - sleep 5s + echo "System will now reboot !!! Please re-run this script after restart to complete installation !" + sleep 5s sudo reboot fi fi @@ -232,15 +232,12 @@ fi if command -v docker &>/dev/null; then echo "Docker is already installed." # @dev Added the following code lines to install dependencies in Fedora distros -elif [["$DISTRO" == "fedora"]]; then +elif [ "$DISTRO" = "fedora" ]; then echo "Docker is not installed. Proceeding with installations..." sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo || true - sudo dnf update -y || true - sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y || true + sudo dnf update -y # @dev One assumes that if docker isn't installed, we'll install every docker related dependecies - curl -s -L https://nvidia.github.io/libnvidia-container/centos8/libnvidia-container.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo || true - sudo dnf update -y || true - sudo dnf install nvidia-docker2 -y || true + sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y || true sudo dnf autoremove -y else echo "Docker is not installed. Proceeding with installations..." @@ -257,9 +254,12 @@ else # Add Docker-ce repository to Apt sources and install echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ - $(. /etc/os-release; echo "$VERSION_CODENAME") stable" | \ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $( + . /etc/os-release + echo "$VERSION_CODENAME" + ) stable" | + sudo tee /etc/apt/sources.list.d/docker.list >/dev/null sudo apt update -y sudo apt -y install docker-ce fi @@ -268,7 +268,7 @@ fi if command -v docker-compose &>/dev/null; then echo "Docker-compose is already installed." # @dev Added the following code lines to install dependencies in Fedora distros -elif [["$DISTRO" == "fedora"]]; then +elif [ "$DISTRO" = "fedora" ]; then echo "Docker-compose is not installed. Proceeding with installations..." sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo || true sudo dnf update -y @@ -286,17 +286,20 @@ fi if [[ ! -z "$NVIDIA_PRESENT" ]]; then if sudo docker run --gpus all nvidia/cuda:11.0.3-base-ubuntu18.04 nvidia-smi &>/dev/null; then echo "nvidia-docker is enabled and working. Exiting script." - # @dev Added the following code lines to install dependencies in Fedora distros - elif [["$DISTRO" == "fedora"]]; then + # @dev Added the following code lines to install dependencies in Fedora distros + elif [ "$DISTRO" = "fedora" ]; then echo "nvidia-docker is not installed. Proceeding with installations..." - # @dev Tested the following repo and it works fine in Fedora 38 and 39 + # @dev Tested the following repo and it works fine in Fedora 38 and 39 curl -s -L https://nvidia.github.io/libnvidia-container/centos8/libnvidia-container.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo || true - sudo dnf update -y || true + sudo dnf update -y sudo dnf install nvidia-docker2 -y || true sudo dnf autoremove -y else echo "nvidia-docker does not seem to be enabled. Proceeding with installations..." - distribution=$(. /etc/os-release;echo $ID$VERSION_ID) + distribution=$( + . /etc/os-release + echo $ID$VERSION_ID + ) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit From 635c1b96e9b0617a96993300d15d1a7f524d2705 Mon Sep 17 00:00:00 2001 From: Fabio Matos Date: Thu, 18 Apr 2024 19:08:14 +0000 Subject: [PATCH 3/3] Install Script Updated --- ionet-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ionet-setup.sh b/ionet-setup.sh index 8b6ae48..d6b9dcd 100755 --- a/ionet-setup.sh +++ b/ionet-setup.sh @@ -4,7 +4,7 @@ set -euxo pipefail export DEBIAN_FRONTEND=noninteractive -# @dev Removed the selection state of `cloud-init` package, as it is dispensable and prevents errors on other Distros +sudo dpkg --set-selections <<< "cloud-init install" || true # Set Gloabal Variables # Detect OS @@ -34,7 +34,7 @@ else if command -v nvidia-smi &>/dev/null; then echo "CUDA drivers already installed as nvidia-smi works." if [ "$DISTRO" = "fedora" ]; then - # @dev Remove uncompatible versions of docker + # @dev Remove incompatible versions of docker if command -v docker &>/dev/null; then sudo dnf remove moby-engine -y || true fi @@ -177,7 +177,7 @@ else case $VERSION in "38" | "39") # Commands specific to Fedora - # @dev Remove uncompatible versions of docker + # @dev Remove incompatible versions of docker if command -v docker &>/dev/null; then sudo dnf remove moby-engine -y || true fi