Compare commits

...

5 Commits

Author SHA1 Message Date
the Sane
809efb6a54
Add more referral codes! 2022-01-01 21:51:13 -05:00
the Sane
5afa8e7c19
Improve post download handling 2022-01-01 16:12:14 -05:00
the Sane
49079818f6
Rearrange some functions 2022-01-01 15:52:53 -05:00
the Sane
227038a289
Check for installed wine in the pre-flight check 2022-01-01 15:37:51 -05:00
the Sane
8f53957f3c
Improve messages 2022-01-01 15:17:07 -05:00

View File

@ -159,6 +159,9 @@ repo="starcitizen-lug/lug-helper"
releases_url="https://github.com/$repo/releases"
current_version="v1.14"
# LUG Wiki
lug_wiki="https://github.com/starcitizen-lug/information-howtos/wiki"
############################################################################
############################################################################
@ -421,7 +424,7 @@ getdirs() {
# If we don't have the directory paths we need yet,
# ask the user to provide them
if [ -z "$wine_prefix" ] || [ -z "$game_path" ]; then
message info "Star Citizen must be installed before proceeding.\n\nAt the next screen, please select your Star Citizen WINE prefix.\nIt will be remembered for future use."
message info "Star Citizen must be installed before proceeding.\n\nAt the next screen, please select your Star Citizen install directory (WINE prefix)\nIt will be remembered for future use.\n\nLutris default install path: ~/Games/star-citizen"
if [ "$use_zenity" -eq 1 ]; then
# Using Zenity file selection menus
# Get the wine prefix directory
@ -735,6 +738,15 @@ filelimit_check() {
#------------------------- end filelimit functions ---------------------------#
# Check if WINE is installed
wine_check() {
if [ -x "$(command -v wine)" ]; then
preflight_pass+=("Wine is installed on your system.")
else
preflight_fail+=("Wine does not appear to be installed.\nAt a minimum, wine dependencies must be installed.\nPlease refer to our Quick Start Guide:\n$lug_wiki")
fi
}
# Check total system memory
memory_check() {
memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
@ -754,73 +766,120 @@ avx_check() {
fi
}
# 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
}
#------------------------- end preflight check functions ---------------------#
# 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
#------------------------- begin download functions ----------------------------#
lutris --install "$install_script" &
message info "The installation will continue in Lutris"
}
# 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
}
# Restart lutris
# Restart lutris if necessary
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
@ -831,22 +890,23 @@ lutris_restart() {
lutris_needs_restart="false"
}
#------------------------- begin download functions ----------------------------#
# Display post download message or instructions if needed
# Perform post-download actions, display messages or instructions
# Expects the variables message_heading, post_download_msg_text,
# post_download_msg_italics, and downloaded_item_name
post_download() {
if [ "$trigger_post_download" = "true" ]; then
# Check if lutris needs to be restarted after making changes
lutris_restart
if [ "$display_post_download_msg" = "true" ]; then
message_heading="Download Complete"
if [ "$use_zenity" -eq 1 ]; then
message_heading="<b>$message_heading</b>"
post_download_msg_italics="<i>$post_download_msg_italics</i>"
fi
message info "$message_heading\n\n$post_download_msg_text\n\n$post_download_msg_italics\n$downloaded_item_name"
message info "$message_heading\n\n$post_download_msg_text\n$post_download_msg_italics\n\n$downloaded_item_name"
fi
trigger_post_download="false"
display_post_download_msg="false"
}
# Uninstall the selected item
@ -1028,7 +1088,7 @@ download_install() {
# Store the final name of the downloaded directory
downloaded_item_name="$download_name"
# Trigger the post_download() function
trigger_post_download="true"
display_post_download_msg="true"
elif [ "$num_dirs" -gt 1 ] || [ "$num_files" -gt 0 ]; then
# If the archive contains more than one directory or
# one or more files, we must create a subdirectory
@ -1046,7 +1106,7 @@ download_install() {
# Store the final name of the downloaded directory
downloaded_item_name="$download_name"
# Trigger the post_download() function
trigger_post_download="true"
display_post_download_msg="true"
else
# Some unexpected combination of directories and files
debug_print exit "Script error: Unexpected archive contents in download_install function. Aborting"
@ -1056,9 +1116,6 @@ download_install() {
# Cleanup tmp download
debug_print continue "Cleaning up $tmp_dir/$download_file..."
rm "$tmp_dir/$download_file"
# Display any post-download messages or instructions
post_download
}
# List available items for download
@ -1240,19 +1297,16 @@ download_manage() {
# Call the menu function. It will use the options as configured above
menu
# Perform post-download actions and display messages or instructions
post_download
done
# Check if lutris needs to be restarted after making changes
lutris_restart
}
#-------------------------- end download functions -----------------------------#
# Configure the download_manage function for runners
runner_manage() {
# Set some defaults
lutris_needs_restart="false"
trigger_post_download="false"
display_post_download_msg="false"
# Use indirect expansion to point download_sources
# to the runner_sources array set at the top of the script
@ -1270,7 +1324,7 @@ runner_manage() {
# msg_text is displayed below the header
# msg_italics is displayed below that in italics when zenity is in use
# Lastly, the downloaded directory name is automatically displayed
post_download_msg_text="Select the runner in Lutris from the dropdown menu"
post_download_msg_text="Select the following runner in Lutris from the dropdown menu under:"
post_download_msg_italics="Configure->Runner Options->Wine version"
# Call the download_manage function with the above configuration
@ -1283,7 +1337,7 @@ runner_manage() {
dxvk_manage() {
# Set some defaults
lutris_needs_restart="false"
trigger_post_download="false"
display_post_download_msg="false"
# Use indirect expansion to point download_sources
# to the dxvk_sources array set at the top of the script
@ -1301,7 +1355,7 @@ dxvk_manage() {
# msg_text is displayed below the header
# msg_italics is displayed below that in italics when zenity is in use
# Lastly, the downloaded directory name is automatically displayed
post_download_msg_text="Type the DXVK folder name in your Lutris settings"
post_download_msg_text="Type the following DXVK name into your Lutris settings under:"
post_download_msg_italics="Configure->Runner Options->DXVK version"
# Call the download_manage function with the above configuration
@ -1310,115 +1364,7 @@ dxvk_manage() {
download_manage "dxvk"
}
#-------------------------- end dxvk 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
# 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
}
#-------------------------- end download functions -----------------------------#
# Deploy Easy Anti-Cheat Workaround
eac_workaround() {
@ -1467,6 +1413,72 @@ eac_workaround() {
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
maintenance_menu() {
# Loop the menu until the user selects quit
@ -1505,7 +1517,7 @@ maintenance_menu() {
# 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" "STAR-GMBP-SH9Y" "STAR-PLWB-LMFY" "STAR-TNZN-H4ZT" "STAR-T5G5-L2GJ" "STAR-6TPV-7QH2" "STAR-THHD-TV3Y" "STAR-7ZFS-PK2L" "STAR-SRQN-43TB" "STAR-9TDG-D4H9" "STAR-BPH3-THJC" "STAR-HL3M-R5KC" "STAR-GBS5-LTVB" "STAR-CJ3Y-KZZ4" "STAR-5GRM-7HBY" "STAR-G2GX-Y2QJ" "STAR-YWY3-H4XX" "STAR-6VGM-PTKC" "STAR-T6MZ-QFHX" "STAR-T2K6-LXFW" "STAR-XN25-9CJJ" "STAR-47V3-4QGB" "STAR-YD4Z-TQZV" "STAR-XLN7-9XNJ" "STAR-N62T-2R39" "STAR-3S3D-9HXQ" "STAR-TRZF-NMCV" "STAR-TLLJ-SMG4")
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" "STAR-T5G5-L2GJ" "STAR-6TPV-7QH2" "STAR-THHD-TV3Y" "STAR-7ZFS-PK2L" "STAR-SRQN-43TB" "STAR-9TDG-D4H9" "STAR-BPH3-THJC" "STAR-HL3M-R5KC" "STAR-GBS5-LTVB" "STAR-CJ3Y-KZZ4" "STAR-5GRM-7HBY" "STAR-G2GX-Y2QJ" "STAR-YWY3-H4XX" "STAR-6VGM-PTKC" "STAR-T6MZ-QFHX" "STAR-T2K6-LXFW" "STAR-XN25-9CJJ" "STAR-47V3-4QGB" "STAR-YD4Z-TQZV" "STAR-XLN7-9XNJ" "STAR-N62T-2R39" "STAR-3S3D-9HXQ" "STAR-TRZF-NMCV" "STAR-TLLJ-SMG4" "STAR-MFT6-Q44H" "STAR-TZX2-TPWF")
# 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")]}"