mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-07-01 13:30:35 +00:00
Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
b6eea7b224 | |||
c9c3c07866 | |||
2e883423d3 | |||
12a3a51eb4 | |||
aec6ffbfc0 | |||
96b15262f5 | |||
9986f62566 | |||
a2397c28f0 | |||
e8891b42e6 | |||
52f602498e | |||
9279c68d69 | |||
45e5f586dd | |||
9d532f3ac5 | |||
ce7031e873 | |||
8492cdc3a2 | |||
b22e84887e | |||
bfc2822a35 | |||
dfe15f8e78 | |||
8a27a77579 | |||
28edb3393e | |||
978e0adc92 | |||
1ae2d6e4b4 | |||
ae7c407b19 | |||
5caea10a6b | |||
c6b56ac98b | |||
407db0bbcf | |||
70f282d012 | |||
0018591192 | |||
e3d6e4db68 | |||
ca2ce556aa | |||
8e922ae0ef | |||
1d4ff8375e | |||
8bd3a165de | |||
1670c3ccf7 | |||
348bcfe0e4 | |||
5850ec847b | |||
829610b13e | |||
f91422a8c4 | |||
12d9e205f7 | |||
d4c3015a22 | |||
f6ea8c04c7 | |||
b7a36a872b | |||
4a4d8a0f2a | |||
2dd81588b2 | |||
7b7460fa0d | |||
478ff37b8a | |||
1840983431 | |||
693edd56fa | |||
a0d60cf0ee | |||
371accc92c | |||
9af012eaaf | |||
870091faaa | |||
2c6cceb60f | |||
32e4dae92e | |||
7ebaa6d2d2 | |||
8bea7dc005 | |||
5107076b2f | |||
3cf15be6de | |||
7e30f706fc | |||
bc39507e48 | |||
9d8e17bd2a | |||
fe2b9f56c0 |
66
README.md
66
README.md
@ -1,43 +1,65 @@
|
||||
# LUG-Helper
|
||||
**Star Citizen's Linux Users Group Helper Script**
|
||||
|
||||
https://robertsspaceindustries.com/orgs/LUG
|
||||
|
||||
*Greetings, fellow Penguin!*
|
||||
### *Greetings, fellow Penguin!*
|
||||
_**This script is designed to help you manage and optimize Star Citizen on Linux.**_
|
||||
|
||||
This script is designed to help you manage and optimize Star Citizen on Linux.
|
||||
Zenity menus are used for a GUI experience with a fallback to terminal-based menus where Zenity is unavailable.
|
||||
Command line arguments are available for quickly launching functions from the terminal.
|
||||
|
||||
Zenity menus are used for a GUI experience with a fallback to terminal-based menus where Zenity is unavailable. The game directory paths provided by the user on first run are saved in *$XDG_CONFIG_HOME/starcitizen-lug*. Keybinds are backed up to *$XDG_CONFIG_HOME/starcitizen-lug/keybinds*
|
||||
Configuration is saved in *$XDG_CONFIG_HOME/starcitizen-lug/*.
|
||||
Keybinds are backed up to *$XDG_CONFIG_HOME/starcitizen-lug/keybinds/*
|
||||
|
||||
## Options:
|
||||
|
||||
`Preflight Check`
|
||||
- Runs a series of system optimization checks and offers to fix any issues.
|
||||
- Checks that vm.max_map_count is set to at least 16777216.
|
||||
- This sets the maxmimum number of "memory map areas" a process can have. While most applications need less than a thousand maps, Star Citizen requires access to more.
|
||||
- Checks that the hard open file descriptors limit is set to at least 524288.
|
||||
- This limits the maximum number of open files on your system. On some Linux distributions, the default is set too low for Star Citizen.
|
||||
|
||||
`Manage Lutris Runners`
|
||||
- Quickly install and delete Lutris wine runners
|
||||
|
||||
`Delete my Star Citizen USER folder and preserve my keybinds`
|
||||
- The helper will make backups of any exported keybinds, delete your Star Citizen USER folder, then restore your keybind files.
|
||||
- To export your keybinds from within the game, go to:
|
||||
`User Folder Maintenance and Troubleshooting`
|
||||
- `Switch the helper between LIVE and PTU`
|
||||
- Toggle between targeting LIVE or PTU for all of the above options. Defaults to LIVE on each run.
|
||||
|
||||
- `Delete my Star Citizen USER folder and preserve my keybinds`
|
||||
- The helper will make backups of any exported keybinds, delete your Star Citizen USER folder, then restore your keybind files.
|
||||
- To export your keybinds from within the game, go to:
|
||||
- *Options->Keybindings->Control Profiles->Save Control Settings*
|
||||
- To re-import your keybinds from within the game, select them from the list:
|
||||
- To re-import your keybinds from within the game, select them from the list:
|
||||
- *Options->Keybindings->Control Profiles*
|
||||
|
||||
`Check vm.max_map_count for optimal performance`
|
||||
- We recommend setting this to at least 16777216 to give the game access to sufficient memory.
|
||||
- The helper will offer to set it for you or show you the commands to do it yourself.
|
||||
- `Delete my shaders only`
|
||||
- Sometimes all you need to do between major version updates is delete your shaders directory.
|
||||
|
||||
`Check my open file descriptors limit`
|
||||
- We recommend setting the hard open files limit to at least 524288.
|
||||
- The helper will offer to set it for you and try to auto-detect the correct method to do so.
|
||||
- It is able to update either */etc/systemd/system.conf* or */etc/security/limits.conf*
|
||||
- `Delete my DXVK cache`
|
||||
- A troubleshooting step that sometimes helps fix various issues and crashes.
|
||||
|
||||
`Delete my shaders only`
|
||||
- Sometimes all you need to do between major version updates is delete your shaders directory.
|
||||
|
||||
`Delete my DXVK cache`
|
||||
- A troubleshooting step that sometimes helps fix various issues and crashes.
|
||||
- `Reset Helper configs`
|
||||
- Delete the configs saved by the helper in *$XDG_CONFIG_HOME/starcitizen-lug/*
|
||||
|
||||
`Get a random Penguin's Star Citizen referral code`
|
||||
- Display a referral code for a random member of the Star Citizen Linux Users Group.
|
||||
|
||||
`Switch the helper between LIVE and PTU`
|
||||
- Toggle between targeting LIVE or PTU for all of the above options. Defaults to LIVE on each run.
|
||||
|
||||
|
||||
## Installation:
|
||||
|
||||
From Source:
|
||||
1. Download it!
|
||||
2. Run it!
|
||||
3. If you want, move *lug-logo.png* to */usr/share/pixmaps/*
|
||||
|
||||
Arch Linux: https://aur.archlinux.org/packages/lug-helper/
|
||||
|
||||
## Contributors:
|
||||
- https://github.com/Termuellinator
|
||||
- https://github.com/pstn
|
||||
- https://github.com/gort818
|
||||
- https://github.com/victort
|
||||
- Runner Downloader inspired by https://github.com/richardtatum/sc-runner-updater
|
||||
|
501
lug-helper.sh
501
lug-helper.sh
@ -41,6 +41,10 @@
|
||||
# Author: https://github.com/the-sane
|
||||
# Contributor: https://github.com/Termuellinator
|
||||
# Contributor: https://github.com/pstn
|
||||
# Contributor: https://github.com/gort818
|
||||
# Contributor: https://github.com/victort
|
||||
# Runner Downloader inspired by:
|
||||
# https://github.com/richardtatum/sc-runner-updater
|
||||
############################################################################
|
||||
|
||||
# Check for dependencies
|
||||
@ -59,19 +63,10 @@ fi
|
||||
|
||||
wine_conf="winedir.conf"
|
||||
game_conf="gamedir.conf"
|
||||
backup_conf="backupdir.conf"
|
||||
|
||||
# Use XDG base directories if defined
|
||||
if [ -z "$XDG_CONFIG_HOME" ]; then
|
||||
conf_dir="$HOME/.config"
|
||||
else
|
||||
conf_dir="$XDG_CONFIG_HOME"
|
||||
fi
|
||||
if [ -z "$XDG_DATA_HOME" ]; then
|
||||
data_dir="$HOME/.local/share"
|
||||
else
|
||||
data_dir="$XDG_DATA_HOME"
|
||||
fi
|
||||
conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
|
||||
# .config subdirectory
|
||||
conf_subdir="starcitizen-lug"
|
||||
@ -105,6 +100,16 @@ max_runners=20
|
||||
# used to dynamically determine the height of menus
|
||||
menu_option_height="25"
|
||||
|
||||
# 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 "lug-logo.png" ]; then
|
||||
lug_logo="lug-logo.png"
|
||||
else
|
||||
lug_logo="info"
|
||||
fi
|
||||
|
||||
############################################################################
|
||||
############################################################################
|
||||
|
||||
@ -152,22 +157,22 @@ message() {
|
||||
fi
|
||||
|
||||
# Use zenity messages if available
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
case "$1" in
|
||||
"info")
|
||||
# info message
|
||||
# call format: message info "text to display"
|
||||
margs=("--info" "--no-wrap" "--text=")
|
||||
margs=("--info" "--window-icon=$lug_logo" "--no-wrap" "--text=")
|
||||
;;
|
||||
"warning")
|
||||
# warning message
|
||||
# call format: message warning "text to display"
|
||||
margs=("--warning" "--text=")
|
||||
margs=("--warning" "--window-icon=$lug_logo" "--text=")
|
||||
;;
|
||||
"question")
|
||||
# question
|
||||
# call format: if message question "question to ask?"; then...
|
||||
margs=("--question" "--text=")
|
||||
margs=("--question" "--window-icon=$lug_logo" "--text=")
|
||||
;;
|
||||
*)
|
||||
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
|
||||
@ -261,7 +266,7 @@ menu() {
|
||||
fi
|
||||
|
||||
# Use Zenity if it is available
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Format the options array for Zenity by adding
|
||||
# TRUE or FALSE to indicate default selections
|
||||
# ie: "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3"
|
||||
@ -277,7 +282,7 @@ menu() {
|
||||
done
|
||||
|
||||
# Display the zenity radio button menu
|
||||
choice="$(zenity --list --radiolist --width="400" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)"
|
||||
choice="$(zenity --list --radiolist --width="480" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --window-icon=$lug_logo --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)"
|
||||
|
||||
# Loop through the options array to match the chosen option
|
||||
matched="false"
|
||||
@ -328,6 +333,12 @@ menu() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Called when the user clicks cancel on a looping menu
|
||||
# Causes a return to the main menu
|
||||
menu_loop_done() {
|
||||
looping_menu="false"
|
||||
}
|
||||
|
||||
# Get paths to the user's wine prefix, game directory, and a backup directory
|
||||
getdirs() {
|
||||
# Sanity checks
|
||||
@ -359,7 +370,7 @@ getdirs() {
|
||||
# ask the user to provide them
|
||||
if [ -z "$wine_prefix" ] || [ -z "$game_path" ]; then
|
||||
message info "At the next screen, please select your Star Citizen WINE prefix.\nIt will be remembered for future use."
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Using Zenity file selection menus
|
||||
# Get the wine prefix directory
|
||||
if [ -z "$wine_prefix" ]; then
|
||||
@ -500,85 +511,69 @@ sanitize() {
|
||||
fi
|
||||
}
|
||||
|
||||
#--------------------- begin preflight check functions -----------------------#
|
||||
#------------------------- begin mapcount functions --------------------------#
|
||||
|
||||
# Check if setting vm.max_map_count was successful
|
||||
mapcount_check() {
|
||||
mapcount_confirm() {
|
||||
if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then
|
||||
message warning "As far as this Helper can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes."
|
||||
preflight_results+=("WARNING: As far as this Helper can detect, vm.max_map_count\nwas not successfully configured on your system.\nYou will most likely experience crashes.")
|
||||
fi
|
||||
}
|
||||
|
||||
# Sets vm.max_map_count for the current session only
|
||||
mapcount_once() {
|
||||
pkexec sh -c 'sysctl -w vm.max_map_count=16777216'
|
||||
mapcount_check
|
||||
preflight_actions+=('sysctl -w vm.max_map_count=16777216')
|
||||
preflight_results+=("vm.max_map_count was changed until the next boot.")
|
||||
preflight_followup+=("mapcount_confirm")
|
||||
}
|
||||
|
||||
# Sets vm.max_map_count to persist between reboots
|
||||
mapcount_persist() {
|
||||
if [ -d "/etc/sysctl.d" ]; then
|
||||
pkexec sh -c 'echo "vm.max_map_count = 16777216" >> /etc/sysctl.d/20-max_map_count.conf && sysctl --system'
|
||||
message info "The necessary configuration has been appended to:\n/etc/sysctl.d/20-max_map_count.conf"
|
||||
else
|
||||
pkexec sh -c 'echo "vm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p'
|
||||
message info "The necessary configuration has been appended to:\n/etc/sysctl.conf"
|
||||
fi
|
||||
mapcount_check
|
||||
}
|
||||
|
||||
# Displays instructions for the user to manually set vm.max_map_count
|
||||
mapcount_manual() {
|
||||
# Set vm.max_map_count
|
||||
mapcount_set() {
|
||||
if [ -d "/etc/sysctl.d" ]; then
|
||||
# Newer versions of sysctl
|
||||
message info "To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.d/20-max_map_count.conf && sysctl --system'"
|
||||
preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216\n" >> /etc/sysctl.d/20-max_map_count.conf && sysctl --system')
|
||||
preflight_results+=("The vm.max_map_count configuration has been appended to:\n/etc/sysctl.d/20-max_map_count.conf")
|
||||
else
|
||||
# Older versions of sysctl
|
||||
message info "To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.conf && sysctl -p'"
|
||||
preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p')
|
||||
preflight_results+=("The vm.max_map_count configuration has been appended to:\n/etc/sysctl.conf")
|
||||
fi
|
||||
|
||||
# Verify that the setting took effect
|
||||
preflight_followup+=("mapcount_confirm")
|
||||
}
|
||||
|
||||
# Check vm.max_map_count for the correct setting and let the user fix it
|
||||
mapcount_set() {
|
||||
# If vm.max_map_count is already set, no need to do anything
|
||||
if [ "$(cat /proc/sys/vm/max_map_count)" -ge 16777216 ]; then
|
||||
message info "vm.max_map_count is already set to the optimal value.\nYou're all set!"
|
||||
return 0
|
||||
# Check vm.max_map_count for the correct setting
|
||||
mapcount_check() {
|
||||
mapcount="$(cat /proc/sys/vm/max_map_count)"
|
||||
# Add to the results and actions arrays
|
||||
if [ "$mapcount" -ge 16777216 ]; then
|
||||
# All good
|
||||
preflight_pass+=("vm.max_map_count is set to at least 16777216.")
|
||||
elif grep -E -x -q "vm.max_map_count" /etc/sysctl.conf /etc/sysctl.d/* 2>/dev/null; then
|
||||
# Was it supposed to have been set by sysctl?
|
||||
preflight_fail+=("vm.max_map_count is configured to at least 16777216 but the setting has not been loaded by your system.")
|
||||
# Add the function that will be called to change the configuration
|
||||
preflight_action_funcs+=("mapcount_once")
|
||||
|
||||
# Add info for manually changing the setting
|
||||
preflight_manual+=("To change vm.max_map_count until the next reboot, run:\nsudo sysctl -w vm.max_map_count=16777216")
|
||||
else
|
||||
# The setting should be changed
|
||||
preflight_fail+=("vm.max_map_count is $mapcount\nand should be set to at least 16777216\nto give the game access to sufficient memory.")
|
||||
# Add the function that will be called to change the configuration
|
||||
preflight_action_funcs+=("mapcount_set")
|
||||
|
||||
# Add info for manually changing the setting
|
||||
if [ -d "/etc/sysctl.d" ]; then
|
||||
# Newer versions of sysctl
|
||||
preflight_manual+=("To change vm.max_map_count permanently, add the following line to\n'/etc/sysctl.d/20-max_map_count.conf' and reload with 'sudo sysctl --system':\n vm.max_map_count = 16777216\n\nOr, to change vm.max_map_count temporarily until next boot, run:\n sudo sysctl -w vm.max_map_count=16777216")
|
||||
else
|
||||
# Older versions of sysctl
|
||||
preflight_manual+=("To change vm.max_map_count permanently, add the following line to\n'/etc/sysctl.conf' and reload with 'sudo sysctl -p':\n vm.max_map_count = 16777216\n\nOr, to change vm.max_map_count temporarily until next boot, run:\n sudo sysctl -w vm.max_map_count=16777216")
|
||||
fi
|
||||
|
||||
# Otherwise, check to see if it was supposed to be set by sysctl
|
||||
if grep -E -x -q "vm.max_map_count" /etc/sysctl.conf /etc/sysctl.d/* 2>/dev/null; then
|
||||
if message question "It looks like you've already configured vm.max_map_count\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then
|
||||
pkexec sh -c 'sysctl -w vm.max_map_count=16777216'
|
||||
fi
|
||||
mapcount_check
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Configure the menu
|
||||
menu_text_zenity="<b>This Helper can change vm.max_map_count for you</b>\n\nChoose from the following options:"
|
||||
menu_text_terminal="This Helper can change vm.max_map_count for you\n\nChoose from the following options:"
|
||||
menu_text_height="100"
|
||||
|
||||
# Configure the menu options
|
||||
once="Change setting until next reboot"
|
||||
persist="Change setting and persist after reboot"
|
||||
manual="Show me the commands; I'll handle it myself"
|
||||
goback="Return to the main menu"
|
||||
|
||||
# Set the options to be displayed in the menu
|
||||
menu_options=("$once" "$persist" "$manual" "$goback")
|
||||
# Set the corresponding functions to be called for each of the options
|
||||
menu_actions=("mapcount_once" "mapcount_persist" "mapcount_manual" "mapcount_check")
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(("$menu_option_height" * "${#menu_options[@]}" + "$menu_text_height"))"
|
||||
|
||||
# Display an informational message to the user
|
||||
message info "Running Star Citizen requires changing a system setting\nto give the game access to more than 8GB of memory.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\n\nAs far as this Helper can detect, the setting\nhas not been changed on your system.\n\nYou will now be given the option to change it."
|
||||
|
||||
# Call the menu function. It will use the options as configured above
|
||||
menu
|
||||
}
|
||||
|
||||
#-------------------------- end mapcount functions ---------------------------#
|
||||
@ -586,47 +581,83 @@ mapcount_set() {
|
||||
#------------------------ begin filelimit functions --------------------------#
|
||||
|
||||
# Check if setting the open file descriptors limit was successful
|
||||
filelimit_check() {
|
||||
filelimit_confirm() {
|
||||
if [ "$(ulimit -Hn)" -lt 524288 ]; then
|
||||
message warning "As far as this Helper can detect, the open files limit\nwas not successfully configured on your system.\nYou may experience crashes.\n\nWe recommend manually configuring this limit to at least 524288."
|
||||
preflight_results+=("WARNING: As far as this Helper can detect, the open files limit\nwas not successfully configured on your system.\nYou may experience crashes.")
|
||||
fi
|
||||
}
|
||||
|
||||
# Check the open file descriptors limit and let the user fix it if needed
|
||||
# Set the open file descriptors limit
|
||||
filelimit_set() {
|
||||
filelimit="$(ulimit -Hn)"
|
||||
|
||||
# If the file limit is already set, no need to do anything
|
||||
if [ "$filelimit" -ge 524288 ]; then
|
||||
message info "Your open files limit is already set to the optimal value.\nYou're all set!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Adjust the limit
|
||||
if message question "We recommend setting the hard open\nfile descriptors limit to at least 524288.\n\nThe current value on your system appears to be $filelimit.\n\nWould you like this Helper to change it for you?"; then
|
||||
if [ -f "/etc/systemd/system.conf" ]; then
|
||||
# Using systemd
|
||||
# Append to the file
|
||||
pkexec sh -c 'echo "DefaultLimitNOFILE=524288" >> /etc/systemd/system.conf && systemctl daemon-reexec'
|
||||
message info "The necessary configuration has been appended to:\n/etc/systemd/system.conf"
|
||||
preflight_actions+=('printf "\n# Added by LUG-Helper:\nDefaultLimitNOFILE=524288\n" >> /etc/systemd/system.conf && systemctl daemon-reexec')
|
||||
preflight_results+=("The open files limit configuration has been appended to:\n/etc/systemd/system.conf")
|
||||
elif [ -f "/etc/security/limits.conf" ]; then
|
||||
# Using limits.conf
|
||||
# Insert before the last line in the file
|
||||
pkexec sh -c 'sed -i "\$i* hard nofile 524288" /etc/security/limits.conf'
|
||||
message info "The necessary configuration has been appended to:\n/etc/security/limits.conf"
|
||||
preflight_actions+=('sed -i "\$i#Added by LUG-Helper:" /etc/security/limits.conf; sed -i "\$i* hard nofile 524288" /etc/security/limits.conf')
|
||||
preflight_results+=("The open files limit configuration has been appended to:\n/etc/security/limits.conf")
|
||||
else
|
||||
# Don't know what method to use
|
||||
message warning "This Helper is unable to detect the correct method of setting\nthe open file descriptors limit on your system.\n\nWe recommend manually configuring this limit to at least 524288."
|
||||
return 0
|
||||
fi
|
||||
preflight_results+=("This Helper is unable to detect the correct method of setting\nthe open file descriptors limit on your system.\n\nWe recommend manually configuring this limit to at least 524288.")
|
||||
fi
|
||||
|
||||
# Verify that setting the limit was successful
|
||||
filelimit_check
|
||||
preflight_followup+=("filelimit_confirm")
|
||||
}
|
||||
|
||||
# Check the open file descriptors limit
|
||||
filelimit_check() {
|
||||
filelimit="$(ulimit -Hn)"
|
||||
|
||||
# Add to the results and actions arrays
|
||||
if [ "$filelimit" -ge 524288 ]; then
|
||||
# All good
|
||||
preflight_pass+=("Hard open file descriptors limit is set to at least 524288.")
|
||||
else
|
||||
# The file limit should be changed
|
||||
preflight_fail+=("Your hard open file descriptors limit is $filelimit\nand should be set to at least 524288\nto increase the maximum number of open files.")
|
||||
# Add the function that will be called to change the configuration
|
||||
preflight_action_funcs+=("filelimit_set")
|
||||
|
||||
# Add info for manually changing the settings
|
||||
if [ -f "/etc/systemd/system.conf" ]; then
|
||||
# Using systemd
|
||||
preflight_manual+=("To change your open file descriptors limit, add the following line to\n'/etc/systemd/system.conf':\n DefaultLimitNOFILE=524288")
|
||||
elif [ -f "/etc/security/limits.conf" ]; then
|
||||
# Using limits.conf
|
||||
preflight_manual+=("To change your open file descriptors limit, add the following line to\n'/etc/security/limits.conf':\n * hard nofile 524288")
|
||||
else
|
||||
# Don't know what method to use
|
||||
preflight_manual+=("This Helper is unable to detect the correct method of setting\nthe open file descriptors limit on your system.\n\nWe recommend manually configuring this limit to at least 524288.")
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#------------------------- end filelimit functions ---------------------------#
|
||||
|
||||
# Check total system memory
|
||||
memory_check() {
|
||||
memtotal="$(awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
|
||||
if [ ${memtotal%.*} -ge "15" ]; then
|
||||
preflight_pass+=("Your system has $memtotal GB of memory.")
|
||||
else
|
||||
preflight_fail+=("Your system has $memtotal GB of memory.\nWe recommend at least 16 GB to avoid crashes.")
|
||||
fi
|
||||
}
|
||||
|
||||
# Check CPU for the required AVX extension
|
||||
avx_check() {
|
||||
if grep -q "avx" /proc/cpuinfo; then
|
||||
preflight_pass+=("Your CPU supports the necessary AVX instruction set.")
|
||||
else
|
||||
preflight_fail+=("Your CPU does not appear to support AVX instructions.\nThis requirement was added to Star Citizen in version 3.11")
|
||||
fi
|
||||
}
|
||||
|
||||
#------------------------- end preflight check functions ---------------------#
|
||||
|
||||
# Delete the shaders directory
|
||||
rm_shaders() {
|
||||
@ -654,7 +685,7 @@ rm_shaders() {
|
||||
}
|
||||
|
||||
# Delete DXVK cache
|
||||
rm_vidcache() {
|
||||
rm_dxvkcache() {
|
||||
# Get/Set directory paths
|
||||
getdirs
|
||||
if [ "$?" -eq 1 ]; then
|
||||
@ -737,7 +768,7 @@ runner_select_delete() {
|
||||
menu_actions+=(":") # no-op
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(("$menu_option_height" * "${#menu_options[@]}" + "$menu_text_height"))"
|
||||
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
|
||||
if [ "$menu_height" -gt "400" ]; then
|
||||
menu_height="400"
|
||||
fi
|
||||
@ -791,7 +822,7 @@ runner_install() {
|
||||
|
||||
# Download the runner to the tmp directory
|
||||
debug_print continue "Downloading $runner_dl_url into $tmp_dir/$runner_file..."
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Format the curl progress bar for zenity
|
||||
mkfifo "$tmp_dir/lugpipe"
|
||||
cd "$tmp_dir" && curl -#LO "$runner_dl_url" > "$tmp_dir/lugpipe" 2>&1 & curlpid="$!"
|
||||
@ -830,7 +861,7 @@ runner_install() {
|
||||
# If the files in the archive begin with ./ there is no subdirectory
|
||||
./*)
|
||||
debug_print continue "Installing runner into $runners_dir/$runner_name..."
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Use Zenity progress bar
|
||||
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name" | \
|
||||
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing runner...\n" 2>/dev/null
|
||||
@ -842,7 +873,7 @@ runner_install() {
|
||||
*)
|
||||
# Runners with a subdirectory in the archive
|
||||
debug_print continue "Installing runner into $runners_dir..."
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Use Zenity progress bar
|
||||
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir" | \
|
||||
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing runner...\n" 2>/dev/null
|
||||
@ -885,7 +916,7 @@ runner_select_install() {
|
||||
# To add new sources, handle them here, in the if statement
|
||||
# just above, and the runner_install function above
|
||||
if [ "$runner_url_type" = "github" ]; then
|
||||
runner_versions=($(curl -s "$contributor_url" | grep "browser_download_url" | awk '{print $2}' | xargs basename -a))
|
||||
runner_versions=($(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | xargs basename -a))
|
||||
else
|
||||
debug_print exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
||||
fi
|
||||
@ -936,7 +967,7 @@ runner_select_install() {
|
||||
menu_actions+=(":") # no-op
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(("$menu_option_height" * "${#menu_options[@]}" + "$menu_text_height"))"
|
||||
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
|
||||
if [ "$menu_height" -gt "400" ]; then
|
||||
menu_height="400"
|
||||
fi
|
||||
@ -945,12 +976,6 @@ runner_select_install() {
|
||||
menu
|
||||
}
|
||||
|
||||
# Called when the user is done managing runners
|
||||
# Causes a return to the main menu
|
||||
runner_manage_done() {
|
||||
managing_runners="false"
|
||||
}
|
||||
|
||||
# Manage Lutris runners
|
||||
runner_manage() {
|
||||
# Check if Lutris is installed
|
||||
@ -964,13 +989,12 @@ runner_manage() {
|
||||
fi
|
||||
|
||||
# The runner management menu will loop until the user cancels
|
||||
managing_runners="true"
|
||||
|
||||
while [ "$managing_runners" = "true" ]; do
|
||||
looping_menu="true"
|
||||
while [ "$looping_menu" = "true" ]; do
|
||||
# Configure the menu
|
||||
menu_text_zenity="<b>This Helper can manage your Lutris runners</b>\n\nChoose from the following options:"
|
||||
menu_text_terminal="This Helper can manage your Lutris runners<\n\nChoose from the following options:"
|
||||
menu_text_height="100"
|
||||
menu_text_zenity="<b><big>Manage Your Lutris Runners</big>\n\nThe runners listed below are wine builds created for Star Citizen</b>\n\nYou may choose from the following options:"
|
||||
menu_text_terminal="Manage Your Lutris Runners\n\nThe runners listed below are wine builds created for Star Citizen\nYou may choose from the following options:"
|
||||
menu_text_height="140"
|
||||
|
||||
# Configure the menu options
|
||||
delete="Remove an installed runner"
|
||||
@ -990,10 +1014,10 @@ runner_manage() {
|
||||
# Complete the menu by adding options to remove a runner
|
||||
# or go back to the previous menu
|
||||
menu_options+=("$delete" "$back")
|
||||
menu_actions+=("runner_select_delete" "runner_manage_done")
|
||||
menu_actions+=("runner_select_delete" "menu_loop_done")
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(("$menu_option_height" * "${#menu_options[@]}" + "$menu_text_height"))"
|
||||
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
|
||||
|
||||
# Call the menu function. It will use the options as configured above
|
||||
menu
|
||||
@ -1005,11 +1029,143 @@ runner_manage() {
|
||||
|
||||
#-------------------------- end runner functions -----------------------------#
|
||||
|
||||
# Check that the system is optimized for Star Citizen
|
||||
preflight_check() {
|
||||
# Initialize variables
|
||||
unset preflight_pass
|
||||
unset preflight_fail
|
||||
unset preflight_action_funcs
|
||||
unset preflight_actions
|
||||
unset preflight_results
|
||||
unset preflight_manual
|
||||
unset preflight_followup
|
||||
|
||||
# Call the optimization functions to perform the checks
|
||||
memory_check
|
||||
avx_check
|
||||
mapcount_check
|
||||
filelimit_check
|
||||
|
||||
# Populate info strings with the results and add formatting
|
||||
if [ "${#preflight_pass[@]}" -gt 0 ]; then
|
||||
preflight_pass_string="Passed Checks:"
|
||||
for (( i=0; i<"${#preflight_pass[@]}"; i++ )); do
|
||||
preflight_pass_string="$preflight_pass_string\n- ${preflight_pass[i]//\\n/\\n }"
|
||||
done
|
||||
# Add extra newlines if there are also failures to report
|
||||
if [ "${#preflight_fail[@]}" -gt 0 ]; then
|
||||
preflight_pass_string="$preflight_pass_string\n\n"
|
||||
fi
|
||||
fi
|
||||
if [ "${#preflight_fail[@]}" -gt 0 ]; then
|
||||
preflight_fail_string="Failed Checks:"
|
||||
for (( i=0; i<"${#preflight_fail[@]}"; i++ )); do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
preflight_fail_string="$preflight_fail_string\n- ${preflight_fail[i]//\\n/\\n }"
|
||||
else
|
||||
preflight_fail_string="$preflight_fail_string\n\n- ${preflight_fail[i]//\\n/\\n }"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
for (( i=0; i<"${#preflight_manual[@]}"; i++ )); do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
preflight_manual_string="${preflight_manual[i]}"
|
||||
else
|
||||
preflight_manual_string="$preflight_manual_string\n\n${preflight_manual[i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Display the results of the preflight check
|
||||
if [ -z "$preflight_fail_string" ]; then
|
||||
message info "Preflight Check Complete\n\nYour system is optimized for Star Citizen!\n\n$preflight_pass_string"
|
||||
else
|
||||
if [ -z "$preflight_action_funcs" ]; then
|
||||
message warning "$preflight_pass_string$preflight_fail_string"
|
||||
elif message question "$preflight_pass_string$preflight_fail_string\n\nWould you like configuration issues to be fixed for you?"; then
|
||||
# Call functions to build fixes for any issues found
|
||||
for (( i=0; i<"${#preflight_action_funcs[@]}"; i++ )); do
|
||||
${preflight_action_funcs[i]}
|
||||
done
|
||||
# Populate a string of actions to be executed
|
||||
for (( i=0; i<"${#preflight_actions[@]}"; i++ )); do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
preflight_actions_string="${preflight_actions[i]}"
|
||||
else
|
||||
preflight_actions_string="$preflight_actions_string; ${preflight_actions[i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Execute the actions set by the functions
|
||||
if [ ! -z "$preflight_actions_string" ]; then
|
||||
# Use pollkit's pkexec for gui with a fallback to sudo
|
||||
if [ -x "$(command -v pkexec)" ]; then
|
||||
pkexec sh -c "$preflight_actions_string"
|
||||
else
|
||||
sudo sh -c "$preflight_actions_string"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Call any followup functions
|
||||
for (( i=0; i<"${#preflight_followup[@]}"; i++ )); do
|
||||
${preflight_followup[i]}
|
||||
done
|
||||
|
||||
# Populate the results string
|
||||
for (( i=0; i<"${#preflight_results[@]}"; i++ )); do
|
||||
if [ "$i" -eq 0 ]; then
|
||||
preflight_results_string="${preflight_results[i]}"
|
||||
else
|
||||
preflight_results_string="$preflight_results_string\n\n${preflight_results[i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Display the results
|
||||
message info "$preflight_results_string"
|
||||
else
|
||||
# User declined to automatically fix configuration issues
|
||||
# Show manual configuration options
|
||||
if [ ! -z "$preflight_manual_string" ]; then
|
||||
message info "$preflight_manual_string"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Show maintenance/troubleshooting options
|
||||
maintenance_menu() {
|
||||
# Loop the menu until the user selects quit
|
||||
looping_menu="true"
|
||||
while [ "$looping_menu" = "true" ]; do
|
||||
# Configure the menu
|
||||
menu_text_zenity="<b><big>Game Maintenance and Troubleshooting</big></b>\n\nYou may choose from the following options:"
|
||||
menu_text_terminal="Game Maintenance and Troubleshooting\n\nYou may choose from the following options:"
|
||||
menu_text_height="100"
|
||||
|
||||
# Configure the menu options
|
||||
version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)"
|
||||
sanitize_msg="Delete my Star Citizen USER folder and preserve my keybinds"
|
||||
shaders_msg="Delete my shaders folder only (Do this after each game update)"
|
||||
vidcache_msg="Delete my DXVK cache"
|
||||
reset_msg="Reset Helper configs"
|
||||
quit_msg="Return to the main menu"
|
||||
|
||||
# Set the options to be displayed in the menu
|
||||
menu_options=("$version_msg" "$sanitize_msg" "$shaders_msg" "$vidcache_msg" "$reset_msg" "$quit_msg")
|
||||
# Set the corresponding functions to be called for each of the options
|
||||
menu_actions=("set_version" "sanitize" "rm_shaders" "rm_dxvkcache" "reset_helper" "menu_loop_done")
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
|
||||
|
||||
# Call the menu function. It will use the options as configured above
|
||||
menu
|
||||
done
|
||||
}
|
||||
|
||||
# Get a random Penguin's Star Citizen referral code
|
||||
referral_randomizer() {
|
||||
# Populate the referral codes array
|
||||
referral_codes=("STAR-4TZD-6KMM" "STAR-4XM2-VM99" "STAR-2NPY-FCR2" "STAR-T9Z9-7W6P" "STAR-VLBF-W2QR" "STAR-BYR6-YHMF" "STAR-3X2H-VZMX" "STAR-BRWN-FB9T" "STAR-FG6Y-N4Q4" "STAR-VLD6-VZRG" "STAR-T9KF-LV77" "STAR-4XHB-R7RF" "STAR-9NVF-MRN7" "STAR-3Q4W-9TC3" "STAR-3SBK-7QTT" "STAR-XFBT-9TTK" "STAR-F3H9-YPHN" "STAR-BYK6-RCCL" "STAR-XCKH-W6T7" "STAR-H292-39WK" "STAR-ZRT5-PJB7")
|
||||
referral_codes=("STAR-4TZD-6KMM" "STAR-4XM2-VM99" "STAR-2NPY-FCR2" "STAR-T9Z9-7W6P" "STAR-VLBF-W2QR" "STAR-BYR6-YHMF" "STAR-3X2H-VZMX" "STAR-BRWN-FB9T" "STAR-FG6Y-N4Q4" "STAR-VLD6-VZRG" "STAR-T9KF-LV77" "STAR-4XHB-R7RF" "STAR-9NVF-MRN7" "STAR-3Q4W-9TC3" "STAR-3SBK-7QTT" "STAR-XFBT-9TTK" "STAR-F3H9-YPHN" "STAR-BYK6-RCCL" "STAR-XCKH-W6T7" "STAR-H292-39WK" "STAR-ZRT5-PJB7" "STAR-GMBP-SH9Y" "STAR-PLWB-LMFY" "STAR-TNZN-H4ZT")
|
||||
# Pick a random array element. Scale a floating point number for
|
||||
# a more random distribution than simply calling RANDOM
|
||||
random_code="${referral_codes[$(awk '{srand($2); print int(rand()*$1)}' <<< "${#referral_codes[@]} $RANDOM")]}"
|
||||
@ -1051,15 +1207,101 @@ quit() {
|
||||
############################################################################
|
||||
|
||||
# Check if Zenity is available
|
||||
has_zen=0
|
||||
use_zenity=0
|
||||
if [ -x "$(command -v zenity)" ]; then
|
||||
has_zen=1
|
||||
use_zenity=1
|
||||
fi
|
||||
|
||||
# Set some defaults
|
||||
live_or_ptu="LIVE"
|
||||
lutris_needs_restart="false"
|
||||
|
||||
# If invoked with command line arguments, process them and exit
|
||||
if [ "$#" -gt 0 ]; then
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
# Victor_Tramp expects the spanish inquisition.
|
||||
case "$1" in
|
||||
--help | -h )
|
||||
printf "Star Citizen Linux Users Group Helper Script
|
||||
Usage: lug-helper <options>
|
||||
-p, --preflight-check Run system optimization checks
|
||||
-m, --manage-runners Install or remove Lutris runners
|
||||
-u, --delete-user-folder Delete Star Citizen USER folder, preserving keybinds
|
||||
-s, --delete-shaders Delete Star Citizen shaders directory
|
||||
-c, --delete-dxvk-cache Delete Star Citizen dxvk cache file
|
||||
-t, --target=[live|ptu] Target LIVE or PTU (default live)
|
||||
-g, --use-gui=[yes|no] Use Zenity GUI (default yes)
|
||||
-r, --get-referral Get a random LUG member's Star Citizen referral code
|
||||
-x, --reset-helper Delete saved lug-helper configs
|
||||
"
|
||||
exit 0
|
||||
;;
|
||||
--preflight-check | -p )
|
||||
cargs+=("preflight_check")
|
||||
;;
|
||||
--manage-runners | -m )
|
||||
cargs+=("runner_manage")
|
||||
;;
|
||||
--delete-user-folder | -u )
|
||||
cargs+=("sanitize")
|
||||
;;
|
||||
--delete-shaders | -s )
|
||||
cargs+=("rm_shaders")
|
||||
;;
|
||||
--delete-dxvk-cache | -c )
|
||||
cargs+=("rm_dxvkcache")
|
||||
;;
|
||||
--target=* | -t=* )
|
||||
live_or_ptu="$(echo "$1" | cut -d'=' -f2)"
|
||||
if [ "$live_or_ptu" = "live" ] || [ "$live_or_ptu" = "LIVE" ]; then
|
||||
live_or_ptu="LIVE"
|
||||
elif [ "$live_or_ptu" = "ptu" ] || [ "$live_or_ptu" = "PTU" ]; then
|
||||
live_or_ptu="PTU"
|
||||
else
|
||||
printf "$0: Invalid option '$1'\n"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
--use-gui=* | -g=* )
|
||||
# If zenity is unavailable, it has already been set to 0
|
||||
# and this setting has no effect
|
||||
if [ -x "$(command -v zenity)" ]; then
|
||||
use_zenity="$(echo "$1" | cut -d'=' -f2)"
|
||||
if [ "$use_zenity" = "yes" ] || [ "$use_zenity" = "YES" ] || [ "$use_zenity" = "1" ]; then
|
||||
use_zenity=1
|
||||
elif [ "$use_zenity" = "no" ] || [ "$use_zenity" = "NO" ] || [ "$use_zenity" = "0" ]; then
|
||||
use_zenity=0
|
||||
else
|
||||
printf "$0: Invalid option '$1'\n"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
--get-referral | -r )
|
||||
cargs+=("referral_randomizer")
|
||||
;;
|
||||
--reset-helper | -x )
|
||||
cargs+=("reset_helper")
|
||||
;;
|
||||
* )
|
||||
printf "$0: Invalid option '$1'\n"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
# Shift forward to the next argument and loop again
|
||||
shift
|
||||
done
|
||||
|
||||
# Call the requested functions and exit
|
||||
if [ "${#cargs[@]}" -gt 0 ]; then
|
||||
for (( i=0; i<"${#cargs[@]}"; i++ )); do
|
||||
${cargs[i]}
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Loop the main menu until the user selects quit
|
||||
while true; do
|
||||
# Configure the menu
|
||||
@ -1068,24 +1310,19 @@ while true; do
|
||||
menu_text_height="140"
|
||||
|
||||
# Configure the menu options
|
||||
preflight_msg="Preflight Check (System Optimization)"
|
||||
runners_msg="Manage Lutris Runners"
|
||||
sanitize_msg="Delete my Star Citizen USER folder and preserve my keybinds"
|
||||
shaders_msg="Delete my shaders folder only (Do this after each game update)"
|
||||
vidcache_msg="Delete my DXVK cache"
|
||||
version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)"
|
||||
mapcount_msg="Check vm.max_map_count for optimal performance"
|
||||
filelimit_msg="Check my open file descriptors limit"
|
||||
maintenance_msg="User Folder Maintenance and Troubleshooting"
|
||||
randomizer_msg="Get a random Penguin's Star Citizen referral code"
|
||||
reset_msg="Reset Helper"
|
||||
quit_msg="Quit"
|
||||
|
||||
# Set the options to be displayed in the menu
|
||||
menu_options=("$runners_msg" "$sanitize_msg" "$shaders_msg" "$vidcache_msg" "$version_msg" "$mapcount_msg" "$filelimit_msg" "$randomizer_msg" "$reset_msg" "$quit_msg")
|
||||
menu_options=("$preflight_msg" "$runners_msg" "$maintenance_msg" "$randomizer_msg" "$quit_msg")
|
||||
# Set the corresponding functions to be called for each of the options
|
||||
menu_actions=("runner_manage" "sanitize" "rm_shaders" "rm_vidcache" "set_version" "mapcount_set" "filelimit_set" "referral_randomizer" "reset_helper" "quit")
|
||||
menu_actions=("preflight_check" "runner_manage" "maintenance_menu" "referral_randomizer" "quit")
|
||||
|
||||
# Calculate the total height the menu should be
|
||||
menu_height="$(("$menu_option_height" * "${#menu_options[@]}" + "$menu_text_height"))"
|
||||
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
|
||||
|
||||
# Call the menu function. It will use the options as configured above
|
||||
menu
|
||||
|
BIN
lug-logo.png
Normal file
BIN
lug-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
Reference in New Issue
Block a user