From 6a113e00abc38c28ddc1e585dee0bf5947709fdb Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Mon, 17 Aug 2020 17:53:25 -0400 Subject: [PATCH 1/6] WIP delete caches and shaders --- lug-helper.sh | 110 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 93 insertions(+), 17 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index 487d653..d66864d 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -318,14 +318,14 @@ sanitize() { } # Check if setting vm.max_map_count was successful -check_map_count() { +check_mapcount() { if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then message 2 "As far as this script can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes." fi } # Check vm.max_map_count for the correct setting and let the user fix it if needed -set_map_count() { +set_mapcount() { # If vm.max_map_count is already set, no need to do anything if [ "$(cat /proc/sys/vm/max_map_count)" -ge 16777216 ]; then message 1 "vm.max_map_count is already set to the optimal value. You're all set!" @@ -333,10 +333,10 @@ set_map_count() { fi if grep -E -x -q "vm.max_map_count" /etc/sysctl.conf /etc/sysctl.d/* 2>/dev/null; then - if message 3 "It looks like you've already configured your system to work with Star Citizen\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then + if message 3 "It looks like you've already configured vm.max_map_count\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then pkexec sh -c 'sysctl -w vm.max_map_count=16777216' fi - check_map_count + check_mapcount return 0 fi @@ -356,7 +356,7 @@ set_map_count() { case "$choice" in "$once") pkexec sh -c 'sysctl -w vm.max_map_count=16777216' - check_map_count + check_mapcount ;; "$persist") if [ -d "/etc/sysctl.d" ]; then @@ -364,7 +364,7 @@ set_map_count() { else pkexec sh -c 'echo "vm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p' fi - check_map_count + check_mapcount ;; "$manual") if [ -d "/etc/sysctl.d" ]; then @@ -374,7 +374,7 @@ set_map_count() { fi ;; *) - check_map_count + check_mapcount return 0 ;; esac @@ -390,7 +390,7 @@ set_map_count() { case "$choice" in "$once") pkexec sh -c 'sysctl -w vm.max_map_count=16777216' - check_map_count + check_mapcount break ;; "$persist") @@ -399,7 +399,7 @@ set_map_count() { else pkexec sh -c 'echo "vm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p' fi - check_map_count + check_mapcount break ;; "$manual") @@ -411,7 +411,7 @@ set_map_count() { break ;; "$goback") - check_map_count + check_mapcount break ;; *) @@ -424,25 +424,91 @@ set_map_count() { fi } +# Delete the shaders directory +rm_shaders() { + shaders_dir="$user_dir/Shaders" + + # 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 [ ! -d "$shaders_dir" ]; then + message 2 "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir" + return 0 + fi + + # Delete the shader directory + echo "Deleting shaders..." + rm -r "$shaders_dir" + echo -e "Done.\n" + + message 1 "Your shaders have been deleted!" +} + +# Delete DXVK and OpenGL caches +rm_vidcache() { + dxvk_cache="$game_path/StarCitizen-dxvk.cache" + opengl_cach="$game_path/" + + # 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" ] && [ ! -f "$opengl_cache" ]; then + message 2 "Unable to find the DXVK or OpenGL cache files. There is nothing to delete!\n\n$dxvk_cache\n$opengl_cache" + return 0 + fi + + # Delete the cache files + if [ -f "$dxvk_cache" ]; then + echo "Deleting DXVK cache..." + rm "$dxvk_cache" + echo -e "Done.\n" + fi + if [ -f "$opengl_cache" ]; then + echo "Deleting OpenGL cache..." + rm "$opengl_cache" + echo -e "Done.\n" + fi + + message 1 "Your DXVK/OpenGL cache has been deleted!" +} + # Display the main menu main_menu() { # Set the menu options - check="Check vm.max_map_count for optimal performance" + mapcount="Check vm.max_map_count for optimal performance" clean="Delete my USER folder and preserve my keybinds" + shaders="Delete my shaders only" + vidcache="Delete my DXVK and OpenGL caches" quit="Quit" # Use Zenity if it is available if [ "$has_zen" -eq 1 ]; then - options_main=("TRUE" "$check" "FALSE" "$clean" "FALSE" "$quit") + options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$quit") choice="$(message 5 "${options_main[@]}")" case "$choice" in - "$check") - set_map_count + "$mapcount") + set_mapcount ;; "$clean") sanitize ;; + "$shaders") + rm_shaders + ;; + "$vidcache") + rm_vidcache + ;; "$quit") exit 0 ;; @@ -455,15 +521,15 @@ main_menu() { clear echo -e "\nWelcome, fellow Penguin, to the Star Citizen Linux Users Group Helper Script!\n\nThis script is designed to help you optimize your system for Star Citizen.\nYou may choose from the following options:\n" - options_main=("$check" "$clean" "$quit") + options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$quit") PS3="Enter selection number: " select choice in "${options_main[@]}" do case "$choice" in - "$check") + "$mapcount") echo -e "\n" - set_map_count + set_mapcount break ;; "$clean") @@ -471,6 +537,16 @@ main_menu() { sanitize break ;; + "$shaders") + echo -e "\n" + rm_shaders + break + ;; + "$vidcache") + echo -e "\n" + rm_vidcache + break + ;; "$quit") exit 0 ;; From fa5993be8d96c48c99245c0e3ea170fb8e1b8a05 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Mon, 17 Aug 2020 21:57:24 -0400 Subject: [PATCH 2/6] Toggle between LIVE and PTU --- lug-helper.sh | 84 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index d66864d..efc351b 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -73,7 +73,7 @@ message() { # main menu radio list # call format: message 5 "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3" # IMPORTANT: Adjust the height value below based on the number of items listed in the menu - margs=("--list" "--radiolist" "--height=240" "--text=Welcome, fellow Penguin, to the Star Citizen LUG Helper Script!\n\nThis script is designed to help you optimize your system for Star Citizen.\n\nYou may choose from the following options:" "--hide-header" "--column=" "--column=Option") + margs=("--list" "--radiolist" "--height=240" "--text=Welcome, fellow Penguin, to the Star Citizen LUG Helper!\n\nThis helper is designed to help optimize your system for Star Citizen\n\nYou may choose from the following options:" "--hide-header" "--column=" "--column=Option") ;; *) echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by string arguments.\n" @@ -85,11 +85,11 @@ message() { if [ "$1" -eq 4 ] || [ "$1" -eq 5 ]; then # requires a space between the assembled arguments shift 1 # drop the first numerical argument and shift the remaining up one - zenity "${margs[@]}" "$@" --width="400" --title="Star Citizen LUG Helper Script" + zenity "${margs[@]}" "$@" --width="400" --title="Star Citizen LUG Helper" else # no space between the assmebled arguments shift 1 # drop the first numerical argument and shift the remaining up one - zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper Script" + zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper" fi else # Text based menu. Does not work with message types 4 and 5 (zenity radio lists) @@ -141,7 +141,7 @@ message() { getdirs() { # Sanity checks if [ ! -d "$conf_dir" ]; then - message 2 "Config directory not found. The script is unable to proceed.\n\n$conf_dir" + message 2 "Config directory not found. The helper is unable to proceed.\n\n$conf_dir" return 1 fi @@ -155,19 +155,23 @@ getdirs() { fi if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")" + if [ "$(basename "$game_path")" != "Star Citizen" ]; then + echo -e "\nUnexpected game path found in config file, ignoring.\n" + game_path="" + fi fi if [ -f "$conf_dir/$conf_subdir/$backup_conf" ]; then backup_path="$(cat "$conf_dir/$conf_subdir/$backup_conf")" fi if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then - message 1 "You will now be asked to provide some directories needed by this script.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/" + message 1 "You will now be asked to provide some directories needed by the helper.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/" if [ "$has_zen" -eq 1 ]; then # Get the wine prefix directory if [ -z "$wine_prefix" ]; then wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine")" if [ "$?" -eq -1 ]; then - message 2 "An unexpected error has occurred. The script is unable to proceed." + message 2 "An unexpected error has occurred. The helper is unable to proceed." return 1 elif [ -z "$wine_prefix" ]; then # User clicked cancel @@ -178,12 +182,12 @@ getdirs() { # Get the game path if [ -z "$game_path" ]; then - while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen LIVE directory" --filename="$wine_prefix/")"; do + while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/Star Citizen")"; do if [ "$?" -eq -1 ]; then - message 2 "An unexpected error has occurred. The script is unable to proceed." + message 2 "An unexpected error has occurred. The helper is unable to proceed." return 1 - elif [ "$(basename "$game_path")" != "LIVE" ]; then - message 2 "You must select your LIVE directory." + elif [ "$(basename "$game_path")" != "Star Citizen" ]; then + message 2 "You must select the directory named 'Star Citizen'" else # All good or cancel break @@ -201,7 +205,7 @@ getdirs() { if [ -z "$backup_path" ]; then backup_path="$(zenity --file-selection --directory --title="Select a backup directory for your keybinds" --filename="$HOME/")" if [ "$?" -eq -1 ]; then - message 2 "An unexpected error has occurred. The script is unable to proceed." + message 2 "An unexpected error has occurred. The helper is unable to proceed." return 1 elif [ -z "$backup_path" ]; then # User clicked cancel @@ -225,13 +229,13 @@ getdirs() { # Get the game path if [ -z "$game_path" ]; then - echo -e "\nEnter the full path to your Star Citizen installation LIVE directory\n(case sensitive)" - echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/Star Citizen/LIVE/" + echo -e "\nEnter the full path to your Star Citizen installation directory\n(case sensitive)" + echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/Star Citizen/" while read -rp ": " game_path; do if [ ! -d "$game_path" ]; then echo -e "That directory is invalid or does not exist. Please try again.\n" - elif [ "$(basename "$game_path")" != "LIVE" ]; then - echo -e "You must select your LIVE directory." + elif [ "$(basename "$game_path")" != "Star Citizen" ]; then + echo -e "You must enter the full path to the directory named 'Star Citizen'" else break fi @@ -260,7 +264,7 @@ getdirs() { fi # Set some remaining directory paths - user_dir="$game_path/USER" + user_dir="$game_path/$live_or_ptu/USER" mappings_dir="$user_dir/Controls/Mappings" } @@ -278,7 +282,7 @@ sanitize() { # Sanity check if [ ! -d "$user_dir" ]; then - message 2 "Directory not found. The script is unable to proceed.\n\n$user_dir" + message 2 "Directory not found. The helper is unable to proceed.\n\n$user_dir" return 0 fi @@ -320,7 +324,7 @@ sanitize() { # Check if setting vm.max_map_count was successful check_mapcount() { if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then - message 2 "As far as this script can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes." + message 2 "As far as this helper can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes." fi } @@ -348,7 +352,7 @@ set_mapcount() { newsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.d/20-max_map_count.conf && sysctl -p'" oldsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.conf && sysctl -p'" - if message 3 "Running Star Citizen requires changing a system setting\nto give the game access to more than 8GB of memory.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\n\nAs far as this script can detect, the setting\nhas not been changed on your system.\n\nWould you like to change the setting now?"; then + if message 3 "Running Star Citizen requires changing a system setting\nto give the game access to more than 8GB of memory.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\n\nAs far as this helper can detect, the setting\nhas not been changed on your system.\n\nWould you like to change the setting now?"; then if [ "$has_zen" -eq 1 ]; then # zenity menu options_mapcount=("--height=165" "TRUE" "$once" "FALSE" "$persist" "FALSE" "$manual") @@ -381,7 +385,7 @@ set_mapcount() { else # text menu clear - echo -e "\nThis script can change vm.max_map_count for you.\nChoose from the following options:\n" + echo -e "\nThis helper can change vm.max_map_count for you.\nChoose from the following options:\n" options_mapcount=("$once" "$persist" "$manual" "$goback") PS3="Enter selection number: " @@ -451,8 +455,8 @@ rm_shaders() { # Delete DXVK and OpenGL caches rm_vidcache() { - dxvk_cache="$game_path/StarCitizen-dxvk.cache" - opengl_cach="$game_path/" + dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache" + opengl_cach="$game_path/$live_or_ptu" # Get/Set directory paths getdirs @@ -489,11 +493,12 @@ main_menu() { clean="Delete my USER folder and preserve my keybinds" shaders="Delete my shaders only" vidcache="Delete my DXVK and OpenGL caches" + changever="Switch the helper between LIVE and PTU (default is LIVE)" quit="Quit" # Use Zenity if it is available if [ "$has_zen" -eq 1 ]; then - options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$quit") + options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$changever" "FALSE" "$quit") choice="$(message 5 "${options_main[@]}")" case "$choice" in @@ -509,6 +514,18 @@ main_menu() { "$vidcache") rm_vidcache ;; + "$changever") + if [ "$live_or_ptu" == "LIVE" ]; then + live_or_ptu="PTU" + message 1 "The helper will now target your Star Citizen PTU installation." + elif [ "$live_or_ptu" == "PTU" ]; then + live_or_ptu="LIVE" + message 1 "The helper will now target your Star Citizen LIVE installation." + else + echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation." + live_or_ptu="LIVE" + fi + ;; "$quit") exit 0 ;; @@ -519,9 +536,9 @@ main_menu() { else # Use a text menu if Zenity is not available clear - echo -e "\nWelcome, fellow Penguin, to the Star Citizen Linux Users Group Helper Script!\n\nThis script is designed to help you optimize your system for Star Citizen.\nYou may choose from the following options:\n" + echo -e "\nWelcome, 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:\n" - options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$quit") + options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$changever" "$quit") PS3="Enter selection number: " select choice in "${options_main[@]}" @@ -547,6 +564,20 @@ main_menu() { rm_vidcache break ;; + "$changever") + echo -e "\n" + if [ "$live_or_ptu" == "LIVE" ]; then + live_or_ptu="PTU" + message 1 "This helper will now target your Star Citizen PTU installation." + elif [ "$live_or_ptu" == "PTU" ]; then + live_or_ptu="LIVE" + message 1 "This helper will now target your Star Citizen LIVE installation." + else + echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation." + live_or_ptu="LIVE" + fi + break + ;; "$quit") exit 0 ;; @@ -569,6 +600,9 @@ if [ -x "$(command -v zenity)" ]; then has_zen=1 fi +# Default to LIVE +live_or_ptu="LIVE" + # Loop the main menu until the user selects quit while true; do main_menu From 1a9544bc637d6a3fc13b03fd295e067db5fda60c Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Mon, 17 Aug 2020 22:05:34 -0400 Subject: [PATCH 3/6] Quit menu option isn't needed, just click the cancel button --- lug-helper.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index efc351b..a80b7da 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -73,7 +73,7 @@ message() { # main menu radio list # call format: message 5 "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3" # IMPORTANT: Adjust the height value below based on the number of items listed in the menu - margs=("--list" "--radiolist" "--height=240" "--text=Welcome, fellow Penguin, to the Star Citizen LUG Helper!\n\nThis helper is designed to help optimize your system for Star Citizen\n\nYou may choose from the following options:" "--hide-header" "--column=" "--column=Option") + margs=("--list" "--radiolist" "--height=290" "--text=Welcome, fellow Penguin, to the Star Citizen LUG Helper!\n\nThis helper is designed to help optimize your system for Star Citizen\n\nYou may choose from the following options:" "--hide-header" "--column=" "--column=Option") ;; *) echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by string arguments.\n" @@ -498,7 +498,7 @@ main_menu() { # Use Zenity if it is available if [ "$has_zen" -eq 1 ]; then - options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$changever" "FALSE" "$quit") + options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$changever") choice="$(message 5 "${options_main[@]}")" case "$choice" in @@ -526,9 +526,6 @@ main_menu() { live_or_ptu="LIVE" fi ;; - "$quit") - exit 0 - ;; *) exit 0 ;; From 3bc2958e9c607f98e5456766bd1bdfe896da6a53 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Tue, 18 Aug 2020 21:19:26 -0400 Subject: [PATCH 4/6] Cleanup & consistency --- lug-helper.sh | 76 ++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index a80b7da..a43e47f 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -456,7 +456,7 @@ rm_shaders() { # Delete DXVK and OpenGL caches rm_vidcache() { dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache" - opengl_cach="$game_path/$live_or_ptu" + opengl_cach="$game_path/$live_or_ptu/StarCitizen-opengl.cache" # Get/Set directory paths getdirs @@ -486,45 +486,50 @@ rm_vidcache() { message 1 "Your DXVK/OpenGL cache has been deleted!" } +# Toggle between targeting the LIVE and PTU game directories for all helper functions +set_version() { + if [ "$live_or_ptu" == "LIVE" ]; then + live_or_ptu="PTU" + message 1 "The helper will now target your Star Citizen PTU installation." + elif [ "$live_or_ptu" == "PTU" ]; then + live_or_ptu="LIVE" + message 1 "The helper will now target your Star Citizen LIVE installation." + else + echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation." + live_or_ptu="LIVE" + fi +} + # Display the main menu main_menu() { # Set the menu options - mapcount="Check vm.max_map_count for optimal performance" - clean="Delete my USER folder and preserve my keybinds" - shaders="Delete my shaders only" - vidcache="Delete my DXVK and OpenGL caches" - changever="Switch the helper between LIVE and PTU (default is LIVE)" - quit="Quit" + mapcount_msg="Check vm.max_map_count for optimal performance" + sanitize_msg="Delete my USER folder and preserve my keybinds" + shaders_msg="Delete my shaders only" + vidcache_msg="Delete my DXVK/OpenGL cache" + version_msg="Switch the helper between LIVE and PTU (default is LIVE)" + quit_msg="Quit" # Use Zenity if it is available if [ "$has_zen" -eq 1 ]; then - options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$changever") + options_main=("TRUE" "$mapcount_msg" "FALSE" "$sanitize_msg" "FALSE" "$shaders_msg" "FALSE" "$vidcache_msg" "FALSE" "$version_msg") choice="$(message 5 "${options_main[@]}")" case "$choice" in - "$mapcount") + "$mapcount_msg") set_mapcount ;; - "$clean") + "$sanitize_msg") sanitize ;; - "$shaders") + "$shaders_msg") rm_shaders ;; - "$vidcache") + "$vidcache_msg") rm_vidcache ;; - "$changever") - if [ "$live_or_ptu" == "LIVE" ]; then - live_or_ptu="PTU" - message 1 "The helper will now target your Star Citizen PTU installation." - elif [ "$live_or_ptu" == "PTU" ]; then - live_or_ptu="LIVE" - message 1 "The helper will now target your Star Citizen LIVE installation." - else - echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation." - live_or_ptu="LIVE" - fi + "$version_msg") + set_version ;; *) exit 0 @@ -535,47 +540,38 @@ main_menu() { clear echo -e "\nWelcome, 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:\n" - options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$changever" "$quit") + options_main=("$mapcount_msg" "$sanitize_msg" "$shaders_msg" "$vidcache_msg" "$version_msg" "$quit_msg") PS3="Enter selection number: " select choice in "${options_main[@]}" do case "$choice" in - "$mapcount") + "$mapcount_msg") echo -e "\n" set_mapcount break ;; - "$clean") + "$sanitize_msg") echo -e "\n" sanitize break ;; - "$shaders") + "$shaders_msg") echo -e "\n" rm_shaders break ;; - "$vidcache") + "$vidcache_msg") echo -e "\n" rm_vidcache break ;; - "$changever") + "$version_msg") echo -e "\n" - if [ "$live_or_ptu" == "LIVE" ]; then - live_or_ptu="PTU" - message 1 "This helper will now target your Star Citizen PTU installation." - elif [ "$live_or_ptu" == "PTU" ]; then - live_or_ptu="LIVE" - message 1 "This helper will now target your Star Citizen LIVE installation." - else - echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation." - live_or_ptu="LIVE" - fi + set_version break ;; - "$quit") + "$quit_msg") exit 0 ;; *) From 745bf715d2adb3d16ca95f28a17c1645d2e22cdb Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Fri, 21 Aug 2020 18:49:28 -0400 Subject: [PATCH 5/6] DXVK cache only --- lug-helper.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index a43e47f..6a76c7c 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -453,10 +453,9 @@ rm_shaders() { message 1 "Your shaders have been deleted!" } -# Delete DXVK and OpenGL caches +# Delete DXVK cache rm_vidcache() { dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache" - opengl_cach="$game_path/$live_or_ptu/StarCitizen-opengl.cache" # Get/Set directory paths getdirs @@ -466,24 +465,17 @@ rm_vidcache() { fi # Sanity check - if [ ! -f "$dxvk_cache" ] && [ ! -f "$opengl_cache" ]; then - message 2 "Unable to find the DXVK or OpenGL cache files. There is nothing to delete!\n\n$dxvk_cache\n$opengl_cache" + if [ ! -f "$dxvk_cache" ]; then + message 2 "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache" return 0 fi - # Delete the cache files - if [ -f "$dxvk_cache" ]; then - echo "Deleting DXVK cache..." - rm "$dxvk_cache" - echo -e "Done.\n" - fi - if [ -f "$opengl_cache" ]; then - echo "Deleting OpenGL cache..." - rm "$opengl_cache" - echo -e "Done.\n" - fi + # Delete the cache file + echo "Deleting DXVK cache..." + rm "$dxvk_cache" + echo -e "Done.\n" - message 1 "Your DXVK/OpenGL cache has been deleted!" + message 1 "Your DXVK cache has been deleted!" } # Toggle between targeting the LIVE and PTU game directories for all helper functions @@ -506,7 +498,7 @@ main_menu() { mapcount_msg="Check vm.max_map_count for optimal performance" sanitize_msg="Delete my USER folder and preserve my keybinds" shaders_msg="Delete my shaders only" - vidcache_msg="Delete my DXVK/OpenGL cache" + vidcache_msg="Delete my DXVK cache" version_msg="Switch the helper between LIVE and PTU (default is LIVE)" quit_msg="Quit" From 913e6a693ca91e5ad218eb57359dc0aad114bec5 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Fri, 21 Aug 2020 21:02:16 -0400 Subject: [PATCH 6/6] Extra sanity checks, fix variables --- lug-helper.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index 6a76c7c..f76803c 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -144,7 +144,6 @@ getdirs() { message 2 "Config directory not found. The helper is unable to proceed.\n\n$conf_dir" return 1 fi - if [ ! -d "$conf_dir/$conf_subdir" ]; then mkdir "$conf_dir/$conf_subdir" fi @@ -152,18 +151,27 @@ getdirs() { # Check if the config files already exist if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then wine_prefix="$(cat "$conf_dir/$conf_subdir/$wine_conf")" + if [ ! -d "$wine_prefix" ]; then + echo -e "\nThe saved wine prefix does not exist, ignoring.\n" + wine_prefix="" + fi fi if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")" - if [ "$(basename "$game_path")" != "Star Citizen" ]; then + if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "Star Citizen" ]; then echo -e "\nUnexpected game path found in config file, ignoring.\n" game_path="" fi fi if [ -f "$conf_dir/$conf_subdir/$backup_conf" ]; then backup_path="$(cat "$conf_dir/$conf_subdir/$backup_conf")" + if [ ! -d "$backup_path" ]; then + echo -e "\nThe saved backup path does not exist, ignoring.\n" + backup_path="" + fi fi - + + # If we don't have the directory paths we need yet, ask the user to provide them if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then message 1 "You will now be asked to provide some directories needed by the helper.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/" if [ "$has_zen" -eq 1 ]; then @@ -282,7 +290,7 @@ sanitize() { # Sanity check if [ ! -d "$user_dir" ]; then - message 2 "Directory not found. The helper is unable to proceed.\n\n$user_dir" + message 2 "USER directory not found. There is nothing to delete!\n\n$user_dir" return 0 fi @@ -336,6 +344,7 @@ set_mapcount() { return 0 fi + # Otherwise, check to see if it was supposed to be set by sysctl if grep -E -x -q "vm.max_map_count" /etc/sysctl.conf /etc/sysctl.d/* 2>/dev/null; then if message 3 "It looks like you've already configured vm.max_map_count\nand saved the setting to persist across reboots.\nHowever, for some reason the persistence part did not work.\n\nFor now, would you like to enable the setting again until the next reboot?"; then pkexec sh -c 'sysctl -w vm.max_map_count=16777216' @@ -430,8 +439,6 @@ set_mapcount() { # Delete the shaders directory rm_shaders() { - shaders_dir="$user_dir/Shaders" - # Get/Set directory paths getdirs if [ "$?" -eq 1 ]; then @@ -439,6 +446,8 @@ rm_shaders() { return 0 fi + shaders_dir="$user_dir/Shaders" + # Sanity check if [ ! -d "$shaders_dir" ]; then message 2 "Shaders directory not found. There is nothing to delete!\n\n$shaders_dir" @@ -455,15 +464,15 @@ rm_shaders() { # Delete DXVK cache rm_vidcache() { - dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache" - # 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 - + + dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache" + # Sanity check if [ ! -f "$dxvk_cache" ]; then message 2 "Unable to find the DXVK cache file. There is nothing to delete!\n\n$dxvk_cache"