diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 95e1a92ba..ac5fb9bc8 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -83,3 +83,11 @@ do check_status.sh fi done + +local allowed_commands_array=( command_install.sh command_start.sh command_debug.sh ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${function_selfname}" ]; then + check_system_requirements.sh + fi +done diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh new file mode 100644 index 000000000..d9e56cc5f --- /dev/null +++ b/lgsm/functions/check_system_requirements.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# LGSM check_system_requirements.sh +# Author: Daniel Gibbs +# Contributor: UltimateByte +# Website: https://gameservermanagers.com +# Description: Checks RAM requirements + +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +info_distro.sh + +# RAM requirements in megabytes for each game or engine. +if [ "${gamename}" == "Rust" ]; then + ramrequirementmb="4000" + ramrequirementgb="4" +fi + +# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM. +if [ -n "${ramrequirement}" ]; then + if [ "${physmemtotalmb}" -lt "${ramrequirementmb}" ]; then + # Warn the user + fn_print_warn "Insufficient memory: ${ramrequirementgb}G required, ${physmemtotal} available" + sleep 1 + fn_print_warning "You may experiance poor performance from your server" + sleep 1 + fi +fi diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index e89b18fe7..2dda20940 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -222,6 +222,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +check_system_requirements.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + check_tmux.sh(){ functionfile="${FUNCNAME}" fn_fetch_function diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 9b4ba5886..02a2c0488 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -61,6 +61,7 @@ else fi physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}') +physmemtotalmb=$(free -m | awk '/Mem:/ {print $2}') physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}') physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}') physmemcached=$(free ${humanreadable} | awk '/cache:/ {print $4}') @@ -68,7 +69,6 @@ swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') - ### Disk Infomation ## Available disk space on the partition.