2021-01-15 17:00:52 +00:00
#!/usr/bin/env bash
2020-08-02 18:12:02 +00:00
############################################################################
# Star Citizen's Linux Users Group Helper Script
############################################################################
#
2021-01-16 19:31:27 +00:00
# Greetings, Space Penguin!
2020-08-02 18:12:02 +00:00
#
#
2021-01-03 18:48:48 +00:00
# This script is designed to help you manage and optimize
# Star Citizen on Linux.
2020-08-02 18:12:02 +00:00
#
2021-01-16 19:31:27 +00:00
# Features:
2020-08-02 18:12:02 +00:00
#
2021-01-16 19:31:27 +00:00
# - Check your system for optimal settings and
# change them as needed to prevent crashes.
2021-01-03 18:48:48 +00:00
#
2021-12-28 20:40:45 +00:00
# - Install Star Citizen using a bundled Lutris install script
#
2021-10-18 19:27:49 +00:00
# - Easily install and remove Lutris wine Runners and DXVK versions.
2021-01-16 19:31:27 +00:00
#
# - Qickly wipe your Star Citizen USER folder as is recommended
2021-01-03 18:48:48 +00:00
# by CIG after major version updates.
# It will back up your exported keybinds, delete your USER folder,
# then restore your keybind file(s).
#
2021-01-16 19:31:27 +00:00
# - Get a random participating LUG member's Star Citizen referral code.
#
# - Supports both the LIVE and PTU environments.
2021-01-03 18:48:48 +00:00
#
# - Zenity menus are used for a GUI experience with a fallback to
# terminal-based menus where Zenity is unavailable.
2020-08-02 18:12:02 +00:00
#
#
# To export your keybinds from within the game, go to
# Options->Keybindings->Control Profiles->Save Control Settings
#
2020-08-22 01:24:26 +00:00
# To import your keybinds from within the game, select them from the list:
# Options->Keybindings->Control Profiles
#
2020-12-27 21:45:31 +00:00
#
2020-12-28 00:08:11 +00:00
# made with <3
2020-12-27 21:45:31 +00:00
# Author: https://github.com/the-sane
# Contributor: https://github.com/Termuellinator
2021-01-16 01:02:48 +00:00
# Contributor: https://github.com/pstn
2021-01-30 19:35:54 +00:00
# Contributor: https://github.com/gort818
# Contributor: https://github.com/victort
2021-10-11 13:36:14 +00:00
# Contributor: https://github.com/Wrzlprnft
2021-01-23 14:29:42 +00:00
# Runner Downloader inspired by:
# https://github.com/richardtatum/sc-runner-updater
2021-12-22 00:52:32 +00:00
#
# License: GPLv3.0
2020-08-02 18:12:02 +00:00
############################################################################
2021-04-25 13:11:04 +00:00
# Check if script is run as root
2021-09-18 16:57:22 +00:00
if [ " $( id -u) " -eq 0 ] ; then
echo "This script is not supposed to be run as root!"
exit 1
2021-04-25 13:11:04 +00:00
fi
2021-01-16 01:02:10 +00:00
# Check for dependencies
2021-01-16 16:54:44 +00:00
if [ ! -x " $( command -v curl) " ] ; then
# Print to stderr and also try warning the user through notify-send
printf "lug-helper.sh: The required package 'curl' was not found on this system.\n" 1>& 2
notify-send "lug-helper" "The required package 'curl' was not found on this system.\n" --icon= dialog-warning
exit 1
fi
2021-12-28 20:40:45 +00:00
if [ ! -x " $( command -v mktemp) " ] || [ ! -x " $( command -v sort) " ] || [ ! -x " $( command -v basename) " ] || [ ! -x " $( command -v realpath) " ] || [ ! -x " $( command -v dirname) " ] ; then
2021-01-16 14:07:01 +00:00
# Print to stderr and also try warning the user through notify-send
2021-12-28 20:40:45 +00:00
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
2021-01-16 01:02:10 +00:00
exit 1
fi
2022-01-07 19:30:38 +00:00
######## Config ############################################################
2020-08-10 20:03:11 +00:00
wine_conf = "winedir.conf"
game_conf = "gamedir.conf"
2021-01-30 18:45:35 +00:00
# Use XDG base directories if defined
2021-01-29 05:26:17 +00:00
conf_dir = " ${ XDG_CONFIG_HOME :- $HOME /.config } "
data_dir = " ${ XDG_DATA_HOME :- $HOME /.local/share } "
2021-01-01 19:52:43 +00:00
# .config subdirectory
2020-08-10 20:03:11 +00:00
conf_subdir = "starcitizen-lug"
2021-01-01 19:52:43 +00:00
2021-12-28 20:40:45 +00:00
# Helper directory
helper_dir = " $( realpath " $0 " | xargs dirname) "
2021-01-16 01:02:10 +00:00
# Temporary directory
tmp_dir = " $( mktemp -d --suffix= ".lughelper" ) "
trap 'rm -r "$tmp_dir"' EXIT
2020-11-21 13:59:10 +00:00
2021-03-13 17:21:46 +00:00
######## Game Directories ##################################################
2021-03-13 14:59:28 +00:00
# The game's base directory name
sc_base_dir = "StarCitizen"
# The default install location within a WINE prefix:
install_path = " drive_c/Program Files/Roberts Space Industries/ $sc_base_dir "
2020-11-26 13:46:54 +00:00
2021-03-13 17:21:46 +00:00
# The names of the live/ptu directories
live_dir = "LIVE"
ptu_dir = "PTU"
2020-12-22 12:02:18 +00:00
2021-03-13 14:59:28 +00:00
# Remaining directory paths are set at the end of the getdirs() function
2021-10-18 19:27:49 +00:00
######## Runners ###########################################################
2021-03-13 14:59:28 +00:00
2020-12-25 16:24:10 +00:00
# Lutris wine runners directory
2021-01-01 19:52:43 +00:00
runners_dir = " $data_dir /lutris/runners/wine "
2020-12-25 16:24:10 +00:00
# URLs for downloading Lutris runners
2021-01-01 01:28:34 +00:00
# Elements in this array must be added in quoted pairs of: "description" "url"
2021-01-03 13:49:13 +00:00
# The first string in the pair is expected to contain the runner description
2021-01-01 01:28:34 +00:00
# The second is expected to contain the github api releases url
# ie. "RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases"
runner_sources = (
2021-12-24 01:01:11 +00:00
"RawFox" "https://api.github.com/repos/starcitizen-lug/raw-wine/releases"
2021-01-01 01:28:34 +00:00
"Molotov/Snatella" "https://api.github.com/repos/snatella/wine-runner-sc/releases"
2021-06-15 13:34:40 +00:00
"/dev/null" "https://api.github.com/repos/gort818/wine-sc-lug/releases"
2021-06-08 15:09:25 +00:00
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
2021-01-01 01:28:34 +00:00
)
2020-12-22 12:02:18 +00:00
2021-10-18 19:27:49 +00:00
######## DXVK ##############################################################
# Lutris dxvk directory
dxvk_dir = " $data_dir /lutris/runtime/dxvk "
# URLs for downloading dxvk versions
# Elements in this array must be added in quoted pairs of: "description" "url"
# The first string in the pair is expected to contain the runner description
# The second is expected to contain the github api releases url
# ie. "Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
dxvk_sources = (
"Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
2021-10-24 16:01:38 +00:00
"/dev/null" "https://api.github.com/repos/gort818/dxvk/releases"
2021-10-18 19:27:49 +00:00
)
2021-10-28 00:53:11 +00:00
# Set a maximum number of versions to display from each download url
max_download_items = 20
2021-10-18 19:27:49 +00:00
2020-12-27 22:27:00 +00:00
# Pixels to add for each Zenity menu option
# used to dynamically determine the height of menus
menu_option_height = "25"
2022-01-07 19:30:38 +00:00
######## Bundled Files #####################################################
2021-10-18 19:27:49 +00:00
2021-01-17 20:58:14 +00:00
# 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"
2021-12-28 20:40:45 +00:00
elif [ -f " $helper_dir /lug-logo.png " ] ; then
lug_logo = " $helper_dir /lug-logo.png "
2021-01-17 21:17:51 +00:00
else
lug_logo = "info"
2021-01-17 20:58:14 +00:00
fi
2022-01-06 14:10:10 +00:00
# Use Lutris install script installed by a packaged version of this script if available
# Otherwise, default to the json in the same directory
2022-01-06 14:05:24 +00:00
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
2021-12-28 20:40:45 +00:00
2022-01-07 19:30:38 +00:00
######## Links #############################################################
2022-01-07 19:26:24 +00:00
# LUG Wiki
lug_wiki = "https://github.com/starcitizen-lug/information-howtos/wiki"
2021-09-18 16:57:22 +00:00
# Github repo and script version info
2021-11-25 19:08:23 +00:00
repo = "starcitizen-lug/lug-helper"
releases_url = " https://github.com/ $repo /releases "
2022-01-07 19:26:24 +00:00
current_version = "v1.15"
2022-01-01 20:37:51 +00:00
2020-08-02 18:12:02 +00:00
############################################################################
############################################################################
2020-08-10 01:30:10 +00:00
2021-01-01 01:43:10 +00:00
# Echo a formatted debug message to the terminal and optionally exit
# Accepts either "continue" or "exit" as the first argument
# followed by the string to be echoed
2021-01-17 02:33:15 +00:00
debug_print( ) {
2021-01-01 01:43:10 +00:00
# This function expects two string arguments
if [ " $# " -lt 2 ] ; then
2021-01-17 02:33:15 +00:00
printf "\nScript error: The debug_print function expects two arguments. Aborting.\n"
2020-12-27 22:47:57 +00:00
read -n 1 -s -p "Press any key..."
exit 0
fi
2021-01-01 01:43:10 +00:00
# Echo the provided string and, optionally, exit the script
case " $1 " in
"continue" )
2021-01-16 13:51:22 +00:00
printf " \n $2 \n "
2021-01-01 01:43:10 +00:00
; ;
"exit" )
2021-01-16 01:42:47 +00:00
# Write an error to stderr and exit
2021-01-16 13:51:22 +00:00
printf " lug-helper.sh: $2 \n " 1>& 2
2021-01-01 01:43:10 +00:00
read -n 1 -s -p "Press any key..."
2021-01-16 01:42:47 +00:00
exit 1
2021-01-01 01:43:10 +00:00
; ;
*)
2021-01-17 02:33:15 +00:00
printf "lug-helper.sh: Unknown argument provided to debug_print function. Aborting.\n" 1>& 2
2021-01-01 01:43:10 +00:00
read -n 1 -s -p "Press any key..."
exit 0
; ;
esac
2020-12-27 22:47:57 +00:00
}
2020-09-07 22:51:19 +00:00
# Display a message to the user.
2020-09-08 00:30:28 +00:00
# Expects the first argument to indicate the message type, followed by
2020-09-07 22:51:19 +00:00
# a string of arguments that will be passed to zenity or echoed to the user.
2020-08-15 15:01:54 +00:00
#
2020-09-08 00:30:28 +00:00
# To call this function, use the following format: message [type] "[string]"
2020-09-07 22:51:19 +00:00
# See the message types below for instructions on formatting the string.
2020-08-03 19:49:19 +00:00
message( ) {
2020-09-08 00:36:26 +00:00
# Sanity check
if [ " $# " -lt 2 ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The message function expects two arguments. Aborting."
2020-09-08 00:36:26 +00:00
fi
# Use zenity messages if available
2021-01-31 16:11:38 +00:00
if [ " $use_zenity " -eq 1 ] ; then
2020-08-15 15:22:44 +00:00
case " $1 " in
2020-12-25 16:24:10 +00:00
"info" )
# info message
# call format: message info "text to display"
2021-01-17 20:58:14 +00:00
margs = ( "--info" " --window-icon= $lug_logo " "--no-wrap" "--text=" )
2020-12-25 16:24:10 +00:00
; ;
2020-09-08 00:30:28 +00:00
"warning" )
2020-12-25 16:24:10 +00:00
# warning message
# call format: message warning "text to display"
2021-01-17 20:58:14 +00:00
margs = ( "--warning" " --window-icon= $lug_logo " "--text=" )
2020-12-25 16:24:10 +00:00
; ;
2020-09-08 00:30:28 +00:00
"question" )
2020-12-25 16:24:10 +00:00
# question
# call format: if message question "question to ask?"; then...
2021-01-17 20:58:14 +00:00
margs = ( "--question" " --window-icon= $lug_logo " "--text=" )
2020-12-25 16:24:10 +00:00
; ;
*)
2021-01-17 02:33:15 +00:00
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
2020-12-25 16:24:10 +00:00
; ;
2020-08-15 15:22:44 +00:00
esac
2020-08-02 18:12:02 +00:00
2020-08-03 22:15:38 +00:00
# Display the message
2020-12-19 14:34:53 +00:00
shift 1 # drop the first argument and shift the remaining up one
2020-12-27 21:56:41 +00:00
zenity " ${ margs [@] } " " $@ " --width= "400" --title= "Star Citizen LUG Helper" 2>/dev/null
2020-08-03 19:49:19 +00:00
else
2020-09-07 23:42:18 +00:00
# Fall back to text-based messages when zenity is not available
2020-08-15 15:22:44 +00:00
case " $1 " in
2020-12-25 16:24:10 +00:00
"info" )
# info message
# call format: message info "text to display"
clear
2021-01-16 13:51:22 +00:00
printf " \n $2 \n\n "
2020-12-25 16:24:10 +00:00
read -n 1 -s -p "Press any key..."
; ;
2020-09-08 00:38:39 +00:00
"warning" )
2020-12-25 16:24:10 +00:00
# warning message
# call format: message warning "text to display"
clear
2021-01-16 13:51:22 +00:00
printf " \n $2 \n\n "
2020-12-25 16:24:10 +00:00
read -n 1 -s -p "Press any key..."
return 0
; ;
2020-09-08 00:38:39 +00:00
"question" )
2020-12-25 16:24:10 +00:00
# question
# call format: if message question "question to ask?"; then...
clear
2021-01-16 13:51:22 +00:00
printf " $2 \n "
2020-12-25 16:24:10 +00:00
while read -p "[y/n]: " yn; do
2020-08-15 15:22:44 +00:00
case " $yn " in
2020-12-25 16:24:10 +00:00
[ Yy] *)
2020-08-15 15:22:44 +00:00
return 0
; ;
2020-12-25 16:24:10 +00:00
[ Nn] *)
2020-08-15 15:22:44 +00:00
return 1
; ;
2020-12-25 16:24:10 +00:00
*)
2021-01-16 13:51:22 +00:00
printf "Please type 'y' or 'n'\n"
2020-08-15 15:22:44 +00:00
; ;
esac
2020-12-25 16:24:10 +00:00
done
; ;
*)
2021-01-17 02:33:15 +00:00
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
2020-12-25 16:24:10 +00:00
; ;
2020-08-15 15:22:44 +00:00
esac
2020-08-03 19:49:19 +00:00
fi
2020-08-02 18:12:02 +00:00
}
2020-09-07 22:51:19 +00:00
# Display a menu to the user.
# Uses Zenity for a gui menu with a fallback to plain old text.
#
# How to call this function:
#
# Requires two arrays to be set: "menu_options" and "menu_actions"
2020-12-21 00:34:34 +00:00
# two string variables: "menu_text_zenity" and "menu_text_terminal"
2020-09-07 22:51:19 +00:00
# and one integer variable: "menu_height".
#
2020-12-21 00:34:34 +00:00
# - The array "menu_options" should contain the strings of each option.
# - The array "menu_actions" should contain function names to be called.
# - The strings "menu_text_zenity" and "menu_text_terminal" should contain
# the menu description formatted for zenity and the terminal, respectively.
# This text will be displayed above the menu options.
# Zenity supports Pango Markup for text formatting.
# - The integer "menu_height" specifies the height of the zenity menu.
2021-09-18 19:51:57 +00:00
# - The string "cancel_label" should contain the text of the cancel button.
2020-09-07 22:51:19 +00:00
#
# The final element in each array is expected to be a quit option.
#
# IMPORTANT: The indices of the elements in "menu_actions"
# *MUST* correspond to the indeces in "menu_options".
# In other words, it is expected that menu_actions[1] is the correct action
# to be executed when menu_options[1] is selected, and so on for each element.
2020-12-19 14:34:53 +00:00
#
# See MAIN at the bottom of this script for an example of generating a menu.
2020-09-07 22:51:19 +00:00
menu( ) {
# Sanity checks
if [ " ${# menu_options [@] } " -eq 0 ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The array 'menu_options' was not set\nbefore calling the menu function. Aborting."
2020-09-07 22:51:19 +00:00
elif [ " ${# menu_actions [@] } " -eq 0 ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The array 'menu_actions' was not set\nbefore calling the menu function. Aborting."
2020-12-21 00:34:34 +00:00
elif [ -z " $menu_text_zenity " ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The string 'menu_text_zenity' was not set\nbefore calling the menu function. Aborting."
2020-12-21 00:34:34 +00:00
elif [ -z " $menu_text_terminal " ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
2020-09-07 22:51:19 +00:00
elif [ -z " $menu_height " ] ; then
2021-01-17 02:33:15 +00:00
debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
2021-09-18 19:51:57 +00:00
elif [ -z " $cancel_label " ] ; then
2021-11-08 11:57:00 +00:00
debug_print exit "Script error: The string 'cancel_label' was not set\nbefore calling the menu function. Aborting."
2020-09-07 22:51:19 +00:00
fi
# Use Zenity if it is available
2021-01-31 16:11:38 +00:00
if [ " $use_zenity " -eq 1 ] ; then
2020-12-25 16:24:10 +00:00
# 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"
for ( ( i = 0; i<" ${# menu_options [@] } " -1; i++ ) ) ; do
if [ " $i " -eq 0 ] ; then
# Select the first radio button by default
zen_options = ( "TRUE" )
zen_options += ( " ${ menu_options [i] } " )
else
zen_options += ( "FALSE" )
zen_options += ( " ${ menu_options [i] } " )
fi
done
# Display the zenity radio button menu
2021-09-18 19:51:57 +00:00
choice = " $( zenity --list --radiolist --width= "480" --height= " $menu_height " --text= " $menu_text_zenity " --title= "Star Citizen LUG Helper" --hide-header --cancel-label " $cancel_label " --window-icon= $lug_logo --column= "" --column= "Option" " ${ zen_options [@] } " 2>/dev/null) "
2020-12-25 16:24:10 +00:00
# Loop through the options array to match the chosen option
matched = "false"
for ( ( i = 0; i<" ${# menu_options [@] } " ; i++ ) ) ; do
if [ " $choice " = " ${ menu_options [i] } " ] ; then
# Execute the corresponding action
${ menu_actions [i] }
matched = "true"
break
fi
done
# If no match was found, the user clicked cancel
if [ " $matched " = "false" ] ; then
# Execute the last option in the actions array
" ${ menu_actions [ ${# menu_actions [@] } -1] } "
fi
2020-09-07 22:51:19 +00:00
else
2020-12-25 16:24:10 +00:00
# Use a text menu if Zenity is not available
clear
2021-01-16 13:51:22 +00:00
printf " \n $menu_text_terminal \n\n "
2020-12-25 16:24:10 +00:00
PS3 = "Enter selection number: "
select choice in " ${ menu_options [@] } "
do
# Loop through the options array to match the chosen option
matched = "false"
for ( ( i = 0; i<" ${# menu_options [@] } " ; i++ ) ) ; do
if [ " $choice " = " ${ menu_options [i] } " ] ; then
# Execute the corresponding action
2021-01-16 13:51:22 +00:00
printf "\n\n"
2020-12-25 16:24:10 +00:00
${ menu_actions [i] }
matched = "true"
break
fi
done
# Check if we're done looping the menu
if [ " $matched " = "true" ] ; then
# Match was found and actioned, so exit the menu
break
else
# If no match was found, the user entered an invalid option
2021-01-16 13:51:22 +00:00
printf "\nInvalid selection.\n"
2020-12-25 16:24:10 +00:00
continue
fi
done
2020-09-07 22:51:19 +00:00
fi
}
2021-01-24 21:15:35 +00:00
# Called when the user clicks cancel on a looping menu
# Causes a return to the main menu
menu_loop_done( ) {
looping_menu = "false"
}
2020-08-10 20:03:11 +00:00
# Get paths to the user's wine prefix, game directory, and a backup directory
2020-08-10 01:30:10 +00:00
getdirs( ) {
2020-08-10 20:03:11 +00:00
# Sanity checks
if [ ! -d " $conf_dir " ] ; then
2021-01-17 02:55:58 +00:00
message warning " Config directory not found. The Helper is unable to proceed.\n\n $conf_dir "
2020-08-15 02:33:04 +00:00
return 1
2020-08-10 20:03:11 +00:00
fi
if [ ! -d " $conf_dir / $conf_subdir " ] ; then
2020-12-27 21:45:31 +00:00
mkdir -p " $conf_dir / $conf_subdir "
2020-08-10 20:03:11 +00:00
fi
# Check if the config files already exist
if [ -f " $conf_dir / $conf_subdir / $wine_conf " ] ; then
2020-08-12 00:42:44 +00:00
wine_prefix = " $( cat " $conf_dir / $conf_subdir / $wine_conf " ) "
2020-12-25 16:24:10 +00:00
if [ ! -d " $wine_prefix " ] ; then
2021-01-17 02:33:15 +00:00
debug_print continue "The saved wine prefix does not exist, ignoring."
2020-12-25 16:24:10 +00:00
wine_prefix = ""
fi
2020-08-10 20:03:11 +00:00
fi
if [ -f " $conf_dir / $conf_subdir / $game_conf " ] ; then
2020-08-12 00:42:44 +00:00
game_path = " $( cat " $conf_dir / $conf_subdir / $game_conf " ) "
2021-03-13 14:59:28 +00:00
if [ ! -d " $game_path " ] || [ " $( basename " $game_path " ) " != " $sc_base_dir " ] ; then
2021-01-17 02:33:15 +00:00
debug_print continue "Unexpected game path found in config file, ignoring."
2020-12-25 16:24:10 +00:00
game_path = ""
fi
2020-08-10 20:03:11 +00:00
fi
2020-08-22 01:02:16 +00:00
2021-01-01 01:55:44 +00:00
# If we don't have the directory paths we need yet,
# ask the user to provide them
2021-01-16 23:50:28 +00:00
if [ -z " $wine_prefix " ] || [ -z " $game_path " ] ; then
2022-01-01 20:17:07 +00:00
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"
2021-01-31 16:11:38 +00:00
if [ " $use_zenity " -eq 1 ] ; then
2021-01-01 19:52:43 +00:00
# Using Zenity file selection menus
2020-08-12 00:42:44 +00:00
# Get the wine prefix directory
2020-08-12 02:02:44 +00:00
if [ -z " $wine_prefix " ] ; then
2021-01-16 19:20:10 +00:00
wine_prefix = " $( zenity --file-selection --directory --title= "Select your Star Citizen WINE prefix directory" --filename= " $HOME /Games/star-citizen " 2>/dev/null) "
2020-12-25 16:24:10 +00:00
if [ " $? " -eq -1 ] ; then
2021-01-17 02:55:58 +00:00
message warning "An unexpected error has occurred. The Helper is unable to proceed."
2020-12-25 16:24:10 +00:00
return 1
elif [ -z " $wine_prefix " ] ; then
# User clicked cancel
message warning "Operation cancelled.\nNo changes have been made to your game."
return 1
fi
2020-08-10 20:03:11 +00:00
fi
2020-08-12 00:42:44 +00:00
# Get the game path
2020-08-12 02:02:44 +00:00
if [ -z " $game_path " ] ; then
2021-03-13 14:59:28 +00:00
if [ -d " $wine_prefix / $install_path " ] &&
message question " Is this your Star Citizen game directory?\n\n $wine_prefix / $install_path " ; then
game_path = " $wine_prefix / $install_path "
2021-01-01 19:52:43 +00:00
else
2021-03-13 14:59:28 +00:00
while game_path = " $( zenity --file-selection --directory --title= "Select your Star Citizen directory" --filename= " $wine_prefix / $install_path " 2>/dev/null) " ; do
2021-01-01 19:52:43 +00:00
if [ " $? " -eq -1 ] ; then
2021-01-17 02:55:58 +00:00
message warning "An unexpected error has occurred. The Helper is unable to proceed."
2021-01-01 19:52:43 +00:00
return 1
2021-03-13 14:59:28 +00:00
elif [ " $( basename " $game_path " ) " != " $sc_base_dir " ] ; then
2021-01-02 13:57:01 +00:00
message warning "You must select the Star Citizen base game directory.\n\nFor Example: prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
2021-01-01 19:52:43 +00:00
else
# All good or cancel
break
fi
done
if [ -z " $game_path " ] ; then
# User clicked cancel
message warning "Operation cancelled.\nNo changes have been made to your game."
2020-12-25 16:24:10 +00:00
return 1
2020-08-12 00:42:44 +00:00
fi
2020-12-25 16:24:10 +00:00
fi
2020-08-12 00:42:44 +00:00
fi
2020-12-25 16:24:10 +00:00
else
2021-01-01 19:52:43 +00:00
# No Zenity, use terminal-based menus
2020-12-25 16:24:10 +00:00
clear
2020-08-12 00:42:44 +00:00
# Get the wine prefix directory
2020-08-12 02:02:44 +00:00
if [ -z " $wine_prefix " ] ; then
2021-01-16 13:51:22 +00:00
printf "Enter the full path to your Star Citizen WINE prefix directory (case sensitive)\n"
2021-01-16 19:20:10 +00:00
printf "ie. /home/USER/Games/star-citizen\n"
2020-12-25 16:24:10 +00:00
while read -rp ": " wine_prefix; do
if [ ! -d " $wine_prefix " ] ; then
2021-01-16 13:51:22 +00:00
printf "That directory is invalid or does not exist. Please try again.\n\n"
2020-12-25 16:24:10 +00:00
else
break
fi
done
2021-01-01 19:52:43 +00:00
fi
2020-12-25 16:24:10 +00:00
2021-01-01 19:52:43 +00:00
# Get the game path
if [ -z " $game_path " ] ; then
2021-03-13 14:59:28 +00:00
if [ -d " $wine_prefix / $install_path " ] &&
message question " Is this your Star Citizen game directory?\n\n $wine_prefix / $install_path " ; then
game_path = " $wine_prefix / $install_path "
2021-01-01 19:52:43 +00:00
else
2021-01-16 13:51:22 +00:00
printf "\nEnter the full path to your Star Citizen installation directory (case sensitive)\n"
2021-01-16 19:20:10 +00:00
printf "ie. /home/USER/Games/star-citizen/drive_c/Program Files/Roberts Space Industries/StarCitizen\n"
2020-12-25 16:24:10 +00:00
while read -rp ": " game_path; do
if [ ! -d " $game_path " ] ; then
2021-01-16 13:51:22 +00:00
printf "That directory is invalid or does not exist. Please try again.\n\n"
2021-03-13 14:59:28 +00:00
elif [ " $( basename " $game_path " ) " != " $sc_base_dir " ] ; then
printf " You must enter the full path to the directory named ' $sc_base_dir '\n\n "
2020-12-25 16:24:10 +00:00
else
break
fi
done
fi
2021-01-01 19:52:43 +00:00
fi
2020-12-25 16:24:10 +00:00
fi
2020-08-10 20:03:11 +00:00
# Save the paths for later use
echo " $wine_prefix " > " $conf_dir / $conf_subdir / $wine_conf "
echo " $game_path " > " $conf_dir / $conf_subdir / $game_conf "
fi
2021-03-13 17:21:46 +00:00
######## Set remaining directory paths #####################################
# $live_or_ptu is set in the set_version() function
############################################################################
# The game's user directory
2021-09-18 20:22:50 +00:00
user_dir = " $game_path / $live_or_ptu /USER/Client/0 "
2021-03-13 17:21:46 +00:00
# The location within the USER directory to which the game exports keybinds
keybinds_dir = " $user_dir /Controls/Mappings "
# Shaders directory
2021-03-13 14:59:28 +00:00
shaders_dir = " $user_dir /shaders "
2021-03-13 17:21:46 +00:00
# dxvk cache file
dxvk_cache = " $game_path / $live_or_ptu /StarCitizen.dxvk-cache "
# Where to store backed up keybinds
backup_path = " $conf_dir / $conf_subdir "
2020-08-10 01:30:10 +00:00
}
2021-09-20 03:13:46 +00:00
# Display all directories currently used by this helper and Star Citizen
display_dirs( ) {
# Helper configs and keybinds
if [ -d " $conf_dir / $conf_subdir " ] ; then
dirs_list += ( " \n\nHelper configuration:\n $conf_dir / $conf_subdir \n\nKeybind backups:\n $conf_dir / $conf_subdir /keybinds " )
fi
# Wine prefix
if [ -f " $conf_dir / $conf_subdir / $wine_conf " ] ; then
dirs_list += " \n\nWine prefix:\n $( cat " $conf_dir / $conf_subdir / $wine_conf " ) "
fi
# Star Citizen installation
if [ -f " $conf_dir / $conf_subdir / $game_conf " ] ; then
dirs_list += " \n\nStar Citizen game directory:\n $( cat " $conf_dir / $conf_subdir / $game_conf " ) "
fi
# Lutris runners
2021-10-11 02:16:02 +00:00
if [ -d " $runners_dir " ] ; then
2021-10-11 02:12:28 +00:00
dirs_list += " \n\nLutris Runners:\n $runners_dir "
fi
2021-09-20 03:13:46 +00:00
2021-10-18 19:31:59 +00:00
# Lutris dxvk
if [ -d " $runners_dir " ] ; then
dirs_list += " \n\nLutris DXVK Versions:\n $dxvk_dir "
fi
2021-10-11 14:25:25 +00:00
# Formatting
message_heading = "These directories are currently being used by this Helper and Star Citizen"
if [ " $use_zenity " -eq 1 ] ; then
message_heading = " <b> $message_heading </b> "
fi
message info " $message_heading \n ${ dirs_list [@] } "
2021-09-20 03:13:46 +00:00
}
2020-08-02 18:12:02 +00:00
# Save exported keybinds, wipe the USER directory, and restore keybinds
2021-01-01 01:43:10 +00:00
sanitize( ) {
2020-08-12 00:42:44 +00:00
# Prompt user to back up the current keybinds in the game
2020-09-08 00:30:28 +00:00
message info "Before proceeding, please be sure you have exported\nyour Star Citizen keybinds from within the game.\n\nTo do this, launch the game and go to:\nOptions->Keybindings->Control Profiles->Save Control Settings\n\nGo on; I'll wait."
2020-08-10 20:03:11 +00:00
2020-08-12 00:42:44 +00:00
# Get/Set directory paths
getdirs
2020-08-15 02:33:04 +00:00
if [ " $? " -eq 1 ] ; then
2021-01-01 01:55:44 +00:00
# User cancelled and wants to return to the main menu
# or there was an error
2020-12-25 16:24:10 +00:00
return 0
2020-08-15 02:33:04 +00:00
fi
2020-08-02 18:12:02 +00:00
2020-08-12 02:46:05 +00:00
# Sanity check
if [ ! -d " $user_dir " ] ; then
2020-12-25 16:24:10 +00:00
message warning " USER directory not found. There is nothing to delete!\n\n $user_dir "
return 0
2020-08-12 02:46:05 +00:00
fi
2020-08-12 00:42:44 +00:00
# Check for exported keybind files
2020-11-21 13:59:10 +00:00
if [ ! -d " $keybinds_dir " ] || [ -z " $( ls -A " $keybinds_dir " ) " ] ; then
2020-12-25 16:24:10 +00:00
if message question "Warning: No exported keybindings found.\nContinuing will erase your existing keybinds!\n\nDo you want to continue anyway?" ; then
exported = 0
else
# User said no
return 0
fi
2020-08-12 00:42:44 +00:00
else
2020-12-25 16:24:10 +00:00
exported = 1
2020-08-12 00:42:44 +00:00
fi
2020-08-02 18:12:02 +00:00
2021-01-17 02:55:58 +00:00
if message question " The following directory will be deleted:\n\n $user_dir \n\nDo you want to proceed? " ; then
2020-12-25 16:24:10 +00:00
# Back up keybinds
if [ " $exported " -eq 1 ] ; then
2021-01-17 02:33:15 +00:00
debug_print continue " Backing up keybinds to $backup_path /keybinds... "
2021-01-16 23:50:28 +00:00
mkdir -p " $backup_path /keybinds " && cp -r " $keybinds_dir /. " " $backup_path /keybinds/ "
2020-12-25 16:24:10 +00:00
fi
# Wipe the user directory
2021-01-17 02:33:15 +00:00
debug_print continue " Wiping $user_dir ... "
2020-12-25 16:24:10 +00:00
rm -r " $user_dir "
# Restore custom keybinds
if [ " $exported " -eq 1 ] ; then
2021-01-17 02:33:15 +00:00
debug_print continue "Restoring keybinds..."
2020-12-25 16:24:10 +00:00
mkdir -p " $keybinds_dir " && cp -r " $backup_path /keybinds/. " " $keybinds_dir / "
message info "To re-import your keybinds, select it in-game from the list:\nOptions->Keybindings->Control Profiles"
fi
message info "Your Star Citizen USER directory has been cleaned up!"
2020-08-23 14:01:38 +00:00
fi
2020-08-02 18:12:02 +00:00
}
2021-02-20 23:04:34 +00:00
#--------------------- begin preflight check functions -----------------------#
2020-12-27 21:45:31 +00:00
#------------------------- begin mapcount functions --------------------------#
2020-08-15 02:11:31 +00:00
# Check if setting vm.max_map_count was successful
2021-01-24 03:05:23 +00:00
mapcount_confirm( ) {
2020-08-02 18:12:02 +00:00
if [ " $( cat /proc/sys/vm/max_map_count) " -lt 16777216 ] ; then
2021-01-24 17:44:49 +00:00
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." )
2020-08-02 18:12:02 +00:00
fi
}
2020-09-07 22:51:19 +00:00
# Sets vm.max_map_count for the current session only
mapcount_once( ) {
2021-01-24 17:44:49 +00:00
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" )
2020-09-07 22:51:19 +00:00
}
2021-01-24 03:05:23 +00:00
# Set vm.max_map_count
mapcount_set( ) {
2020-09-07 22:51:19 +00:00
if [ -d "/etc/sysctl.d" ] ; then
2021-01-24 17:44:49 +00:00
# Newer versions of sysctl
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" )
2020-09-07 22:51:19 +00:00
else
2021-01-24 17:44:49 +00:00
# Older versions of sysctl
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" )
2020-09-07 22:51:19 +00:00
fi
2021-01-24 17:44:49 +00:00
# Verify that the setting took effect
preflight_followup += ( "mapcount_confirm" )
2020-09-07 22:51:19 +00:00
}
2021-01-24 03:05:23 +00:00
# Check vm.max_map_count for the correct setting
mapcount_check( ) {
2021-01-24 19:37:36 +00:00
mapcount = " $( cat /proc/sys/vm/max_map_count) "
2021-01-24 03:05:23 +00:00
# Add to the results and actions arrays
2021-01-24 19:37:36 +00:00
if [ " $mapcount " -ge 16777216 ] ; then
2021-01-24 03:05:23 +00:00
# All good
2021-11-14 17:13:10 +00:00
preflight_pass += ( " vm.max_map_count is set to $mapcount . " )
2021-01-24 03:05:23 +00:00
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." )
2021-01-24 03:34:15 +00:00
# Add the function that will be called to change the configuration
2021-01-24 17:44:49 +00:00
preflight_action_funcs += ( "mapcount_once" )
2021-01-24 03:05:23 +00:00
# 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
2021-01-24 19:37:36 +00:00
preflight_fail += ( " vm.max_map_count is $mapcount \nand should be set to at least 16777216\nto give the game access to sufficient memory. " )
2021-01-24 03:34:15 +00:00
# Add the function that will be called to change the configuration
2021-01-24 17:44:49 +00:00
preflight_action_funcs += ( "mapcount_set" )
2021-01-24 03:05:23 +00:00
# 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" )
2020-12-25 16:24:10 +00:00
fi
2020-08-02 18:12:02 +00:00
fi
}
2020-12-27 21:45:31 +00:00
#-------------------------- end mapcount functions ---------------------------#
#------------------------ begin filelimit functions --------------------------#
2020-09-04 00:56:53 +00:00
# Check if setting the open file descriptors limit was successful
2021-01-24 03:05:23 +00:00
filelimit_confirm( ) {
2020-09-04 00:56:53 +00:00
if [ " $( ulimit -Hn) " -lt 524288 ] ; then
2021-01-24 17:44:49 +00:00
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." )
2020-09-04 00:56:53 +00:00
fi
}
2021-01-24 03:05:23 +00:00
# Set the open file descriptors limit
2020-09-08 01:59:34 +00:00
filelimit_set( ) {
2021-01-24 03:05:23 +00:00
if [ -f "/etc/systemd/system.conf" ] ; then
# Using systemd
# Append to the file
2021-01-24 17:44:49 +00:00
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" )
2021-01-24 03:05:23 +00:00
elif [ -f "/etc/security/limits.conf" ] ; then
# Using limits.conf
# Insert before the last line in the file
2021-01-24 17:44:49 +00:00
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" )
2021-01-24 03:05:23 +00:00
else
# Don't know what method to use
2021-01-24 17:44:49 +00:00
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." )
2021-01-24 03:05:23 +00:00
fi
# Verify that setting the limit was successful
2021-01-24 17:44:49 +00:00
preflight_followup += ( "filelimit_confirm" )
2021-01-24 03:05:23 +00:00
}
# Check the open file descriptors limit
filelimit_check( ) {
2020-08-23 13:27:46 +00:00
filelimit = " $( ulimit -Hn) "
2020-09-04 00:56:53 +00:00
2021-01-24 03:05:23 +00:00
# Add to the results and actions arrays
2020-08-23 13:27:46 +00:00
if [ " $filelimit " -ge 524288 ] ; then
2021-01-24 03:05:23 +00:00
# All good
2021-11-14 17:13:10 +00:00
preflight_pass += ( " Hard open file descriptors limit is set to $filelimit . " )
2021-01-24 03:05:23 +00:00
else
# The file limit should be changed
2021-01-24 19:37:36 +00:00
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. " )
2021-01-24 03:34:15 +00:00
# Add the function that will be called to change the configuration
2021-01-24 17:44:49 +00:00
preflight_action_funcs += ( "filelimit_set" )
2020-09-04 00:56:53 +00:00
2021-01-24 03:05:23 +00:00
# Add info for manually changing the settings
2020-09-05 12:12:11 +00:00
if [ -f "/etc/systemd/system.conf" ] ; then
2020-09-04 00:56:53 +00:00
# Using systemd
2021-01-24 03:05:23 +00:00
preflight_manual += ( "To change your open file descriptors limit, add the following line to\n'/etc/systemd/system.conf':\n DefaultLimitNOFILE=524288" )
2020-09-04 00:56:53 +00:00
elif [ -f "/etc/security/limits.conf" ] ; then
# Using limits.conf
2021-01-24 03:05:23 +00:00
preflight_manual += ( "To change your open file descriptors limit, add the following line to\n'/etc/security/limits.conf':\n * hard nofile 524288" )
2020-09-04 00:56:53 +00:00
else
2020-09-04 01:20:06 +00:00
# Don't know what method to use
2021-01-24 03:05:23 +00:00
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." )
2020-09-04 00:56:53 +00:00
fi
2020-08-23 13:27:46 +00:00
fi
}
2020-12-27 21:45:31 +00:00
#------------------------- end filelimit functions ---------------------------#
2022-01-01 20:37:51 +00:00
# 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
}
2021-01-24 20:37:06 +00:00
# Check total system memory
memory_check( ) {
2021-07-19 14:01:38 +00:00
memtotal = " $( LC_NUMERIC = C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo) "
2021-02-20 23:01:13 +00:00
if [ ${ memtotal %.* } -ge "15" ] ; then
2021-01-24 20:37:06 +00:00
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
}
2021-02-16 19:23:14 +00:00
# Check CPU for the required AVX extension
avx_check( ) {
2021-02-20 23:07:08 +00:00
if grep -q "avx" /proc/cpuinfo; then
2021-02-16 19:23:14 +00:00
preflight_pass += ( "Your CPU supports the necessary AVX instruction set." )
else
2021-02-20 23:06:49 +00:00
preflight_fail += ( "Your CPU does not appear to support AVX instructions.\nThis requirement was added to Star Citizen in version 3.11" )
2021-02-16 19:23:14 +00:00
fi
}
2022-01-01 20:52:53 +00:00
# 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
2021-12-28 20:40:45 +00:00
2022-01-01 20:52:53 +00:00
# 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
2020-08-17 21:53:25 +00:00
fi
2022-01-01 20:52:53 +00:00
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
2020-08-17 21:53:25 +00:00
fi
2022-01-01 20:52:53 +00:00
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
2020-08-17 21:53:25 +00:00
2022-01-01 20:52:53 +00:00
# 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
2020-08-17 21:53:25 +00:00
2022-01-01 20:52:53 +00:00
# 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
2021-03-13 14:59:28 +00:00
2022-01-01 20:52:53 +00:00
# Call any followup functions
for ( ( i = 0; i<" ${# preflight_followup [@] } " ; i++ ) ) ; do
${ preflight_followup [i] }
done
2020-08-17 21:53:25 +00:00
2022-01-01 20:52:53 +00:00
# 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
2020-08-17 21:53:25 +00:00
2022-01-01 20:52:53 +00:00
# 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
2020-12-27 19:12:20 +00:00
fi
fi
}
2022-01-01 20:52:53 +00:00
#------------------------- end preflight check functions ---------------------#
2021-10-28 00:53:11 +00:00
#------------------------- begin download functions ----------------------------#
2021-10-18 19:27:49 +00:00
2022-01-01 21:12:14 +00:00
# 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
debug_print continue "Restarting Lutris..."
pkill -SIGTERM lutris && nohup lutris </dev/null & >/dev/null &
fi
fi
lutris_needs_restart = "false"
}
# Perform post-download actions, display messages or instructions
2021-11-10 20:04:48 +00:00
# Expects the variables message_heading, post_download_msg_text,
# post_download_msg_italics, and downloaded_item_name
2021-10-28 04:35:43 +00:00
post_download( ) {
2022-01-01 21:12:14 +00:00
# Check if lutris needs to be restarted after making changes
lutris_restart
if [ " $display_post_download_msg " = "true" ] ; then
2021-10-28 04:35:43 +00:00
message_heading = "Download Complete"
2021-10-28 06:02:48 +00:00
2021-10-28 04:35:43 +00:00
if [ " $use_zenity " -eq 1 ] ; then
message_heading = " <b> $message_heading </b> "
2021-11-10 20:04:48 +00:00
post_download_msg_italics = " <i> $post_download_msg_italics </i> "
2021-10-28 04:35:43 +00:00
fi
2022-01-01 20:17:07 +00:00
message info " $message_heading \n\n $post_download_msg_text \n $post_download_msg_italics \n\n $downloaded_item_name "
2021-10-28 04:35:43 +00:00
fi
2022-01-01 21:12:14 +00:00
display_post_download_msg = "false"
2021-10-28 04:35:43 +00:00
}
2021-10-28 00:53:11 +00:00
# Uninstall the selected item
download_delete( ) {
2021-01-01 01:55:44 +00:00
# This function expects an index number for the array
2021-10-28 00:53:11 +00:00
# installed_items to be passed in as an argument
2020-12-27 19:48:38 +00:00
if [ -z " $1 " ] ; then
2021-10-28 00:53:11 +00:00
debug_print exit "Script error: The download_delete function expects an argument. Aborting."
2020-12-27 19:48:38 +00:00
fi
2021-10-28 00:53:11 +00:00
item_to_delete = " $1 "
if message question " Are you sure you want to delete the following ${ download_type } ?\n\n ${ installed_items [ $item_to_delete ] } " ; then
rm -r " ${ installed_items [ $item_to_delete ] } "
debug_print continue " Deleted ${ installed_items [ $item_to_delete ] } "
2020-12-27 20:40:54 +00:00
lutris_needs_restart = "true"
2020-12-25 16:24:10 +00:00
fi
}
2020-12-27 19:43:05 +00:00
2021-10-28 00:53:11 +00:00
# List installed items for deletion
download_select_delete( ) {
2020-12-22 12:02:18 +00:00
# Configure the menu
2021-10-28 00:53:11 +00:00
menu_text_zenity = " Select the $download_type you want to remove: "
menu_text_terminal = " Select the $download_type you want to remove: "
2020-12-27 22:27:00 +00:00
menu_text_height = "65"
2021-10-28 00:53:11 +00:00
goback = " Return to the $download_type management menu "
unset installed_items
2020-12-25 16:24:10 +00:00
unset menu_options
unset menu_actions
2020-12-22 12:02:18 +00:00
2021-10-28 00:53:11 +00:00
# Create an array containing all directories in the download_dir
for items_list in " $download_dir " /*; do
if [ -d " $items_list " ] ; then
installed_items += ( " $items_list " )
2020-12-25 16:24:10 +00:00
fi
done
2021-10-28 00:53:11 +00:00
# Create menu options for the installed items
for ( ( i = 0; i<" ${# installed_items [@] } " ; i++ ) ) ; do
menu_options += ( " $( basename " ${ installed_items [i] } " ) " )
menu_actions += ( " download_delete $i " )
2020-12-22 12:02:18 +00:00
done
2021-10-28 00:53:11 +00:00
2020-12-25 16:24:10 +00:00
# Complete the menu by adding the option to go back to the previous menu
menu_options += ( " $goback " )
2020-12-27 20:40:54 +00:00
menu_actions += ( ":" ) # no-op
2020-12-27 22:27:00 +00:00
# Calculate the total height the menu should be
2021-01-30 19:45:38 +00:00
menu_height = " $(( $menu_option_height * ${# menu_options [@] } + $menu_text_height )) "
2020-12-27 22:27:00 +00:00
if [ " $menu_height " -gt "400" ] ; then
menu_height = "400"
fi
2021-10-28 00:53:11 +00:00
2021-09-18 19:51:57 +00:00
# Set the label for the cancel button
cancel_label = "Go Back"
2021-10-28 00:53:11 +00:00
2020-12-22 12:02:18 +00:00
# Call the menu function. It will use the options as configured above
menu
}
2021-10-28 00:53:11 +00:00
# Download and install the selected item
# Note: The variables download_versions, contributor_url, and download_url_type
2021-01-01 01:28:34 +00:00
# are expected to be set before calling this function
2021-10-28 00:53:11 +00:00
download_install( ) {
2021-01-01 01:55:44 +00:00
# This function expects an index number for the array
2021-10-28 00:53:11 +00:00
# download_versions to be passed in as an argument
2020-12-27 19:12:20 +00:00
if [ -z " $1 " ] ; then
2021-10-28 00:53:11 +00:00
debug_print exit "Script error: The download_install function expects a numerical argument. Aborting."
2020-12-27 19:12:20 +00:00
fi
2021-01-01 01:28:34 +00:00
2021-10-28 00:53:11 +00:00
# Get the filename including file extension
download_file = " ${ download_versions [ $1 ] } "
2021-01-01 01:28:34 +00:00
2021-10-28 00:53:11 +00:00
# Get the selected item name minus the file extension
2021-01-03 13:49:13 +00:00
# To add new file extensions, handle them here and in
2021-10-28 00:53:11 +00:00
# the download_select_install function below
case " $download_file " in
2021-01-01 01:28:34 +00:00
*.tar.gz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " $download_file " .tar.gz) "
2021-01-01 01:28:34 +00:00
; ;
*.tgz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " $download_file " .tgz) "
2021-01-01 01:28:34 +00:00
; ;
2021-06-08 15:09:25 +00:00
*.tar.xz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " $download_file " .tar.xz) "
2021-06-08 15:09:25 +00:00
; ;
2021-01-01 01:28:34 +00:00
*)
2021-10-28 00:53:11 +00:00
debug_print exit "Unknown archive filetype in download_install function. Aborting."
2021-01-01 01:28:34 +00:00
; ;
esac
2021-10-28 00:53:11 +00:00
# Get the selected download url
2021-01-03 13:49:13 +00:00
# To add new sources, handle them here and in the
2021-10-28 00:53:11 +00:00
# download_select_install function below
if [ " $download_url_type " = "github" ] ; then
download_url = " $( curl -s " $contributor_url " | grep " browser_download_url.* $download_file " | cut -d \" -f4) "
2020-12-27 21:32:55 +00:00
else
2021-10-28 00:53:11 +00:00
debug_print exit " Script error: Unknown api/url format in ${ download_type } _sources array. Aborting. "
2020-12-27 21:32:55 +00:00
fi
2020-12-27 19:12:20 +00:00
# Sanity check
2021-10-28 00:53:11 +00:00
if [ -z " $download_url " ] ; then
message warning " Could not find the requested ${ download_type } . The source API may be down or rate limited. "
2020-12-27 19:12:20 +00:00
return 1
fi
2021-10-28 00:53:11 +00:00
# Download the item to the tmp directory
debug_print continue " Downloading $download_url into $tmp_dir / $download_file ... "
2021-01-31 16:11:38 +00:00
if [ " $use_zenity " -eq 1 ] ; then
2021-01-12 01:01:47 +00:00
# Format the curl progress bar for zenity
2021-01-14 00:06:36 +00:00
mkfifo " $tmp_dir /lugpipe "
2021-10-28 00:53:11 +00:00
cd " $tmp_dir " && curl -#LO " $download_url " > " $tmp_dir /lugpipe " 2>& 1 & curlpid = " $! "
2021-01-14 00:06:36 +00:00
stdbuf -oL tr '\r' '\n' < " $tmp_dir /lugpipe " | \
grep --line-buffered -ve "100" | grep --line-buffered -o "[0-9]*\.[0-9]" | \
2021-01-12 01:01:47 +00:00
(
2021-01-14 00:06:36 +00:00
trap 'kill "$curlpid"' ERR
2021-10-28 00:53:11 +00:00
zenity --progress --auto-close --title= "Star Citizen LUG Helper" --text= " Downloading ${ download_type } . This might take a moment.\n " 2>/dev/null
2021-01-12 01:01:47 +00:00
)
2021-01-14 00:06:36 +00:00
2021-01-12 01:01:47 +00:00
if [ " $? " -eq 1 ] ; then
# User clicked cancel
2021-10-28 00:53:11 +00:00
debug_print continue " Download aborted. Removing $tmp_dir / $download_file ... "
rm " $tmp_dir / $download_file "
2021-01-14 00:06:36 +00:00
rm " $tmp_dir /lugpipe "
2021-01-12 01:01:47 +00:00
return 1
fi
2021-01-14 00:06:36 +00:00
rm " $tmp_dir /lugpipe "
2021-01-12 01:01:47 +00:00
else
# Standard curl progress bar
2021-10-28 00:53:11 +00:00
( cd " $tmp_dir " && curl -LO " $download_url " )
2021-01-12 01:01:47 +00:00
fi
2021-01-01 01:28:34 +00:00
# Sanity check
2021-10-28 00:53:11 +00:00
if [ ! -f " $tmp_dir / $download_file " ] ; then
debug_print exit " Script error: The requested $download_type file was not downloaded. Aborting "
2021-01-01 01:28:34 +00:00
fi
2021-10-28 02:30:39 +00:00
# Extract the archive to the tmp directory
debug_print continue " Extracting $download_type into $tmp_dir / $download_name ... "
if [ " $use_zenity " -eq 1 ] ; then
# Use Zenity progress bar
mkdir " $tmp_dir / $download_name " && tar -xf " $tmp_dir / $download_file " -C " $tmp_dir / $download_name " | \
zenity --progress --pulsate --no-cancel --auto-close --title= "Star Citizen LUG Helper" --text= " Extracting ${ download_type } ...\n " 2>/dev/null
else
mkdir " $tmp_dir / $download_name " && tar -xf " $tmp_dir / $download_file " -C " $tmp_dir / $download_name "
fi
# Check the contents of the extracted archive to determine the
# directory structure we must create upon installation
num_dirs = 0
num_files = 0
for extracted_item in " $tmp_dir / $download_name " /*; do
if [ -d " $extracted_item " ] ; then
2021-11-22 02:24:57 +00:00
num_dirs = " $(( $num_dirs + 1 )) "
2021-10-28 04:35:43 +00:00
extracted_dir = " $( basename " $extracted_item " ) "
2021-10-28 02:30:39 +00:00
elif [ -f " $extracted_item " ] ; then
2021-11-22 02:24:57 +00:00
num_files = " $(( $num_files + 1 )) "
2021-10-28 02:30:39 +00:00
fi
done
# Create the correct directory structure and install the item
if [ " $num_dirs " -eq 0 ] && [ " $num_files " -eq 0 ] ; then
# Sanity check
message warning "The downloaded archive is empty. There is nothing to do."
elif [ " $num_dirs " -eq 1 ] && [ " $num_files " -eq 0 ] ; then
# If the archive contains only one directory, install that directory
2021-10-28 16:30:39 +00:00
# We rename it to the name of the archive in case it is different
# so we can easily detect installed items in download_select_install()
debug_print continue " Installing $download_type into $download_dir / $download_name ... "
2021-10-28 02:30:39 +00:00
if [ " $use_zenity " -eq 1 ] ; then
# Use Zenity progress bar
2021-10-28 16:30:39 +00:00
mkdir -p " $download_dir " && cp -r " $tmp_dir / $download_name / $extracted_dir " " $download_dir / $download_name " | \
2021-10-28 02:30:39 +00:00
zenity --progress --pulsate --no-cancel --auto-close --title= "Star Citizen LUG Helper" --text= " Installing ${ download_type } ...\n " 2>/dev/null
else
2021-10-28 16:30:39 +00:00
mkdir -p " $download_dir " && cp -r " $tmp_dir / $download_name / $extracted_dir " " $download_dir / $download_name "
2021-10-28 02:30:39 +00:00
fi
2021-10-28 04:35:43 +00:00
# We need to restart Lutris for the download to be detected
2021-10-28 02:30:39 +00:00
lutris_needs_restart = "true"
2021-10-28 06:02:48 +00:00
# Store the final name of the downloaded directory
2021-10-28 16:30:39 +00:00
downloaded_item_name = " $download_name "
2021-10-28 04:35:43 +00:00
# Trigger the post_download() function
2022-01-01 21:12:14 +00:00
display_post_download_msg = "true"
2021-10-28 02:30:39 +00:00
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
debug_print continue " Installing $download_type into $download_dir / $download_name ... "
if [ " $use_zenity " -eq 1 ] ; then
# Use Zenity progress bar
mkdir -p " $download_dir / $download_name " && cp -r " $tmp_dir " /" $download_name " /* " $download_dir " /" $download_name " | \
zenity --progress --pulsate --no-cancel --auto-close --title= "Star Citizen LUG Helper" --text= " Installing ${ download_type } ...\n " 2>/dev/null
else
mkdir -p " $download_dir / $download_name " && cp -r " $tmp_dir " /" $download_name " /* " $download_dir " /" $download_name "
fi
2021-10-28 04:35:43 +00:00
# We need to restart Lutris for the download to be detected
2021-10-28 02:30:39 +00:00
lutris_needs_restart = "true"
2021-10-28 06:02:48 +00:00
# Store the final name of the downloaded directory
downloaded_item_name = " $download_name "
2021-10-28 04:35:43 +00:00
# Trigger the post_download() function
2022-01-01 21:12:14 +00:00
display_post_download_msg = "true"
2021-10-28 02:30:39 +00:00
else
# Some unexpected combination of directories and files
debug_print exit "Script error: Unexpected archive contents in download_install function. Aborting"
exit 0
fi
2021-01-01 01:28:34 +00:00
# Cleanup tmp download
2021-10-28 04:35:43 +00:00
debug_print continue " Cleaning up $tmp_dir / $download_file ... "
2021-10-28 00:53:11 +00:00
rm " $tmp_dir / $download_file "
2020-12-22 12:02:18 +00:00
}
2020-12-27 19:43:05 +00:00
2021-10-28 00:53:11 +00:00
# List available items for download
download_select_install( ) {
# This function expects an element number for the sources array
# to be passed in as an argument
2020-12-27 16:11:20 +00:00
if [ -z " $1 " ] ; then
2021-10-28 00:53:11 +00:00
debug_print exit "Script error: The download_select_install function expects a numerical argument. Aborting."
2020-12-27 16:11:20 +00:00
fi
2021-10-28 00:53:11 +00:00
2021-09-18 16:57:22 +00:00
# Store info from the selected contributor
2021-10-28 00:53:11 +00:00
contributor_name = " ${ download_sources [ $1 ] } "
contributor_url = " ${ download_sources [ $1 +1] } "
2021-01-01 01:28:34 +00:00
# Check the provided contributor url to make sure we know how to handle it
2021-01-03 13:49:13 +00:00
# To add new sources, add them here and handle in the if statement
2021-10-28 00:53:11 +00:00
# just below and the download_install function above
2021-01-01 01:28:34 +00:00
case " $contributor_url " in
https://api.github.com*)
2021-10-28 00:53:11 +00:00
download_url_type = "github"
2020-12-27 15:58:00 +00:00
; ;
*)
2021-10-28 00:53:11 +00:00
debug_print exit " Script error: Unknown api/url format in ${ download_type } _sources array. Aborting. "
2020-12-27 15:58:00 +00:00
; ;
2020-12-22 12:02:18 +00:00
esac
2022-01-07 19:22:59 +00:00
2021-10-28 00:53:11 +00:00
# For runners, check GlibC version against runner requirements
2022-01-07 19:22:59 +00:00
if [ " $download_type " = "runner" ] && [ " $contributor_name " = "/dev/null" ] ; then
2021-06-15 13:34:40 +00:00
required_glibc = "2.33"
2021-09-18 16:57:22 +00:00
system_glibc = " $( ldd --version | awk '/ldd/{print $NF}' ) "
2022-01-07 19:22:59 +00:00
# Sort the versions and check if the installed glibc is smaller
if [ " $required_glibc " != " $system_glibc " ] &&
[ " $system_glibc " = " $( printf " $system_glibc \n $required_glibc " | sort -V | head -n1) " ] ; then
2021-09-18 16:57:22 +00:00
message warning " Your glibc version is incompatible with the selected runner.\n\nSystem glibc: v $system_glibc \nMinimum required glibc: v $required_glibc "
return 1
2021-06-15 13:34:40 +00:00
fi
fi
2020-12-27 15:58:00 +00:00
2021-10-28 00:53:11 +00:00
# Fetch a list of versions from the selected contributor
2021-01-03 13:49:13 +00:00
# To add new sources, handle them here, in the if statement
2021-10-28 00:53:11 +00:00
# just above, and the download_install function above
if [ " $download_url_type " = "github" ] ; then
download_versions = ( $( curl -s " $contributor_url " | awk '/browser_download_url/ {print $2}' | grep -vE "*.sha512sum" | xargs basename -a) )
2021-01-01 01:28:34 +00:00
else
2021-10-28 00:53:11 +00:00
debug_print exit " Script error: Unknown api/url format in ${ download_type } _sources array. Aborting. "
2021-01-01 01:28:34 +00:00
fi
2020-12-27 15:58:00 +00:00
# Sanity check
2021-10-28 00:53:11 +00:00
if [ " ${# download_versions [@] } " -eq 0 ] ; then
message warning " No $download_type versions were found. The source API may be down or rate limited. "
2020-12-27 15:58:00 +00:00
return 1
2021-01-01 01:28:34 +00:00
fi
2020-12-27 15:58:00 +00:00
2020-12-22 12:02:18 +00:00
# Configure the menu
2021-10-28 00:53:11 +00:00
menu_text_zenity = " Select the $download_type you want to install: "
menu_text_terminal = " Select the $download_type you want to install: "
2020-12-27 22:27:00 +00:00
menu_text_height = "65"
2021-10-28 00:53:11 +00:00
goback = " Return to the $download_type management menu "
2020-12-27 15:58:00 +00:00
unset menu_options
unset menu_actions
2020-12-22 12:02:18 +00:00
2021-01-01 01:55:44 +00:00
# Iterate through the versions, check if they are installed,
# and add them to the menu options
2021-01-03 13:49:13 +00:00
# To add new file extensions, handle them here and in
2021-10-28 00:53:11 +00:00
# the download_install function above
for ( ( i = 0; i<" $max_download_items " && i<" ${# download_versions [@] } " ; i++ ) ) ; do
# Get the file name minus the extension
case " ${ download_versions [i] } " in
2021-01-01 01:28:34 +00:00
*.tar.gz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " ${ download_versions [i] } " .tar.gz) "
2021-01-01 01:28:34 +00:00
; ;
*.tgz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " ${ download_versions [i] } " .tgz) "
2021-01-01 01:28:34 +00:00
; ;
2021-06-08 15:09:25 +00:00
*.tar.xz)
2021-10-28 00:53:11 +00:00
download_name = " $( basename " ${ download_versions [i] } " .tar.xz) "
2021-07-27 18:32:07 +00:00
; ;
2021-01-01 01:28:34 +00:00
*)
2021-10-28 00:53:11 +00:00
debug_print exit "Unknown archive filetype in download_select_install function. Aborting."
2021-01-01 01:28:34 +00:00
; ;
esac
2021-10-28 00:53:11 +00:00
# Add the file names to the menu
if [ -d " $download_dir / $download_name " ] ; then
menu_options += ( " $download_name [installed] " )
2020-12-22 12:02:18 +00:00
else
2021-10-28 00:53:11 +00:00
menu_options += ( " $download_name " )
2020-12-22 12:02:18 +00:00
fi
2021-10-28 00:53:11 +00:00
menu_actions += ( " download_install $i " )
2020-12-22 12:02:18 +00:00
done
2020-12-27 15:58:00 +00:00
# Complete the menu by adding the option to go back to the previous menu
menu_options += ( " $goback " )
2020-12-27 20:40:54 +00:00
menu_actions += ( ":" ) # no-op
2020-12-27 22:27:00 +00:00
# Calculate the total height the menu should be
2021-01-30 19:45:38 +00:00
menu_height = " $(( $menu_option_height * ${# menu_options [@] } + $menu_text_height )) "
2020-12-27 22:27:00 +00:00
if [ " $menu_height " -gt "400" ] ; then
menu_height = "400"
fi
2020-12-27 15:58:00 +00:00
2021-09-18 19:51:57 +00:00
# Set the label for the cancel button
cancel_label = "Go Back"
2020-12-22 12:02:18 +00:00
# Call the menu function. It will use the options as configured above
menu
}
2021-10-28 00:53:11 +00:00
# Manage downloads
#
# This function expects the following variables to be set:
#
# - The string download_sources is a formatted array containing the URLs
# of items to download. It should be pointed to the appropriate
# array set at the top of the script using indirect expansion.
# See runner_sources at the top and runner_manage() below for examples.
# - The string download_dir should contain the location the downloaded item
# will be installed to.
# - The string "download_menu_heading" should contain the type of item
# being downloaded. It will appear in the menu heading.
# - The string "download_menu_description" should contain a description of
# the item being downloaded. It will appear in the menu subheading.
# - The integer "download_menu_height" specifies the height of the zenity menu.
#
# This function also expects one string argument containing the type of item to
# be downloaded. ie. runner or dxvk.
#
# See runner_manage below for a configuration example.
download_manage( ) {
# This function expects a string to be passed as an argument
if [ -z " $1 " ] ; then
debug_print exit "Script error: The download_manage function expects a string argument. Aborting."
fi
2020-12-27 19:34:09 +00:00
# Check if Lutris is installed
if [ ! -x " $( command -v lutris) " ] ; then
message info "Lutris does not appear to be installed."
2020-12-27 20:40:54 +00:00
return 0
2020-12-27 19:34:09 +00:00
fi
2021-10-28 00:53:11 +00:00
if [ ! -d " $download_dir " ] ; then
message info " Lutris $download_type directory not found. Unable to continue.\n\n $download_dir "
2021-01-01 19:52:43 +00:00
return 0
fi
2021-10-28 00:53:11 +00:00
# Get the type of item we're downloading from the function arguments
download_type = " $1 "
# The download management menu will loop until the user cancels
2021-01-24 21:15:35 +00:00
looping_menu = "true"
while [ " $looping_menu " = "true" ] ; do
2020-12-27 20:40:54 +00:00
# Configure the menu
2021-10-28 00:53:11 +00:00
menu_text_zenity = " <b><big>Manage Your $download_menu_heading </big>\n\n $download_menu_description </b>\n\nYou may choose from the following options: "
menu_text_terminal = " Manage Your $download_menu_heading \n\n $download_menu_description \nYou may choose from the following options: "
menu_text_height = " $download_menu_height "
2020-12-27 20:40:54 +00:00
# Configure the menu options
2021-10-28 00:53:11 +00:00
delete = " Remove an installed $download_type "
2020-12-27 20:40:54 +00:00
back = "Return to the main menu"
2021-01-01 01:28:34 +00:00
unset menu_options
unset menu_actions
2021-10-28 00:53:11 +00:00
# Loop through the download_sources array and create a menu item
2021-01-01 01:55:44 +00:00
# for each one. Even numbered elements will contain the runner name
2021-10-28 00:53:11 +00:00
for ( ( i = 0; i<" ${# download_sources [@] } " ; i = i+2 ) ) ; do
2021-01-01 01:28:34 +00:00
# Set the options to be displayed in the menu
2021-10-28 00:53:11 +00:00
menu_options += ( " Install a $download_type from ${ download_sources [i] } " )
2021-01-01 01:28:34 +00:00
# Set the corresponding functions to be called for each of the options
2021-10-28 00:53:11 +00:00
menu_actions += ( " download_select_install $i " )
2021-01-01 01:28:34 +00:00
done
2021-10-28 00:53:11 +00:00
# Complete the menu by adding options to uninstall an item
2021-01-01 01:55:44 +00:00
# or go back to the previous menu
2021-01-01 01:28:34 +00:00
menu_options += ( " $delete " " $back " )
2021-10-28 00:53:11 +00:00
menu_actions += ( "download_select_delete" "menu_loop_done" )
2020-12-27 20:40:54 +00:00
2020-12-27 22:27:00 +00:00
# Calculate the total height the menu should be
2021-01-30 19:45:38 +00:00
menu_height = " $(( $menu_option_height * ${# menu_options [@] } + $menu_text_height )) "
2020-12-27 22:27:00 +00:00
2021-09-18 19:51:57 +00:00
# Set the label for the cancel button
cancel_label = "Go Back"
2020-12-27 20:40:54 +00:00
# Call the menu function. It will use the options as configured above
menu
2022-01-01 21:12:14 +00:00
# Perform post-download actions and display messages or instructions
post_download
2020-12-27 20:40:54 +00:00
done
2020-12-22 12:02:18 +00:00
}
2021-10-28 00:53:11 +00:00
# Configure the download_manage function for runners
runner_manage( ) {
2021-10-28 04:35:43 +00:00
# Set some defaults
lutris_needs_restart = "false"
2022-01-01 21:12:14 +00:00
display_post_download_msg = "false"
2021-10-28 04:35:43 +00:00
2021-10-28 03:28:21 +00:00
# Use indirect expansion to point download_sources
# to the runner_sources array set at the top of the script
2021-10-28 00:53:11 +00:00
declare -n download_sources = runner_sources
download_dir = " $runners_dir "
2021-10-18 19:27:49 +00:00
2021-10-28 00:53:11 +00:00
# Configure the text displayed in the menus
download_menu_heading = "Lutris Runners"
download_menu_description = "The runners listed below are wine builds created for Star Citizen"
download_menu_height = "140"
2021-10-18 19:27:49 +00:00
2021-10-28 04:35:43 +00:00
# Set the post download instructions
2021-10-28 06:18:15 +00:00
# Format:
# A header is automatically displayed that reads: Download Complete
2021-11-10 20:04:48 +00:00
# msg_text is displayed below the header
# msg_italics is displayed below that in italics when zenity is in use
2021-10-28 06:18:15 +00:00
# Lastly, the downloaded directory name is automatically displayed
2022-01-01 20:17:07 +00:00
post_download_msg_text = "Select the following runner in Lutris from the dropdown menu under:"
2021-11-10 20:04:48 +00:00
post_download_msg_italics = "Configure->Runner Options->Wine version"
2021-10-28 04:35:43 +00:00
2021-10-28 00:53:11 +00:00
# Call the download_manage function with the above configuration
2021-10-28 03:28:21 +00:00
# The argument passed to the function is used for special handling
# and displayed in the menus and dialogs.
2021-10-28 00:53:11 +00:00
download_manage "runner"
2021-10-18 19:27:49 +00:00
}
2021-10-28 00:53:11 +00:00
# Configure the download_manage function for dxvks
2021-10-18 19:27:49 +00:00
dxvk_manage( ) {
2021-10-28 04:35:43 +00:00
# Set some defaults
lutris_needs_restart = "false"
2022-01-01 21:12:14 +00:00
display_post_download_msg = "false"
2021-10-28 04:35:43 +00:00
2021-10-28 03:28:21 +00:00
# Use indirect expansion to point download_sources
# to the dxvk_sources array set at the top of the script
2021-10-28 00:53:11 +00:00
declare -n download_sources = dxvk_sources
download_dir = " $dxvk_dir "
2021-10-18 19:27:49 +00:00
2021-10-28 00:53:11 +00:00
# Configure the text displayed in the menus
download_menu_heading = "DXVK Versions"
download_menu_description = "The DXVK versions below may help improve game performance"
download_menu_height = "140"
2021-10-18 19:27:49 +00:00
2021-10-28 04:35:43 +00:00
# Set the post download instructions
2021-10-28 06:18:15 +00:00
# Format:
# A header is automatically displayed that reads: Download Complete
2021-11-10 20:04:48 +00:00
# msg_text is displayed below the header
# msg_italics is displayed below that in italics when zenity is in use
2021-10-28 06:18:15 +00:00
# Lastly, the downloaded directory name is automatically displayed
2022-01-01 20:17:07 +00:00
post_download_msg_text = "Type the following DXVK name into your Lutris settings under:"
2021-11-10 20:04:48 +00:00
post_download_msg_italics = "Configure->Runner Options->DXVK version"
2021-10-28 04:35:43 +00:00
2021-10-28 00:53:11 +00:00
# Call the download_manage function with the above configuration
2021-10-28 03:28:21 +00:00
# The argument passed to the function is used for special handling
# and displayed in the menus and dialogs.
2021-10-28 00:53:11 +00:00
download_manage "dxvk"
2021-10-18 19:27:49 +00:00
}
2022-01-01 20:52:53 +00:00
#-------------------------- end download functions -----------------------------#
2020-12-27 21:45:31 +00:00
2021-12-29 23:11:33 +00:00
# Deploy Easy Anti-Cheat Workaround
eac_workaround( ) {
# Get/set directory paths
getdirs
2022-01-01 17:49:07 +00:00
if [ " $? " -eq 1 ] ; then
# User cancelled and wants to return to the main menu
# or there was an error
return 0
fi
2021-12-29 23:11:33 +00:00
# Set the EAC directory path and hosts modification
eac_dir = " $wine_prefix /drive_c/users/ $USER /AppData/Roaming/EasyAntiCheat "
eac_hosts = "127.0.0.1 modules-cdn.eac-prod.on.epicgames.com"
# Check if EAC is installed
if [ ! -d " $eac_dir " ] ; then
2022-01-01 17:56:13 +00:00
message info "Easy Anti-Cheat does not appear to be installed yet.\nThere is nothing to do!"
2021-12-29 23:11:33 +00:00
return 1
fi
# Configure message variables
eac_title = "Easy Anti-Cheat Workaround"
eac_hosts_formatted = " $eac_hosts "
eac_dir_formatted = " $eac_dir "
if [ " $use_zenity " -eq 1 ] ; then
eac_title = " <b> $eac_title </b> "
eac_hosts_formatted = " <i> $eac_hosts_formatted </i> "
eac_dir_formatted = " <i> $eac_dir_formatted </i> "
fi
if message question " $eac_title \n\nThe following entry will be added to /etc/hosts:\n $eac_hosts_formatted \n\nThe following directory will be deleted:\n $eac_dir_formatted \n\n\nTo revert these changes, delete the above line from\n/etc/hosts and relaunch the game\n\nDo you want to proceed? " ; then
debug_print continue "Editing hosts file..."
# Use pollkit's pkexec for gui with a fallback to sudo
if [ -x " $( command -v pkexec) " ] ; then
pkexec sh -c " echo $eac_hosts '#Star Citizen EAC workaround' >> /etc/hosts "
else
sudo sh -c " echo $eac_hosts '#Star Citizen EAC workaround' >> /etc/hosts "
fi
debug_print continue " Deleting $eac_dir ... "
rm -r " $eac_dir "
message info "Easy Anti-Cheat workaround has been deployed!"
fi
}
2022-01-01 20:52:53 +00:00
# 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
}
2022-01-07 02:08:01 +00:00
# Display the LUG Wiki
display_wiki( ) {
# Display a message containing the URL
message info " See the Wiki for our Quick-Start Guide, Manual Installation instructions,\nPerformance Tuning, and Common Issues and Solutions:\n\n $lug_wiki "
}
2022-01-01 20:52:53 +00:00
# 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
}
2021-01-24 21:15:35 +00:00
# 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"
2021-09-20 03:13:46 +00:00
dirs_msg = "Display Helper and Star Citizen directories"
2022-01-07 02:08:01 +00:00
wiki_msg = "Show the LUG Wiki"
2021-01-24 21:15:35 +00:00
reset_msg = "Reset Helper configs"
quit_msg = "Return to the main menu"
# Set the options to be displayed in the menu
2022-01-07 02:08:01 +00:00
menu_options = ( " $version_msg " " $sanitize_msg " " $shaders_msg " " $vidcache_msg " " $dirs_msg " " $wiki_msg " " $reset_msg " " $quit_msg " )
2021-01-24 21:15:35 +00:00
# Set the corresponding functions to be called for each of the options
2022-01-07 02:08:01 +00:00
menu_actions = ( "set_version" "sanitize" "rm_shaders" "rm_dxvkcache" "display_dirs" "display_wiki" "reset_helper" "menu_loop_done" )
2021-01-24 21:15:35 +00:00
# Calculate the total height the menu should be
2021-01-30 19:45:38 +00:00
menu_height = " $(( $menu_option_height * ${# menu_options [@] } + $menu_text_height )) "
2021-09-18 19:51:57 +00:00
# Set the label for the cancel button
cancel_label = "Go Back"
2021-01-24 21:15:35 +00:00
# Call the menu function. It will use the options as configured above
menu
done
}
2021-01-01 15:41:07 +00:00
# Get a random Penguin's Star Citizen referral code
referral_randomizer( ) {
# Populate the referral codes array
2022-01-02 02:51:13 +00:00
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" )
2021-01-01 15:41:07 +00:00
# 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 " ) ] } "
2021-01-14 00:07:43 +00:00
message info " Your random Penguin's referral code is:\n\n $random_code \n\nThank you! "
2021-01-01 15:41:07 +00:00
}
2021-01-17 02:55:58 +00:00
# Toggle between the LIVE and PTU game directories for all Helper functions
2020-12-27 19:43:05 +00:00
set_version( ) {
2021-03-13 17:21:46 +00:00
if [ " $live_or_ptu " = " $live_dir " ] ; then
live_or_ptu = " $ptu_dir "
2021-01-17 02:55:58 +00:00
message info "The Helper will now target your Star Citizen PTU installation."
2021-03-13 17:21:46 +00:00
elif [ " $live_or_ptu " = " $ptu_dir " ] ; then
live_or_ptu = " $live_dir "
2021-01-17 02:55:58 +00:00
message info "The Helper will now target your Star Citizen LIVE installation."
2020-12-27 19:43:05 +00:00
else
2021-01-17 02:33:15 +00:00
debug_print continue "Unexpected game version provided. Defaulting to the LIVE installation."
2021-03-13 17:21:46 +00:00
live_or_ptu = " $live_dir "
2020-12-27 19:43:05 +00:00
fi
}
2021-01-17 02:51:00 +00:00
# Delete the helper's config directory
reset_helper( ) {
# Delete the shader directory
if message question " All config files will be deleted from:\n\n $conf_dir / $conf_subdir \n\nDo you want to proceed? " ; then
debug_print continue " Deleting $conf_dir / $conf_subdir /*.conf... "
rm " $conf_dir / $conf_subdir / " *.conf
message info "The Helper has been reset!"
fi
}
2021-09-18 16:57:22 +00:00
# Get the latest release version of a repo. Expects "user/repo_name" as input
# Credits for this go to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
get_latest_release( ) {
# Sanity check
if [ " $# " -lt 1 ] ; then
debug_print exit "Script error: The get_latest_release function expects one argument. Aborting."
fi
curl --silent " https://api.github.com/repos/ $1 /releases/latest " | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
2020-12-27 19:43:05 +00:00
quit( ) {
exit 0
}
2020-12-22 12:02:18 +00:00
2020-08-15 02:11:31 +00:00
############################################################################
# MAIN
############################################################################
# Check if Zenity is available
2021-01-31 16:11:38 +00:00
use_zenity = 0
2020-08-15 02:11:31 +00:00
if [ -x " $( command -v zenity) " ] ; then
2021-01-31 16:11:38 +00:00
use_zenity = 1
2020-08-02 18:12:02 +00:00
fi
2020-08-15 02:11:31 +00:00
2021-10-28 04:35:43 +00:00
# Set defaults
2021-03-13 17:21:46 +00:00
live_or_ptu = " $live_dir "
2020-08-18 01:57:24 +00:00
2021-01-30 19:32:16 +00:00
# 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
2021-01-31 16:10:23 +00:00
--help | -h )
2021-01-30 19:32:16 +00:00
printf " Star Citizen Linux Users Group Helper Script
Usage: lug-helper <options>
2021-01-31 16:10:23 +00:00
-p, --preflight-check Run system optimization checks
2022-01-01 18:03:09 +00:00
-i, --install Install Star Citizen
2021-01-31 16:10:23 +00:00
-m, --manage-runners Install or remove Lutris runners
2021-11-27 05:17:24 +00:00
-k, --manage-dxvk Install or remove DXVK versions
2021-01-31 16:10:23 +00:00
-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)
2021-10-11 02:06:00 +00:00
-g, --use-gui= [ yes| no] Use Zenity GUI if available ( default yes)
2021-01-31 16:10:23 +00:00
-r, --get-referral Get a random LUG member' s Star Citizen referral code
2021-10-11 02:06:00 +00:00
-d, --show-directories Show all Star Citizen and LUG Helper directories
2021-01-31 16:10:23 +00:00
-x, --reset-helper Delete saved lug-helper configs
2021-01-30 19:32:16 +00:00
"
exit 0
; ;
2021-01-31 16:10:23 +00:00
--preflight-check | -p )
cargs += ( "preflight_check" )
2021-01-30 19:32:16 +00:00
; ;
2022-01-01 18:03:09 +00:00
--install | -i )
cargs += ( "install_game" )
; ;
2021-01-31 16:10:23 +00:00
--manage-runners | -m )
cargs += ( "runner_manage" )
2021-01-30 19:32:16 +00:00
; ;
2021-11-27 05:17:24 +00:00
--manage-dxvk | -k )
cargs += ( "dxvk_manage" )
; ;
2021-01-31 16:10:23 +00:00
--delete-user-folder | -u )
cargs += ( "sanitize" )
2021-01-30 19:32:16 +00:00
; ;
2021-01-31 16:10:23 +00:00
--delete-shaders | -s )
cargs += ( "rm_shaders" )
2021-01-30 19:32:16 +00:00
; ;
2021-01-31 16:10:23 +00:00
--delete-dxvk-cache | -c )
cargs += ( "rm_dxvkcache" )
2021-01-30 19:32:16 +00:00
; ;
2021-01-31 16:10:23 +00:00
--target= * | -t= * )
live_or_ptu = " $( echo " $1 " | cut -d'=' -f2) "
if [ " $live_or_ptu " = "live" ] || [ " $live_or_ptu " = "LIVE" ] ; then
2021-03-13 17:21:46 +00:00
live_or_ptu = " $live_dir "
2021-01-31 16:10:23 +00:00
elif [ " $live_or_ptu " = "ptu" ] || [ " $live_or_ptu " = "PTU" ] ; then
2021-03-13 17:21:46 +00:00
live_or_ptu = " $ptu_dir "
2021-01-31 16:10:23 +00:00
else
printf " $0 : Invalid option ' $1 '\n "
exit 0
fi
2021-01-30 19:32:16 +00:00
; ;
2021-01-31 16:10:23 +00:00
--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
2021-01-31 16:11:38 +00:00
use_zenity = " $( echo " $1 " | cut -d'=' -f2) "
2021-01-31 16:33:31 +00:00
if [ " $use_zenity " = "yes" ] || [ " $use_zenity " = "YES" ] || [ " $use_zenity " = "1" ] ; then
2021-01-31 16:11:38 +00:00
use_zenity = 1
2021-01-31 16:33:31 +00:00
elif [ " $use_zenity " = "no" ] || [ " $use_zenity " = "NO" ] || [ " $use_zenity " = "0" ] ; then
2021-01-31 16:11:38 +00:00
use_zenity = 0
2021-01-31 16:10:23 +00:00
else
printf " $0 : Invalid option ' $1 '\n "
exit 0
fi
fi
2021-01-30 19:32:16 +00:00
; ;
2021-01-31 16:10:23 +00:00
--get-referral | -r )
cargs += ( "referral_randomizer" )
; ;
2021-10-11 02:06:00 +00:00
--show-directories | -d )
cargs += ( "display_dirs" )
; ;
2021-01-31 16:10:23 +00:00
--reset-helper | -x )
cargs += ( "reset_helper" )
; ;
* )
2021-01-30 19:32:16 +00:00
printf " $0 : Invalid option ' $1 '\n "
exit 0
; ;
esac
# Shift forward to the next argument and loop again
shift
done
2021-01-31 16:10:23 +00:00
# Call the requested functions and exit
if [ " ${# cargs [@] } " -gt 0 ] ; then
for ( ( i = 0; i<" ${# cargs [@] } " ; i++ ) ) ; do
${ cargs [i] }
done
exit 0
fi
2021-01-30 19:32:16 +00:00
fi
2022-01-07 20:55:56 +00:00
# Format some URLs for Zenity
if [ " $use_zenity " -eq 1 ] ; then
releases_url = " <a href=' $releases_url '> $releases_url </a> "
lug_wiki = " <a href=' $lug_wiki '> $lug_wiki </a> "
fi
# Check if a newer verison of the script is available
latest_version = " $( get_latest_release " $repo " ) "
# Sort the versions and check if the installed Helper is smaller
if [ " $latest_version " != " $current_version " ] &&
[ " $current_version " = " $( printf " $current_version \n $latest_version " | sort -V | head -n1) " ] ; then
message info " The latest version of the LUG Helper is $latest_version \nYou are using $current_version \n\nYou can download new releases here:\n $releases_url "
fi
2020-08-15 02:11:31 +00:00
# Loop the main menu until the user selects quit
while true; do
2020-09-07 22:51:19 +00:00
# Configure the menu
2021-01-17 02:55:58 +00:00
menu_text_zenity = "<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper!</big>\n\nThis Helper is designed to help optimize your system for Star Citizen</b>\n\nYou may choose from the following options:"
menu_text_terminal = "Welcome, fellow Penguin, to the Star Citizen Linux Users Group Helper!\n\nThis Helper is designed to help optimize your system for Star Citizen\nYou may choose from the following options:"
2020-12-27 22:27:00 +00:00
menu_text_height = "140"
2020-09-07 22:51:19 +00:00
# Configure the menu options
2021-01-24 03:05:23 +00:00
preflight_msg = "Preflight Check (System Optimization)"
2021-12-28 20:40:45 +00:00
install_msg = "Install Star Citizen"
2021-12-29 23:11:33 +00:00
eac_msg = "Deploy Easy Anti-Cheat Workaround"
2020-12-25 16:24:10 +00:00
runners_msg = "Manage Lutris Runners"
2021-10-18 19:27:49 +00:00
dxvk_msg = "Manage DXVK Versions"
2021-09-20 03:13:46 +00:00
maintenance_msg = "Maintenance and Troubleshooting"
2021-01-17 02:51:00 +00:00
randomizer_msg = "Get a random Penguin's Star Citizen referral code"
2020-09-07 22:51:19 +00:00
quit_msg = "Quit"
2020-11-29 13:34:10 +00:00
# Set the options to be displayed in the menu
2021-12-29 23:11:33 +00:00
menu_options = ( " $preflight_msg " " $install_msg " " $eac_msg " " $runners_msg " " $dxvk_msg " " $maintenance_msg " " $randomizer_msg " " $quit_msg " )
2020-09-07 22:51:19 +00:00
# Set the corresponding functions to be called for each of the options
2021-12-29 23:11:33 +00:00
menu_actions = ( "preflight_check" "install_game" "eac_workaround" "runner_manage" "dxvk_manage" "maintenance_menu" "referral_randomizer" "quit" )
2020-12-27 22:27:00 +00:00
# Calculate the total height the menu should be
2021-01-30 19:45:38 +00:00
menu_height = " $(( $menu_option_height * ${# menu_options [@] } + $menu_text_height )) "
2020-09-07 22:51:19 +00:00
2021-09-18 19:51:57 +00:00
# Set the label for the cancel button
cancel_label = "Quit"
2020-11-29 13:34:10 +00:00
# Call the menu function. It will use the options as configured above
2020-09-07 22:51:19 +00:00
menu
2020-08-15 02:11:31 +00:00
done