Compare commits

..

7 Commits

Author SHA1 Message Date
the-sane
bed6e76ba3 bytes, not KB 2023-03-21 22:11:10 -04:00
the-sane
c4d5a5a3dd awk can't always be trusted for math (mawk bad) 2023-03-21 22:10:11 -04:00
the-sane
4618dfed61 Improve memory_check 2023-03-21 21:44:10 -04:00
the-sane
d643ca3ce7 Fix swap size recommendations 2023-03-21 19:26:29 -04:00
the-sane
787fe0977c Fix comment 2023-03-21 15:27:14 -04:00
the-sane
d5c857d36e Bump version 2023-03-21 15:21:06 -04:00
the-sane
51b9e73090 Improve memory/swap checker 2023-03-21 15:20:15 -04:00

View File

@ -71,11 +71,11 @@ fi
# notify-send "lug-helper" "The package 'zstd' was not found on this system. It is required for extracting some runner packages.\n" --icon=dialog-warning
# exit 1
#fi
if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ]; then
if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ] || [ ! -x "$(command -v numfmt)" ]; then
# coreutils
# Print to stderr and also try warning the user through notify-send
printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n" 1>&2
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n" --icon=dialog-warning
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n- numfmt\n" --icon=dialog-warning
exit 1
fi
if [ ! -x "$(command -v xargs)" ]; then
@ -122,12 +122,6 @@ max_download_items=20
# used to dynamically determine the height of menus
menu_option_height="26"
# winetricks minimum version
winetricks_required="20220411"
# lutris minimum version
lutris_required="0.5.11"
######## Game Directories ##################################################
# The game's base directory name
@ -147,6 +141,26 @@ shaders_subdir="shaders"
# Remaining directory paths are set at the end of the getdirs() function
######## Bundled Files #####################################################
# Use logo installed by a packaged version of this script if available
# Otherwise, default to the logo in the same directory
if [ -f "/usr/share/pixmaps/lug-logo.png" ]; then
lug_logo="/usr/share/pixmaps/lug-logo.png"
elif [ -f "$helper_dir/lug-logo.png" ]; then
lug_logo="$helper_dir/lug-logo.png"
else
lug_logo="info"
fi
# Use Lutris install script installed by a packaged version of this script if available
# Otherwise, default to the json in the same directory
if [ -f "/usr/share/lug-helper/lug-lutris-install.json" ]; then
install_script="/usr/share/lug-helper/lug-lutris-install.json"
else
install_script="$helper_dir/lug-lutris-install.json"
fi
######## Runners ###########################################################
# Lutris native wine runners directory
@ -184,25 +198,17 @@ dxvk_sources=(
"/dev/null" "https://api.github.com/repos/gort818/dxvk/releases"
)
######## Bundled Files #####################################################
######## Requirements ######################################################
# Use logo installed by a packaged version of this script if available
# Otherwise, default to the logo in the same directory
if [ -f "/usr/share/pixmaps/lug-logo.png" ]; then
lug_logo="/usr/share/pixmaps/lug-logo.png"
elif [ -f "$helper_dir/lug-logo.png" ]; then
lug_logo="$helper_dir/lug-logo.png"
else
lug_logo="info"
fi
# winetricks minimum version
winetricks_required="20220411"
# Use Lutris install script installed by a packaged version of this script if available
# Otherwise, default to the json in the same directory
if [ -f "/usr/share/lug-helper/lug-lutris-install.json" ]; then
install_script="/usr/share/lug-helper/lug-lutris-install.json"
else
install_script="$helper_dir/lug-lutris-install.json"
fi
# lutris minimum version
lutris_required="0.5.11"
# Minimum amount of combined RAM + swap in GiB
memory_required="16"
memory_combined_required="40"
######## Links #############################################################
@ -212,7 +218,7 @@ lug_wiki="https://starcitizen-lug.github.io"
# Github repo and script version info
repo="starcitizen-lug/lug-helper"
releases_url="https://github.com/$repo/releases"
current_version="v2.5"
current_version="v2.6"
############################################################################
############################################################################
@ -893,13 +899,33 @@ winetricks_check() {
fi
}
# Check total system memory
# Check system memory and swap space
memory_check() {
memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
if [ "${memtotal%.*}" -ge "15" ]; then
preflight_pass+=("Your system has $memtotal GB of memory.")
# Get totals in bytes
memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf $2}' /proc/meminfo)"
swaptotal="$(LC_NUMERIC=C awk '/SwapTotal/ {printf $2}' /proc/meminfo)"
memtotal="$(($memtotal * 1024))"
swaptotal="$(($swaptotal * 1024))"
combtotal="$(($memtotal + $swaptotal))"
# Convert to GiB
memtotal="$(numfmt --to=iec-i --suffix="B" "$memtotal")"
swaptotal="$(numfmt --to=iec-i --suffix="B" "$swaptotal")"
combtotal="$(numfmt --to=iec-i --suffix="B" "$combtotal")"
if [ "${memtotal: -3}" != "GiB" ] || [ "${memtotal::-3}" -lt "$memory_required" ]; then
# Minimum requirements are not met
preflight_fail+=("Your system has $memtotal of memory.\n${memory_required}GiB is the minimum required to avoid crashes.")
elif [ "${memtotal::-3}" -ge "$memory_combined_required" ]; then
# System has sufficient RAM
preflight_pass+=("Your system has $memtotal of memory.")
elif [ "${combtotal::-3}" -ge "$memory_combined_required" ]; then
# System has sufficient combined RAM + swap
preflight_pass+=("Your system has $memtotal memory and $swaptotal swap.")
else
preflight_fail+=("Your system has $memtotal GB of memory.\nWe recommend at least 16 GB to avoid crashes.")
# Recommend swap
swap_recommended="$(($memory_combined_required - ${memtotal::-3}))"
preflight_fail+=("Your system has $memtotal memory and $swaptotal swap.\nWe recommend at least ${swap_recommended}GiB swap to avoid crashes.")
fi
}
@ -912,15 +938,6 @@ avx_check() {
fi
}
# Check if swap is set up
swap_check() {
if grep -vq "Filename" /proc/swaps; then
preflight_pass+=("You have swap space configured.")
else
preflight_fail+=("You don't appear to have swap space configured.\nWe recommend configuring an 8-16 GB swap file.")
fi
}
# Check that the system is optimized for Star Citizen
preflight_check() {
# Initialize variables
@ -937,7 +954,6 @@ preflight_check() {
wine_check
winetricks_check
memory_check
swap_check
avx_check
mapcount_check
filelimit_check