mirror of
https://github.com/the-sane/lug-helper.git
synced 2024-12-28 16:34:21 +00:00
Rearrange some functions
This commit is contained in:
parent
227038a289
commit
49079818f6
370
lug-helper.sh
370
lug-helper.sh
@ -611,6 +611,17 @@ sanitize() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Restart lutris
|
||||||
|
lutris_restart() {
|
||||||
|
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep lutris)" ]; then
|
||||||
|
if message question "Lutris must be restarted to detect the changes.\nWould you like this Helper to restart it for you?"; then
|
||||||
|
debug_print continue "Restarting Lutris..."
|
||||||
|
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
lutris_needs_restart="false"
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------- begin preflight check functions -----------------------#
|
#--------------------- begin preflight check functions -----------------------#
|
||||||
#------------------------- begin mapcount functions --------------------------#
|
#------------------------- begin mapcount functions --------------------------#
|
||||||
|
|
||||||
@ -766,85 +777,117 @@ avx_check() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------- end preflight check 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
|
||||||
|
wine_check
|
||||||
|
memory_check
|
||||||
|
avx_check
|
||||||
|
mapcount_check
|
||||||
|
filelimit_check
|
||||||
|
|
||||||
# Install Star Citizen using Lutris
|
# Populate info strings with the results and add formatting
|
||||||
install_game() {
|
if [ "${#preflight_pass[@]}" -gt 0 ]; then
|
||||||
# Check if Lutris is installed
|
preflight_pass_string="Passed Checks:"
|
||||||
if [ ! -x "$(command -v lutris)" ]; then
|
for (( i=0; i<"${#preflight_pass[@]}"; i++ )); do
|
||||||
message warning "Lutris is required but does not appear to be installed."
|
preflight_pass_string="$preflight_pass_string\n- ${preflight_pass[i]//\\n/\\n }"
|
||||||
return 0
|
done
|
||||||
fi
|
# Add extra newlines if there are also failures to report
|
||||||
# Check if the install script exists
|
if [ "${#preflight_fail[@]}" -gt 0 ]; then
|
||||||
if [ ! -f "$install_script" ]; then
|
preflight_pass_string="$preflight_pass_string\n\n"
|
||||||
message warning "Lutris install script not found.\n\n$install_script\n\nIt is included in our official releases here:\n$releases_url"
|
fi
|
||||||
return 0
|
fi
|
||||||
fi
|
if [ "${#preflight_fail[@]}" -gt 0 ]; then
|
||||||
|
preflight_fail_string="Failed Checks:"
|
||||||
if message question "Before proceeding, please refer to our Quick Start Guide:\n\n$lug_wiki\n\nAre you ready to continue?"; then
|
for (( i=0; i<"${#preflight_fail[@]}"; i++ )); do
|
||||||
lutris --install "$install_script" &
|
if [ "$i" -eq 0 ]; then
|
||||||
message info "The installation will continue in Lutris"
|
preflight_fail_string="$preflight_fail_string\n- ${preflight_fail[i]//\\n/\\n }"
|
||||||
fi
|
else
|
||||||
}
|
preflight_fail_string="$preflight_fail_string\n\n- ${preflight_fail[i]//\\n/\\n }"
|
||||||
|
fi
|
||||||
# Delete the shaders directory
|
done
|
||||||
rm_shaders() {
|
fi
|
||||||
# Get/Set directory paths
|
for (( i=0; i<"${#preflight_manual[@]}"; i++ )); do
|
||||||
getdirs
|
if [ "$i" -eq 0 ]; then
|
||||||
if [ "$?" -eq 1 ]; then
|
preflight_manual_string="${preflight_manual[i]}"
|
||||||
# User cancelled and wants to return to the main menu, or error
|
else
|
||||||
return 0
|
preflight_manual_string="$preflight_manual_string\n\n${preflight_manual[i]}"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
# Sanity check
|
|
||||||
if [ ! -d "$shaders_dir" ]; then
|
# Display the results of the preflight check
|
||||||
message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir"
|
if [ -z "$preflight_fail_string" ]; then
|
||||||
return 0
|
# Formatting
|
||||||
fi
|
message_heading="Preflight Check Complete"
|
||||||
|
if [ "$use_zenity" -eq 1 ]; then
|
||||||
# Delete the shader directory
|
message_heading="<b>$message_heading</b>"
|
||||||
if message question "The following directory will be deleted:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
fi
|
||||||
debug_print continue "Deleting $shaders_dir..."
|
|
||||||
rm -r "$shaders_dir"
|
message info "$message_heading\n\nYour system is optimized for Star Citizen!\n\n$preflight_pass_string"
|
||||||
message info "Your shaders have been deleted!"
|
else
|
||||||
fi
|
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
|
||||||
# Delete DXVK cache
|
# Call functions to build fixes for any issues found
|
||||||
rm_dxvkcache() {
|
for (( i=0; i<"${#preflight_action_funcs[@]}"; i++ )); do
|
||||||
# Get/Set directory paths
|
${preflight_action_funcs[i]}
|
||||||
getdirs
|
done
|
||||||
if [ "$?" -eq 1 ]; then
|
# Populate a string of actions to be executed
|
||||||
# User cancelled and wants to return to the main menu
|
for (( i=0; i<"${#preflight_actions[@]}"; i++ )); do
|
||||||
# or there was an error
|
if [ "$i" -eq 0 ]; then
|
||||||
return 0
|
preflight_actions_string="${preflight_actions[i]}"
|
||||||
fi
|
else
|
||||||
|
preflight_actions_string="$preflight_actions_string; ${preflight_actions[i]}"
|
||||||
# Sanity check
|
fi
|
||||||
if [ ! -f "$dxvk_cache" ]; then
|
done
|
||||||
message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache"
|
|
||||||
return 0
|
# Execute the actions set by the functions
|
||||||
fi
|
if [ ! -z "$preflight_actions_string" ]; then
|
||||||
|
# Use pollkit's pkexec for gui with a fallback to sudo
|
||||||
# Delete the cache file
|
if [ -x "$(command -v pkexec)" ]; then
|
||||||
if message question "The following file will be deleted:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
pkexec sh -c "$preflight_actions_string"
|
||||||
debug_print continue "Deleting $dxvk_cache..."
|
else
|
||||||
rm "$dxvk_cache"
|
sudo sh -c "$preflight_actions_string"
|
||||||
message info "Your DXVK cache has been deleted!"
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
# Call any followup functions
|
||||||
# Restart lutris
|
for (( i=0; i<"${#preflight_followup[@]}"; i++ )); do
|
||||||
lutris_restart() {
|
${preflight_followup[i]}
|
||||||
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep lutris)" ]; then
|
done
|
||||||
if message question "Lutris must be restarted to detect the changes.\nWould you like this Helper to restart it for you?"; then
|
|
||||||
debug_print continue "Restarting Lutris..."
|
# Populate the results string
|
||||||
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
|
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
|
||||||
fi
|
fi
|
||||||
lutris_needs_restart="false"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------- end preflight check functions ---------------------#
|
||||||
|
|
||||||
#------------------------- begin download functions ----------------------------#
|
#------------------------- begin download functions ----------------------------#
|
||||||
|
|
||||||
# Display post download message or instructions if needed
|
# Display post download message or instructions if needed
|
||||||
@ -1260,8 +1303,6 @@ download_manage() {
|
|||||||
lutris_restart
|
lutris_restart
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------- end download functions -----------------------------#
|
|
||||||
|
|
||||||
# Configure the download_manage function for runners
|
# Configure the download_manage function for runners
|
||||||
runner_manage() {
|
runner_manage() {
|
||||||
# Set some defaults
|
# Set some defaults
|
||||||
@ -1324,116 +1365,7 @@ dxvk_manage() {
|
|||||||
download_manage "dxvk"
|
download_manage "dxvk"
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------- end dxvk functions -----------------------------#
|
#-------------------------- end download 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
|
|
||||||
wine_check
|
|
||||||
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
|
|
||||||
# Formatting
|
|
||||||
message_heading="Preflight Check Complete"
|
|
||||||
if [ "$use_zenity" -eq 1 ]; then
|
|
||||||
message_heading="<b>$message_heading</b>"
|
|
||||||
fi
|
|
||||||
|
|
||||||
message info "$message_heading\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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Deploy Easy Anti-Cheat Workaround
|
# Deploy Easy Anti-Cheat Workaround
|
||||||
eac_workaround() {
|
eac_workaround() {
|
||||||
@ -1482,6 +1414,72 @@ eac_workaround() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install Star Citizen using Lutris
|
||||||
|
install_game() {
|
||||||
|
# Check if Lutris is installed
|
||||||
|
if [ ! -x "$(command -v lutris)" ]; then
|
||||||
|
message warning "Lutris is required but does not appear to be installed."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# Check if the install script exists
|
||||||
|
if [ ! -f "$install_script" ]; then
|
||||||
|
message warning "Lutris install script not found.\n\n$install_script\n\nIt is included in our official releases here:\n$releases_url"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if message question "Before proceeding, please refer to our Quick Start Guide:\n\n$lug_wiki\n\nAre you ready to continue?"; then
|
||||||
|
lutris --install "$install_script" &
|
||||||
|
message info "The installation will continue in Lutris"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Delete the shaders directory
|
||||||
|
rm_shaders() {
|
||||||
|
# Get/Set directory paths
|
||||||
|
getdirs
|
||||||
|
if [ "$?" -eq 1 ]; then
|
||||||
|
# User cancelled and wants to return to the main menu, or error
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sanity check
|
||||||
|
if [ ! -d "$shaders_dir" ]; then
|
||||||
|
message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete the shader directory
|
||||||
|
if message question "The following directory will be deleted:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
||||||
|
debug_print continue "Deleting $shaders_dir..."
|
||||||
|
rm -r "$shaders_dir"
|
||||||
|
message info "Your shaders have been deleted!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Delete DXVK cache
|
||||||
|
rm_dxvkcache() {
|
||||||
|
# Get/Set directory paths
|
||||||
|
getdirs
|
||||||
|
if [ "$?" -eq 1 ]; then
|
||||||
|
# User cancelled and wants to return to the main menu
|
||||||
|
# or there was an error
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sanity check
|
||||||
|
if [ ! -f "$dxvk_cache" ]; then
|
||||||
|
message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete the cache file
|
||||||
|
if message question "The following file will be deleted:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
||||||
|
debug_print continue "Deleting $dxvk_cache..."
|
||||||
|
rm "$dxvk_cache"
|
||||||
|
message info "Your DXVK cache has been deleted!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Show maintenance/troubleshooting options
|
# Show maintenance/troubleshooting options
|
||||||
maintenance_menu() {
|
maintenance_menu() {
|
||||||
# Loop the menu until the user selects quit
|
# Loop the menu until the user selects quit
|
||||||
|
Loading…
Reference in New Issue
Block a user