#!/bin/sh set -e _apt() { echo Setting up... distribution=`lsb_release -i | awk '{print tolower($3)}'` codename=`lsb_release -c | awk '{print tolower($2)}'` echo "deb https://repo.infinidat.com/packages/main-stable/apt/linux-$distribution $codename main" > /etc/apt/sources.list.d/repo.infinidat.com.main-stable.list echo Installing GPG key... curl -s https://repo.infinidat.com/packages/gpg.key | apt-key add - echo Fetching package metadata... apt-get update > /dev/null 2>&1 } _yum() { echo Setting up... distfile=`ls /etc | grep -E "(centos|redhat)-release$" | head -n 1` distribution=`cat /etc/$distfile | grep -Eio "centos|red hat|rocky" | head -n 1 | sed -e 's/ //' | awk '{print tolower($1)}'` version=`cat /etc/$distfile | grep -Eo "[0-9]+" | head -n 1` arch=`uname -m` echo "[repo.infinidat.com.main-stable] name=repo.infinidat.com.main-stable baseurl=https://repo.infinidat.com/packages/main-stable/yum/linux-$distribution-$version-$arch/ enabled=1 gpgcheck=1 gpgkey=https://repo.infinidat.com/packages/gpg.key" > /etc/yum.repos.d/repo.infinidat.com.main-stable.repo echo Fetching package metadata... yum makecache > /dev/null 2>&1 } _zypper() { name=repo.infinidat.com.main-stable if [ -f /etc/os-release ] then version=`cat /etc/os-release | grep -Eo "[0-9]+" | head -n 1` else version=`cat /etc/SuSE-release | grep -Eo "[0-9]+" | head -n 1` fi arch=`uname -m` url=https://repo.infinidat.com/packages/main-stable/yum/linux-suse-$version-$arch/ echo Installing GPG key... curl -s https://repo.infinidat.com/packages/gpg.key > /tmp/$name.gpg.key rpm --import /tmp/$name.gpg.key > /dev/null 2>&1 echo Setting up... zypper rr $name > /dev/null 2>&1 zypper ar -t YUM $url $name > /dev/null 2>&1 echo Fetching package metadata... zypper refresh repo.infinidat.com.main-stable > /dev/null 2>&1 } # suse if test -f /etc/SuSE-release || (test -f /etc/os-release && grep -Fq suse /etc/os-release) then _zypper exit 0 fi # debian-based if test -f /etc/debian_version then _apt exit 0 fi # redhat-based if test -f /etc/redhat-release || test -f /etc/centos-release then _yum exit 0 fi echo "OS not supported" exit 1