From 0254d7678c23fe56f0537134200bc7a855e39c92 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 25 Dec 2021 23:39:37 -0600 Subject: [PATCH] Install requirements for both CentOS and Ubuntu, requires testing --- Scripts/install-requirements.bash | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Scripts/install-requirements.bash diff --git a/Scripts/install-requirements.bash b/Scripts/install-requirements.bash new file mode 100644 index 0000000..7043df7 --- /dev/null +++ b/Scripts/install-requirements.bash @@ -0,0 +1,79 @@ +#!/bin/bash + +INSTALLER="" +INSTALL_PACKAGES=(tmux pv) + +echo_install_method() { + echo "Found ${1}, using ${1} to install packages" +} + +install_method_centos() { + + # Steamcmd requirements + INSTALL_PACKAGES+=(glibc.i686 libstdc++.i686) + + if which dnf >/dev/null 2>&1; then + INSTALLER="dnf -y install" + echo_install_method "dnf" + elif which yum >/dev/null 2>&1; then + INSTALLER="yum -y install" + echo_install_method "yum" + else + echo "Unable to determine installer!" + return 1 + fi + echo "Installing epel-release, NOT fully configured..., see: https://docs.fedoraproject.org/en-US/epel/" + sleep 3 + "$("${INSTALLER}" epel-release)" +} + +install_method_ubuntu() { + + # Steamcmd requirements + INSTALL_PACKAGES+=(lib32gcc1) + + if which apt >/dev/null 2>&1; then + INSTALLER="apt install -y" + echo_install_method "apt" + elif which apt-get >/dev/null 2>&1; then + INSTALLER="apt-get install -y" + echo_install_method "apt-get" + else + echo "Unable to determine installer!" + return 1 + fi +} + +main() { + # Auto exit is /etc/os-release does not exist, we depend upon this to determine os name + if [[ ! -f "/etc/os-release" ]]; then + echo "Unable to continue, cannot determine os release as /etc/os-release does not exist" + exit 1 + fi + + # This gets the unquoted os-release name + OS_RELEASE="$(grep ^NAME= /etc/os-release | cut -d "=" -f2 | tr -d '"')" + + if [[ "${OS_RELEASE}" = "CentOS Linux" ]]; then + install_method_centos || exit + elif [[ "${OS_RELEASE}" = "Ubuntu" ]]; then + install_method_ubuntu || exit + else + echo "${OS_RELEASE} is not a supported distribution, attempt a manual installation." + exit 1 + fi + + if [[ -z "${INSTALLER}" ]]; then + echo "No installer found, exiting..." + exit 1 + fi + + for pkg in "${INSTALL_PACKAGES[@]}"; do + echo "Installing ${pkg}" + "$("${INSTALLER}" "${pkg}")" + done + + echo "Finished installing general module items" +} + +main "${@}"