General/Scripts/install-requirements.bash
2021-12-26 00:11:15 -06:00

80 lines
2.0 KiB
Bash

#!/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 install -y"
echo_install_method "dnf"
elif which yum >/dev/null 2>&1; then
INSTALLER="yum install -y"
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
eval "${INSTALLER} epel-release" 2>/dev/null
}
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"* ]]; then
install_method_centos
elif [[ "${OS_RELEASE}" = *"Ubuntu"* ]]; then
install_method_ubuntu
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}"
eval "${INSTALLER} ${pkg}"
done
echo "Finished installing general module items"
}
main "${@}"