Files
runner/src/Misc/layoutbin/installdependencies.sh
T

234 lines
7.2 KiB
Bash
Raw Normal View History

2019-10-10 00:52:42 -04:00
#!/bin/bash
user_id=`id -u`
if [ $user_id -ne 0 ]; then
echo "Need to run with sudo privilege"
exit 1
fi
# Determine OS type
# Debian based OS (Debian, Ubuntu, Linux Mint) has /etc/debian_version
2020-04-19 22:53:06 +02:00
# Fedora based OS (Fedora, Red Hat Enterprise Linux, CentOS, Oracle Linux 7) has /etc/redhat-release
2019-10-10 00:52:42 -04:00
# SUSE based OS (OpenSUSE, SUSE Enterprise) has ID_LIKE=suse in /etc/os-release
function print_errormessage()
{
2021-01-21 13:45:16 -05:00
echo "Can't install dotnet core dependencies."
2019-10-10 00:52:42 -04:00
echo "You can manually install all required dependencies based on following documentation"
echo "https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x"
}
function print_rhel6message()
{
2021-01-21 13:45:16 -05:00
echo "We did our best effort to install dotnet core dependencies"
2019-10-10 00:52:42 -04:00
echo "However, there are some dependencies which require manual installation"
echo "You can install all remaining required dependencies based on the following documentation"
echo "https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md"
}
function print_rhel6errormessage()
{
2021-01-21 13:45:16 -05:00
echo "We couldn't install dotnet core dependencies"
2019-10-10 00:52:42 -04:00
echo "You can manually install all required dependencies based on following documentation"
echo "https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x"
echo "In addition, there are some dependencies which require manual installation. Please follow this documentation"
echo "https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md"
}
if [ -e /etc/os-release ]
then
echo "--------OS Information--------"
cat /etc/os-release
echo "------------------------------"
if [ -e /etc/debian_version ]
then
echo "The current OS is Debian based"
echo "--------Debian Version--------"
cat /etc/debian_version
echo "------------------------------"
2020-10-26 23:27:09 -04:00
# prefer apt-get over apt
command -v apt-get
2019-10-10 00:52:42 -04:00
if [ $? -eq 0 ]
then
2020-10-26 23:27:09 -04:00
apt_get=apt-get
2019-10-10 00:52:42 -04:00
else
2020-10-26 23:27:09 -04:00
command -v apt
2019-10-10 00:52:42 -04:00
if [ $? -eq 0 ]
then
2020-10-26 23:27:09 -04:00
apt_get=apt
2019-10-10 00:52:42 -04:00
else
2020-10-26 23:27:09 -04:00
echo "Found neither 'apt-get' nor 'apt'"
2019-10-10 00:52:42 -04:00
print_errormessage
exit 1
fi
fi
2020-10-26 23:27:09 -04:00
$apt_get update && $apt_get install -y libkrb5-3 zlib1g
2020-10-26 23:27:09 -04:00
if [ $? -ne 0 ]
then
echo "'$apt_get' failed with exit code '$?'"
print_errormessage
exit 1
fi
apt_get_with_fallbacks() {
$apt_get install -y $1
fail=$?
if [ $fail -eq 0 ]
then
if [ "${1#"${1%?}"}" = '$' ]; then
dpkg -l "${1%?}" > /dev/null 2> /dev/null
fail=$?
fi
fi
if [ $fail -ne 0 ]
then
shift
if [ -n "$1" ]
then
apt_get_with_fallbacks "$@"
fi
fi
}
apt_get_with_fallbacks liblttng-ust1 liblttng-ust0
if [ $? -ne 0 ]
then
echo "'$apt_get' failed with exit code '$?'"
print_errormessage
exit 1
fi
2020-10-26 23:27:09 -04:00
apt_get_with_fallbacks libssl1.1$ libssl1.0.2$ libssl1.0.0$
if [ $? -ne 0 ]
then
echo "'$apt_get' failed with exit code '$?'"
print_errormessage
exit 1
fi
apt_get_with_fallbacks libicu72 libicu71 libicu70 libicu69 libicu68 libicu67 libicu66 libicu65 libicu63 libicu60 libicu57 libicu55 libicu52
2020-10-26 23:27:09 -04:00
if [ $? -ne 0 ]
then
echo "'$apt_get' failed with exit code '$?'"
print_errormessage
exit 1
fi
2019-10-10 00:52:42 -04:00
elif [ -e /etc/redhat-release ]
then
echo "The current OS is Fedora based"
2020-04-19 22:53:06 +02:00
echo "--Fedora/RHEL/CentOS Version--"
2019-10-10 00:52:42 -04:00
cat /etc/redhat-release
echo "------------------------------"
# use dnf on fedora
2020-04-19 22:53:06 +02:00
# use yum on centos and rhel
2019-10-10 00:52:42 -04:00
if [ -e /etc/fedora-release ]
then
command -v dnf
if [ $? -eq 0 ]
then
2019-10-24 16:52:29 -04:00
dnf install -y lttng-ust openssl-libs krb5-libs zlib libicu
2019-10-10 00:52:42 -04:00
if [ $? -ne 0 ]
then
echo "'dnf' failed with exit code '$?'"
print_errormessage
exit 1
fi
else
echo "Can not find 'dnf'"
print_errormessage
exit 1
fi
else
command -v yum
if [ $? -eq 0 ]
then
2019-10-24 16:52:29 -04:00
yum install -y lttng-ust openssl-libs krb5-libs zlib libicu
2019-10-10 00:52:42 -04:00
if [ $? -ne 0 ]
then
echo "'yum' failed with exit code '$?'"
print_errormessage
exit 1
fi
else
echo "Can not find 'yum'"
print_errormessage
exit 1
fi
fi
else
# we might on OpenSUSE
OSTYPE=$(grep ID_LIKE /etc/os-release | cut -f2 -d=)
echo $OSTYPE
2019-10-24 16:52:29 -04:00
echo $OSTYPE | grep "suse"
if [ $? -eq 0 ]
2019-10-10 00:52:42 -04:00
then
echo "The current OS is SUSE based"
command -v zypper
if [ $? -eq 0 ]
then
2019-10-24 16:52:29 -04:00
zypper -n install lttng-ust libopenssl1_1 krb5 zlib libicu60_2
2019-10-10 00:52:42 -04:00
if [ $? -ne 0 ]
then
echo "'zypper' failed with exit code '$?'"
print_errormessage
exit 1
fi
else
echo "Can not find 'zypper'"
print_errormessage
exit 1
fi
else
echo "Can't detect current OS type based on /etc/os-release."
print_errormessage
exit 1
fi
fi
elif [ -e /etc/redhat-release ]
# RHEL6 doesn't have an os-release file defined, read redhat-release instead
then
redhatRelease=$(</etc/redhat-release)
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]
then
2020-04-19 22:53:06 +02:00
echo "The current OS is Red Hat Enterprise Linux 6 or CentOS 6"
2019-10-10 00:52:42 -04:00
# Install known dependencies, as a best effort.
# The remaining dependencies are covered by the GitHub doc that will be shown by `print_rhel6message`
command -v yum
if [ $? -eq 0 ]
then
yum install -y openssl krb5-libs zlib
if [ $? -ne 0 ]
then
echo "'yum' failed with exit code '$?'"
print_rhel6errormessage
exit 1
fi
else
echo "Can not find 'yum'"
print_rhel6errormessage
exit 1
fi
print_rhel6message
exit 1
else
echo "Unknown RHEL OS version"
print_errormessage
exit 1
fi
else
echo "Unknown OS version"
print_errormessage
exit 1
fi
echo "-----------------------------"
echo " Finish Install Dependencies"
echo "-----------------------------"