mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-07-01 13:30:35 +00:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
675621c4c3 | |||
c07e673c0d | |||
b85df29d6d | |||
7f3d84a8bc | |||
6533cf98bd | |||
c7c8cd1ecd | |||
e0d149494d | |||
9800420d73 | |||
eae146ce02 | |||
b4248fb264 | |||
d5dbec7b3f | |||
d4e8298743 | |||
8ee730bf35 | |||
b6eea7b224 | |||
c9c3c07866 | |||
2e883423d3 | |||
12a3a51eb4 | |||
aec6ffbfc0 | |||
96b15262f5 | |||
9986f62566 | |||
a2397c28f0 | |||
e8891b42e6 |
157
lug-helper.sh
157
lug-helper.sh
@ -47,6 +47,12 @@
|
||||
# https://github.com/richardtatum/sc-runner-updater
|
||||
############################################################################
|
||||
|
||||
# Check if script is run as root
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
echo "This script is not supposed to be run as root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for dependencies
|
||||
if [ ! -x "$(command -v curl)" ]; then
|
||||
# Print to stderr and also try warning the user through notify-send
|
||||
@ -75,12 +81,20 @@ conf_subdir="starcitizen-lug"
|
||||
tmp_dir="$(mktemp -d --suffix=".lughelper")"
|
||||
trap 'rm -r "$tmp_dir"' EXIT
|
||||
|
||||
# The game's user subdirectory name
|
||||
user_subdir_name="USER"
|
||||
# The location within the USER directory to which the game exports keybinds
|
||||
keybinds_export_path="Controls/Mappings"
|
||||
######## Game Directories ##################################################
|
||||
|
||||
dxvk_cache_file="StarCitizen.dxvk-cache"
|
||||
# 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"
|
||||
|
||||
# The names of the live/ptu directories
|
||||
live_dir="LIVE"
|
||||
ptu_dir="PTU"
|
||||
|
||||
# Remaining directory paths are set at the end of the getdirs() function
|
||||
|
||||
############################################################################
|
||||
|
||||
# Lutris wine runners directory
|
||||
runners_dir="$data_dir/lutris/runners/wine"
|
||||
@ -92,6 +106,8 @@ runners_dir="$data_dir/lutris/runners/wine"
|
||||
runner_sources=(
|
||||
"RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases"
|
||||
"Molotov/Snatella" "https://api.github.com/repos/snatella/wine-runner-sc/releases"
|
||||
"/dev/null" "https://api.github.com/repos/gort818/wine-sc-lug/releases"
|
||||
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
|
||||
)
|
||||
# Set a maximum number of runner versions to display from each url
|
||||
max_runners=20
|
||||
@ -360,7 +376,7 @@ getdirs() {
|
||||
fi
|
||||
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
|
||||
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
|
||||
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
||||
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
|
||||
debug_print continue "Unexpected game path found in config file, ignoring."
|
||||
game_path=""
|
||||
fi
|
||||
@ -387,15 +403,15 @@ getdirs() {
|
||||
|
||||
# Get the game path
|
||||
if [ -z "$game_path" ]; then
|
||||
if [ -d "$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" ] &&
|
||||
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then
|
||||
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||
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"
|
||||
else
|
||||
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" 2>/dev/null)"; do
|
||||
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/$install_path" 2>/dev/null)"; do
|
||||
if [ "$?" -eq -1 ]; then
|
||||
message warning "An unexpected error has occurred. The Helper is unable to proceed."
|
||||
return 1
|
||||
elif [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
||||
elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
|
||||
message warning "You must select the Star Citizen base game directory.\n\nFor Example: prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||
else
|
||||
# All good or cancel
|
||||
@ -428,17 +444,17 @@ getdirs() {
|
||||
|
||||
# Get the game path
|
||||
if [ -z "$game_path" ]; then
|
||||
if [ -d "$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" ] &&
|
||||
message question "Is this your Star Citizen game directory?\n\n$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then
|
||||
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||
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"
|
||||
else
|
||||
printf "\nEnter the full path to your Star Citizen installation directory (case sensitive)\n"
|
||||
printf "ie. /home/USER/Games/star-citizen/drive_c/Program Files/Roberts Space Industries/StarCitizen\n"
|
||||
while read -rp ": " game_path; do
|
||||
if [ ! -d "$game_path" ]; then
|
||||
printf "That directory is invalid or does not exist. Please try again.\n\n"
|
||||
elif [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
||||
printf "You must enter the full path to the directory named 'StarCitizen'\n\n"
|
||||
elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
|
||||
printf "You must enter the full path to the directory named '$sc_base_dir'\n\n"
|
||||
else
|
||||
break
|
||||
fi
|
||||
@ -452,9 +468,18 @@ getdirs() {
|
||||
echo "$game_path" > "$conf_dir/$conf_subdir/$game_conf"
|
||||
fi
|
||||
|
||||
# Set some remaining directory paths
|
||||
user_dir="$game_path/$live_or_ptu/$user_subdir_name"
|
||||
keybinds_dir="$user_dir/$keybinds_export_path"
|
||||
######## Set remaining directory paths #####################################
|
||||
# $live_or_ptu is set in the set_version() function
|
||||
############################################################################
|
||||
# The game's user directory
|
||||
user_dir="$game_path/$live_or_ptu/USER/Client/0/"
|
||||
# The location within the USER directory to which the game exports keybinds
|
||||
keybinds_dir="$user_dir/Controls/Mappings"
|
||||
# Shaders directory
|
||||
shaders_dir="$user_dir/shaders"
|
||||
# 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"
|
||||
}
|
||||
|
||||
@ -511,6 +536,7 @@ sanitize() {
|
||||
fi
|
||||
}
|
||||
|
||||
#--------------------- begin preflight check functions -----------------------#
|
||||
#------------------------- begin mapcount functions --------------------------#
|
||||
|
||||
# Check if setting vm.max_map_count was successful
|
||||
@ -637,17 +663,27 @@ filelimit_check() {
|
||||
|
||||
#------------------------- end filelimit functions ---------------------------#
|
||||
|
||||
|
||||
# Check total system memory
|
||||
memory_check() {
|
||||
memtotal="$(awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
|
||||
if awk 'BEGIN {exit !("$memtotal" < 15)}'; then
|
||||
memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
|
||||
if [ ${memtotal%.*} -ge "15" ]; then
|
||||
preflight_pass+=("Your system has $memtotal GB of memory.")
|
||||
else
|
||||
preflight_fail+=("Your system has $memtotal GB of memory.\nWe recommend at least 16 GB to avoid crashes.")
|
||||
fi
|
||||
}
|
||||
|
||||
# Check CPU for the required AVX extension
|
||||
avx_check() {
|
||||
if grep -q "avx" /proc/cpuinfo; then
|
||||
preflight_pass+=("Your CPU supports the necessary AVX instruction set.")
|
||||
else
|
||||
preflight_fail+=("Your CPU does not appear to support AVX instructions.\nThis requirement was added to Star Citizen in version 3.11")
|
||||
fi
|
||||
}
|
||||
|
||||
#------------------------- end preflight check functions ---------------------#
|
||||
|
||||
# Delete the shaders directory
|
||||
rm_shaders() {
|
||||
# Get/Set directory paths
|
||||
@ -657,8 +693,6 @@ rm_shaders() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
shaders_dir="$user_dir/shaders"
|
||||
|
||||
# Sanity check
|
||||
if [ ! -d "$shaders_dir" ]; then
|
||||
message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir"
|
||||
@ -683,8 +717,6 @@ rm_dxvkcache() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
dxvk_cache="$game_path/$live_or_ptu/$dxvk_cache_file"
|
||||
|
||||
# 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"
|
||||
@ -789,6 +821,12 @@ runner_install() {
|
||||
*.tgz)
|
||||
runner_name="$(basename "$runner_file" .tgz)"
|
||||
;;
|
||||
*.tar.xz)
|
||||
runner_name="$(basename "$runner_file" .tar.xz)"
|
||||
;;
|
||||
*.sha512sum)
|
||||
runner_name="$(basename "$runner_file" .tar.xz)"
|
||||
;;
|
||||
*)
|
||||
debug_print exit "Unknown archive filetype in runner_install function. Aborting."
|
||||
;;
|
||||
@ -799,6 +837,7 @@ runner_install() {
|
||||
# runner_select_install function below
|
||||
if [ "$runner_url_type" = "github" ]; then
|
||||
runner_dl_url="$(curl -s "$contributor_url" | grep "browser_download_url.*$runner_file" | cut -d \" -f4)"
|
||||
debug_print continue "runner_dl_url= $runner_dl_url"
|
||||
else
|
||||
debug_print exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
||||
fi
|
||||
@ -852,10 +891,10 @@ runner_install() {
|
||||
debug_print continue "Installing runner into $runners_dir/$runner_name..."
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Use Zenity progress bar
|
||||
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name" | \
|
||||
mkdir -p "$runners_dir/$runner_name" && tar -xf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name" | \
|
||||
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing runner...\n" 2>/dev/null
|
||||
else
|
||||
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name"
|
||||
mkdir -p "$runners_dir/$runner_name" && tar -xf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name"
|
||||
fi
|
||||
lutris_needs_restart="true"
|
||||
;;
|
||||
@ -864,10 +903,10 @@ runner_install() {
|
||||
debug_print continue "Installing runner into $runners_dir..."
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
# Use Zenity progress bar
|
||||
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir" | \
|
||||
mkdir -p "$runners_dir" && tar -xf "$tmp_dir/$runner_file" -C "$runners_dir" | \
|
||||
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing runner...\n" 2>/dev/null
|
||||
else
|
||||
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir"
|
||||
mkdir -p "$runners_dir" && tar -xf "$tmp_dir/$runner_file" -C "$runners_dir"
|
||||
fi
|
||||
lutris_needs_restart="true"
|
||||
;;
|
||||
@ -901,6 +940,18 @@ runner_select_install() {
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for GlibC-Version if TKG is selected, as he requires 2.33
|
||||
if [ "$contributor_url" = "https://api.github.com/repos/gort818/wine-sc-lug/releases" ]; then
|
||||
printf "checking for glibc \n"
|
||||
system_glibc=($(ldd --version | awk '/ldd/{print $NF}'))
|
||||
printf "system glibc-versuib: $system_glibc \n"
|
||||
required_glibc="2.33"
|
||||
if [ "$(bc <<< "$required_glibc>$system_glibc")" == "1" ]; then
|
||||
message warning "Your glibc version is too low, /dev/null requires v$required_glibc "
|
||||
proton_manage
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fetch a list of runner versions from the selected contributor
|
||||
# To add new sources, handle them here, in the if statement
|
||||
# just above, and the runner_install function above
|
||||
@ -937,13 +988,18 @@ runner_select_install() {
|
||||
*.tgz)
|
||||
runner_name="$(basename "${runner_versions[i]}" .tgz)"
|
||||
;;
|
||||
*.tar.xz)
|
||||
runner_name="$(basename "${runner_versions[i]}" .tar.xz)"
|
||||
;;
|
||||
*)
|
||||
debug_print exit "Unknown archive filetype in runner_select_install function. Aborting."
|
||||
runner_name="skip"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Add the runner names to the menu
|
||||
if [ -d "$runners_dir/$runner_name" ]; then
|
||||
if [ "$runner_name" = "skip" ]; then
|
||||
continue
|
||||
elif [ -d "$runners_dir/$runner_name" ]; then
|
||||
menu_options+=("$runner_name [installed]")
|
||||
else
|
||||
menu_options+=("$runner_name")
|
||||
@ -1031,6 +1087,7 @@ preflight_check() {
|
||||
|
||||
# Call the optimization functions to perform the checks
|
||||
memory_check
|
||||
avx_check
|
||||
mapcount_check
|
||||
filelimit_check
|
||||
|
||||
@ -1153,7 +1210,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")
|
||||
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")
|
||||
# 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")]}"
|
||||
@ -1163,15 +1220,15 @@ referral_randomizer() {
|
||||
|
||||
# Toggle between the LIVE and PTU game directories for all Helper functions
|
||||
set_version() {
|
||||
if [ "$live_or_ptu" = "LIVE" ]; then
|
||||
live_or_ptu="PTU"
|
||||
if [ "$live_or_ptu" = "$live_dir" ]; then
|
||||
live_or_ptu="$ptu_dir"
|
||||
message info "The Helper will now target your Star Citizen PTU installation."
|
||||
elif [ "$live_or_ptu" = "PTU" ]; then
|
||||
live_or_ptu="LIVE"
|
||||
elif [ "$live_or_ptu" = "$ptu_dir" ]; then
|
||||
live_or_ptu="$live_dir"
|
||||
message info "The Helper will now target your Star Citizen LIVE installation."
|
||||
else
|
||||
debug_print continue "Unexpected game version provided. Defaulting to the LIVE installation."
|
||||
live_or_ptu="LIVE"
|
||||
live_or_ptu="$live_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1201,9 +1258,27 @@ if [ -x "$(command -v zenity)" ]; then
|
||||
fi
|
||||
|
||||
# Set some defaults
|
||||
live_or_ptu="LIVE"
|
||||
live_or_ptu="$live_dir"
|
||||
lutris_needs_restart="false"
|
||||
|
||||
# Credits for this go to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
|
||||
get_latest_release() {
|
||||
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
|
||||
}
|
||||
|
||||
# Check if a new Verison of the script is available
|
||||
repo="the-sane/lug-helper"
|
||||
current_version="v1.9.1"
|
||||
latest_version=$(get_latest_release "$repo")
|
||||
|
||||
if [ "$latest_version" != "$current_version" ]; then
|
||||
# Print to stdout and also try warning the user through message
|
||||
printf "New version available, check https://github.com/the-sane/lug-helper/releases \n"
|
||||
message info "New version available, check <a href='https://github.com/the-sane/lug-helper/releases'>https://github.com/the-sane/lug-helper/releases</a> \n"
|
||||
fi
|
||||
|
||||
# If invoked with command line arguments, process them and exit
|
||||
if [ "$#" -gt 0 ]; then
|
||||
while [ "$#" -gt 0 ]
|
||||
@ -1243,9 +1318,9 @@ Usage: lug-helper <options>
|
||||
--target=* | -t=* )
|
||||
live_or_ptu="$(echo "$1" | cut -d'=' -f2)"
|
||||
if [ "$live_or_ptu" = "live" ] || [ "$live_or_ptu" = "LIVE" ]; then
|
||||
live_or_ptu="LIVE"
|
||||
live_or_ptu="$live_dir"
|
||||
elif [ "$live_or_ptu" = "ptu" ] || [ "$live_or_ptu" = "PTU" ]; then
|
||||
live_or_ptu="PTU"
|
||||
live_or_ptu="$ptu_dir"
|
||||
else
|
||||
printf "$0: Invalid option '$1'\n"
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user