5 Commits
v1.7 ... v1.8

Author SHA1 Message Date
eae146ce02 added support for the new directory structure in 3.13 and check for sudo 2021-04-25 15:11:04 +02:00
b4248fb264 Additional referral code 2021-03-21 14:51:53 -04:00
d5dbec7b3f Refactor directory handling 2021-03-13 12:21:46 -05:00
d4e8298743 Refactor directory paths
Preparation for upcoming changes to the game's directory structure
2021-03-13 09:59:28 -05:00
8ee730bf35 More referral codes! 2021-02-27 12:55:48 -05:00

View File

@ -47,6 +47,12 @@
# https://github.com/richardtatum/sc-runner-updater # 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 # Check for dependencies
if [ ! -x "$(command -v curl)" ]; then if [ ! -x "$(command -v curl)" ]; then
# Print to stderr and also try warning the user through notify-send # 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")" tmp_dir="$(mktemp -d --suffix=".lughelper")"
trap 'rm -r "$tmp_dir"' EXIT trap 'rm -r "$tmp_dir"' EXIT
# The game's user subdirectory name ######## Game Directories ##################################################
user_subdir_name="USER"
# The location within the USER directory to which the game exports keybinds
keybinds_export_path="Controls/Mappings"
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 # Lutris wine runners directory
runners_dir="$data_dir/lutris/runners/wine" runners_dir="$data_dir/lutris/runners/wine"
@ -360,7 +374,7 @@ getdirs() {
fi fi
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")" 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." debug_print continue "Unexpected game path found in config file, ignoring."
game_path="" game_path=""
fi fi
@ -387,15 +401,15 @@ getdirs() {
# Get the game path # Get the game path
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
if [ -d "$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/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then message question "Is this your Star Citizen game directory?\n\n$wine_prefix/$install_path"; then
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" game_path="$wine_prefix/$install_path"
else 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 if [ "$?" -eq -1 ]; then
message warning "An unexpected error has occurred. The Helper is unable to proceed." message warning "An unexpected error has occurred. The Helper is unable to proceed."
return 1 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" message warning "You must select the Star Citizen base game directory.\n\nFor Example: prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen"
else else
# All good or cancel # All good or cancel
@ -428,17 +442,17 @@ getdirs() {
# Get the game path # Get the game path
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
if [ -d "$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/drive_c/Program Files/Roberts Space Industries/StarCitizen"; then message question "Is this your Star Citizen game directory?\n\n$wine_prefix/$install_path"; then
game_path="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" game_path="$wine_prefix/$install_path"
else else
printf "\nEnter the full path to your Star Citizen installation directory (case sensitive)\n" 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" printf "ie. /home/USER/Games/star-citizen/drive_c/Program Files/Roberts Space Industries/StarCitizen\n"
while read -rp ": " game_path; do while read -rp ": " game_path; do
if [ ! -d "$game_path" ]; then if [ ! -d "$game_path" ]; then
printf "That directory is invalid or does not exist. Please try again.\n\n" printf "That directory is invalid or does not exist. Please try again.\n\n"
elif [ "$(basename "$game_path")" != "StarCitizen" ]; then elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
printf "You must enter the full path to the directory named 'StarCitizen'\n\n" printf "You must enter the full path to the directory named '$sc_base_dir'\n\n"
else else
break break
fi fi
@ -452,9 +466,18 @@ getdirs() {
echo "$game_path" > "$conf_dir/$conf_subdir/$game_conf" echo "$game_path" > "$conf_dir/$conf_subdir/$game_conf"
fi fi
# Set some remaining directory paths ######## Set remaining directory paths #####################################
user_dir="$game_path/$live_or_ptu/$user_subdir_name" # $live_or_ptu is set in the set_version() function
keybinds_dir="$user_dir/$keybinds_export_path" ############################################################################
# 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" backup_path="$conf_dir/$conf_subdir"
} }
@ -668,8 +691,6 @@ rm_shaders() {
return 0 return 0
fi fi
shaders_dir="$user_dir/shaders"
# Sanity check # Sanity check
if [ ! -d "$shaders_dir" ]; then if [ ! -d "$shaders_dir" ]; then
message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir" message warning "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir"
@ -693,9 +714,7 @@ rm_dxvkcache() {
# or there was an error # or there was an error
return 0 return 0
fi fi
dxvk_cache="$game_path/$live_or_ptu/$dxvk_cache_file"
# Sanity check # Sanity check
if [ ! -f "$dxvk_cache" ]; then if [ ! -f "$dxvk_cache" ]; then
message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache" message warning "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache"
@ -1165,7 +1184,7 @@ maintenance_menu() {
# Get a random Penguin's Star Citizen referral code # Get a random Penguin's Star Citizen referral code
referral_randomizer() { referral_randomizer() {
# Populate the referral codes array # Populate the referral codes array
referral_codes=("STAR-4TZD-6KMM" "STAR-4XM2-VM99" "STAR-2NPY-FCR2" "STAR-T9Z9-7W6P" "STAR-VLBF-W2QR" "STAR-BYR6-YHMF" "STAR-3X2H-VZMX" "STAR-BRWN-FB9T" "STAR-FG6Y-N4Q4" "STAR-VLD6-VZRG" "STAR-T9KF-LV77" "STAR-4XHB-R7RF" "STAR-9NVF-MRN7" "STAR-3Q4W-9TC3" "STAR-3SBK-7QTT" "STAR-XFBT-9TTK" "STAR-F3H9-YPHN" "STAR-BYK6-RCCL" "STAR-XCKH-W6T7" "STAR-H292-39WK" "STAR-ZRT5-PJB7" "STAR-GMBP-SH9Y" "STAR-PLWB-LMFY" "STAR-TNZN-H4ZT") 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 # Pick a random array element. Scale a floating point number for
# a more random distribution than simply calling RANDOM # a more random distribution than simply calling RANDOM
random_code="${referral_codes[$(awk '{srand($2); print int(rand()*$1)}' <<< "${#referral_codes[@]} $RANDOM")]}" random_code="${referral_codes[$(awk '{srand($2); print int(rand()*$1)}' <<< "${#referral_codes[@]} $RANDOM")]}"
@ -1175,15 +1194,15 @@ referral_randomizer() {
# Toggle between the LIVE and PTU game directories for all Helper functions # Toggle between the LIVE and PTU game directories for all Helper functions
set_version() { set_version() {
if [ "$live_or_ptu" = "LIVE" ]; then if [ "$live_or_ptu" = "$live_dir" ]; then
live_or_ptu="PTU" live_or_ptu="$ptu_dir"
message info "The Helper will now target your Star Citizen PTU installation." message info "The Helper will now target your Star Citizen PTU installation."
elif [ "$live_or_ptu" = "PTU" ]; then elif [ "$live_or_ptu" = "$ptu_dir" ]; then
live_or_ptu="LIVE" live_or_ptu="$live_dir"
message info "The Helper will now target your Star Citizen LIVE installation." message info "The Helper will now target your Star Citizen LIVE installation."
else else
debug_print continue "Unexpected game version provided. Defaulting to the LIVE installation." debug_print continue "Unexpected game version provided. Defaulting to the LIVE installation."
live_or_ptu="LIVE" live_or_ptu="$live_dir"
fi fi
} }
@ -1213,7 +1232,7 @@ if [ -x "$(command -v zenity)" ]; then
fi fi
# Set some defaults # Set some defaults
live_or_ptu="LIVE" live_or_ptu="$live_dir"
lutris_needs_restart="false" lutris_needs_restart="false"
# If invoked with command line arguments, process them and exit # If invoked with command line arguments, process them and exit
@ -1255,9 +1274,9 @@ Usage: lug-helper <options>
--target=* | -t=* ) --target=* | -t=* )
live_or_ptu="$(echo "$1" | cut -d'=' -f2)" live_or_ptu="$(echo "$1" | cut -d'=' -f2)"
if [ "$live_or_ptu" = "live" ] || [ "$live_or_ptu" = "LIVE" ]; then 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 elif [ "$live_or_ptu" = "ptu" ] || [ "$live_or_ptu" = "PTU" ]; then
live_or_ptu="PTU" live_or_ptu="$ptu_dir"
else else
printf "$0: Invalid option '$1'\n" printf "$0: Invalid option '$1'\n"
exit 0 exit 0