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 old mode 100644 new mode 100755 index 97e7858..d6b9dcd --- a/ionet-setup.sh +++ b/ionet-setup.sh @@ -3,24 +3,25 @@ set -euxo pipefail export DEBIAN_FRONTEND=noninteractive + sudo dpkg --set-selections <<< "cloud-init install" || true # 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) @@ -29,167 +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 incompatible 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 @@ -201,6 +231,14 @@ 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 + # @dev One assumes that if docker isn't installed, we'll install every docker related dependecies + 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..." # Install Docker-ce keyring @@ -216,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 @@ -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,30 @@ 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 + 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 - 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 +338,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