#!/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 "${@}"