Browse Source

re-word of mono repo install

pull/3568/head
Daniel Gibbs 4 years ago
parent
commit
c0b7228b67
  1. 188
      lgsm/functions/check_deps.sh

188
lgsm/functions/check_deps.sh

@ -3,18 +3,12 @@
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib # Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com # Website: https://linuxgsm.com
# Description: Checks if required dependencies are installed for LinuxGSM. # Description: Checks and installs missing dependencies.
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_install_mono_repo(){ fn_install_mono_repo(){
if [ "${monostatus}" != "0" ]; then if [ "${autodepinstall}" == "0" ]; then
if [ "${autoinstall}" == "1" ]; then
sudo -n true > /dev/null 2>&1
else
sudo -v > /dev/null 2>&1
fi
if [ $? -eq 0 ]; then
fn_print_information_nl "Automatically adding Mono repository." fn_print_information_nl "Automatically adding Mono repository."
fn_script_log_info "Automatically adding Mono repository." fn_script_log_info "Automatically adding Mono repository."
echo -en ".\r" echo -en ".\r"
@ -26,81 +20,68 @@ fn_install_mono_repo(){
echo -en " \r" echo -en " \r"
if [ "${distroid}" == "ubuntu" ]; then if [ "${distroid}" == "ubuntu" ]; then
if [ "${distroversion}" == "20.04" ]; then if [ "${distroversion}" == "20.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-add-repository 'deb https://download.mono-project.com/repo/ubuntu stable-focal main';sudo apt-get update" cmd="sudo apt install gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-focal main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "18.04" ]; then elif [ "${distroversion}" == "18.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update" cmd="sudo apt install gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "16.04" ]; then elif [ "${distroversion}" == "16.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update" cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https ca-certificates;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "14.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-trusty main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
eval "${cmd}"
else else
fn_print_warning_nl "Installing Mono repository."
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
monoautoinstall="1" monoautoinstall="1"
fi fi
elif [ "${distroid}" == "debian" ]; then elif [ "${distroid}" == "debian" ]; then
if [ "${distroversion}" == "10" ]; then if [ "${distroversion}" == "10" ]; then
cmd="sudo apt-get install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update" cmd="sudo apt install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "9" ]; then elif [ "${distroversion}" == "9" ]; then
cmd="sudo apt-get install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update" cmd="sudo apt install apt-transport-https dirmngr gnupg ca-certificates;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "8" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/debian stable-jessie main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
eval "${cmd}"
else else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
monoautoinstall="1" monoautoinstall="1"
fi fi
elif [ "${distroid}" == "centos" ]; then elif [ "${distroid}" == "centos" ]||[ "${distroid}" == "almalinux" ]||[ "${distroid}" == "rocky" ]; then
if [ "${distroversion}" == "8" ]; then if [ "${distroversion}" == "8" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'" cmd="sudo rpmkeys --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'"
eval "${cmd}"
elif [ "${distroversion}" == "7" ]; then elif [ "${distroversion}" == "7" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'" cmd="sudo rpmkeys --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'"
eval "${cmd}"
else else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
monoautoinstall="1" monoautoinstall="1"
fi fi
elif [ "${distroid}" == "fedora" ]; then elif [ "${distroid}" == "fedora" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF'; su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'; dnf update" if [ "${distroversion}" -ge "29" ]; then
eval "${cmd}" cmd="sudo rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo';dnf update"
else
cmd="sudo rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo';dnf update"
fi
else else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
monoautoinstall="1" monoautoinstall="1"
fi fi
# Run the mono repo install.
eval "${cmd}"
# Did Mono repo install correctly?
if [ "${monoautoinstall}" != "1" ]; then if [ "${monoautoinstall}" != "1" ]; then
if [ $? != 0 ]; then if [ $? != 0 ]; then
fn_print_failure_nl "Unable to install Mono repository." fn_print_failure_nl "Unable to install Mono repository."
fn_script_log_fatal "Unable to install Mono repository." fn_script_log_fatal "Unable to install Mono repository."
monoautoinstall=1
else else
fn_print_complete_nl "Installing Mono repository completed." fn_print_complete_nl "Installing Mono repository completed."
fn_script_log_pass "Installing Mono repository completed." fn_script_log_pass "Installing Mono repository completed."
monoautoinstall=0
fi fi
fi fi
# Mono can not be auto installed with this distro.
if [ "${monoautoinstall}" == "1" ]; then
fn_print_warning_nl "Mono auto install not available for ${distroname}."
echo -e "Follow instructions on Mono website to install."
echo -e "https://www.mono-project.com/download/stable/#download-lin"
fn_script_log_warn "Unable to install Mono repository. Mono auto install not available for ${distroname}."
fi
else else
fn_print_information_nl "Installing Mono repository." fn_print_information_nl "Installing Mono repository."
echo -e "" fn_print_warning_nl "$(whoami) does not have sudo access."
fn_print_warning_nl "$(whoami) does not have sudo access. Manually install Mono repository." echo -e "Follow instructions on Mono website to install."
fn_script_log_warn "$(whoami) does not have sudo access. Manually install Mono repository."
echo -e "* Follow instructions on mono site to install the latest version of Mono."
echo -e "https://www.mono-project.com/download/stable/#download-lin" echo -e "https://www.mono-project.com/download/stable/#download-lin"
fi fn_script_log_warn "Unable to install Mono repository. $(whoami) does not have sudo access."
fi fi
} }
@ -127,7 +108,8 @@ fn_deps_email(){
fi fi
} }
fn_found_missing_deps(){ fn_install_missing_deps(){
# If any dependencies are not installed.
if [ "${#array_deps_missing[*]}" != "0" ]; then if [ "${#array_deps_missing[*]}" != "0" ]; then
if [ "${commandname}" == "INSTALL" ]; then if [ "${commandname}" == "INSTALL" ]; then
fn_print_warning_nl "Missing dependencies: ${red}${array_deps_missing[*]}${default}" fn_print_warning_nl "Missing dependencies: ${red}${array_deps_missing[*]}${default}"
@ -138,15 +120,31 @@ fn_found_missing_deps(){
fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}" fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
fi fi
fn_sleep_time fn_sleep_time
if [ -n "${monostatus}" ]; then
fn_install_mono_repo # Attempt automatic dependency installation
fi
if [ "${autoinstall}" == "1" ]; then if [ "${autoinstall}" == "1" ]; then
sudo -n true > /dev/null 2>&1 sudo -n true > /dev/null 2>&1
else else
sudo -v > /dev/null 2>&1 sudo -v > /dev/null 2>&1
fi fi
if [ $? -eq 0 ]; then autodepinstall="$?"
if [ "${commandname}" == "INSTALL" ]; then
if [ "${autodepinstall}" == "0" ]; then
fn_print_information_nl "$(whoami) has sudo access."
fn_script_log_info "$(whoami) has sudo access."
else
fn_print_information_nl "$(whoami) does not have sudo access. Manually install dependencies."
fn_script_log_info "$(whoami) does not have sudo access. Manually install dependencies."
fi
fi
if [ -n "${monostatus}" ]; then
fn_install_mono_repo
fi
# If automatic dependency install is available
if [ "${autodepinstall}" == "0" ]; then
fn_print_information_nl "Automatically installing missing dependencies." fn_print_information_nl "Automatically installing missing dependencies."
fn_script_log_info "Automatically installing missing dependencies." fn_script_log_info "Automatically installing missing dependencies."
echo -en ".\r" echo -en ".\r"
@ -166,39 +164,11 @@ fn_found_missing_deps(){
cmd="sudo yum -y install ${array_deps_missing[*]}" cmd="sudo yum -y install ${array_deps_missing[*]}"
eval "${cmd}" eval "${cmd}"
fi fi
if [ $? != 0 ]; then autodepinstall="$?"
fn_print_failure_nl "Unable to install dependencies."
fn_script_log_fatal "Unable to install dependencies."
echo -e ""
fn_print_warning_nl "Manually install dependencies."
fn_script_log_warn "Manually install dependencies."
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
echo -e "sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[*]}"
elif [ "$(command -v dnf 2>/dev/null)" ]; then
echo -e "sudo dnf install ${array_deps_missing[*]}"
elif [ "$(command -v yum 2>/dev/null)" ]; then
echo -e "sudo yum install ${array_deps_missing[*]}"
fi fi
if [ -n "${steamcmdfail}" ]; then
echo -e "" # If automatic dependency install is unavailable.
if [ "${commandname}" == "INSTALL" ]; then if [ "${autodepinstall}" != "0" ]; then
fn_print_failure_nl "Missing dependencies required to run SteamCMD."
fn_script_log_fatal "Missing dependencies required to run SteamCMD."
core_exit.sh
else
fn_print_error_nl "Missing dependencies required to run SteamCMD."
fn_script_log_error "Missing dependencies required to run SteamCMD."
fi
fi
else
fn_print_complete_nl "Install dependencies completed."
fn_script_log_pass "Install dependencies completed."
fi
else
if [ "${commandname}" == "INSTALL" ]; then
fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies."
fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies."
echo -e ""
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
echo -e "sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[*]}" echo -e "sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[*]}"
elif [ "$(command -v dnf 2>/dev/null)" ]; then elif [ "$(command -v dnf 2>/dev/null)" ]; then
@ -207,8 +177,8 @@ fn_found_missing_deps(){
echo -e "sudo yum install ${array_deps_missing[*]}" echo -e "sudo yum install ${array_deps_missing[*]}"
fi fi
fi fi
if [ "${steamcmdfail}" ]; then if [ "${steamcmdfail}" ]; then
echo -e ""
if [ "${commandname}" == "INSTALL" ]; then if [ "${commandname}" == "INSTALL" ]; then
fn_print_failure_nl "Missing dependencies required to run SteamCMD." fn_print_failure_nl "Missing dependencies required to run SteamCMD."
fn_script_log_fatal "Missing dependencies required to run SteamCMD." fn_script_log_fatal "Missing dependencies required to run SteamCMD."
@ -218,11 +188,7 @@ fn_found_missing_deps(){
fn_script_log_error "Missing dependencies required to run SteamCMD." fn_script_log_error "Missing dependencies required to run SteamCMD."
fi fi
fi fi
echo -e ""
fi
if [ "${commandname}" == "INSTALL" ]; then
sleep 5
fi
else else
if [ "${commandname}" == "INSTALL" ]; then if [ "${commandname}" == "INSTALL" ]; then
fn_print_information_nl "Required dependencies already installed." fn_print_information_nl "Required dependencies already installed."
@ -232,31 +198,31 @@ fn_found_missing_deps(){
} }
fn_check_loop(){ fn_check_loop(){
# Loop though required depenencies. # Loop though required depenencies checking if they are installed.
for deptocheck in ${array_deps_required[*]}; do for deptocheck in ${array_deps_required[*]}; do
fn_deps_detector fn_deps_detector
done done
# user to be informed of any missing dependencies. # user eill be informed of any missing dependencies.
fn_found_missing_deps fn_install_missing_deps
} }
# Checks if dependency is installed or not.
fn_deps_detector(){ fn_deps_detector(){
# Checks if dependency is missing.
# Java: Added for users using Oracle JRE to bypass check. # Java: Added for users using Oracle JRE to bypass check.
if [ ${deptocheck} == "openjdk-16-jre" ]||[ ${deptocheck} == "java-11-openjdk" ]; then if [ ${deptocheck} == "openjdk-16-jre" ]||[ ${deptocheck} == "java-11-openjdk" ]; then
# Is java already installed?
javaversion=$(java -version 2>&1 | grep "version") javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then if [ -n "${javaversion}" ]; then
javacheck=1 javastatus=1
fi fi
fi fi
if [ "${javacheck}" == "1" ]; then if [ "${javastatus}" == "1" ]; then
# Added for users using Oracle JRE to bypass check. # Added for users using Oracle JRE to bypass check.
depstatus=0 depstatus=0
deptocheck="${javaversion}" deptocheck="${javaversion}"
unset javacheck unset javastatus
# Mono # Mono: A Mono repo needs to be installed.
elif [ "${deptocheck}" == "mono-complete" ]; then elif [ "${deptocheck}" == "mono-complete" ]; then
if [ "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then if [ "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then
# Mono >= 5.0.0 already installed. # Mono >= 5.0.0 already installed.
@ -291,7 +257,7 @@ fn_deps_detector(){
fi fi
# Define required dependencies for SteamCMD. # Define required dependencies for SteamCMD.
if [ -n "${appid}" ]; then if [ -n "${appid}" ]; then
array_steamcmd_deps_required=("${dependencysteamcmd}") array_steamcmd_deps_required=("${depsteamcmd}")
for steamcmddeptocheck in ${array_steamcmd_deps_required[*]}; do for steamcmddeptocheck in ${array_steamcmd_deps_required[*]}; do
if [ "${deptocheck}" == "${steamcmddeptocheck}" ]; then if [ "${deptocheck}" == "${steamcmddeptocheck}" ]; then
steamcmdfail=1 steamcmdfail=1
@ -333,19 +299,19 @@ fi
# If the file successfully downloaded run the dependency check. # If the file successfully downloaded run the dependency check.
if [ -f "${datadir}/${distroid}-${distroversion}.csv" ]; then if [ -f "${datadir}/${distroid}-${distroversion}.csv" ]; then
dependencyinstall=$(awk -F, '$1=="install" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") depinstall=$(awk -F, '$1=="install" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv")
dependencyall=$(awk -F, '$1=="all" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") depall=$(awk -F, '$1=="all" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv")
dependencysteamcmd=$(awk -F, '$1=="steamcmd" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") depsteamcmd=$(awk -F, '$1=="steamcmd" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv")
dependencyshortname=$(awk -v shortname="$shortname" -F, '$1==shortname {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") depshortname=$(awk -v shortname="$shortname" -F, '$1==shortname {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv")
# Generate array of missing deps. # Generate array of missing deps.
array_deps_missing=() array_deps_missing=()
array_deps_required=("${dependencyall} ${dependencysteamcmd} ${dependencyshortname}") array_deps_required=("${depall} ${depsteamcmd} ${depshortname}")
fn_deps_email
# Unique sort dependency array. # Unique sort dependency array.
IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')" IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
fn_deps_email
fn_check_loop fn_check_loop
# Warn the user that dependency checking is unavailable for their distro. # Warn the user that dependency checking is unavailable for their distro.
elif [ "${commandname}" == "INSTALL" ]||[ -n "${checkflag}" ]&&[ "${checkflag}" != "0" ]; then elif [ "${commandname}" == "INSTALL" ]||[ -n "${checkflag}" ]&&[ "${checkflag}" != "0" ]; then

Loading…
Cancel
Save