mirror of
				https://github.com/the-sane/lug-helper.git
				synced 2025-11-04 06:53:14 +00:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
			675621c4c3
			...
			4fd9fec8f7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					4fd9fec8f7 | ||
| 
						 | 
					130704107b | ||
| 
						 | 
					15cad464e3 | ||
| 
						 | 
					cabfd03c29 | ||
| 
						 | 
					33170fae78 | ||
| 
						 | 
					b701ea5e3d | ||
| 
						 | 
					05d75ec82f | ||
| 
						 | 
					2f97a8eb2d | ||
| 
						 | 
					cb3fc5d0d7 | ||
| 
						 | 
					c42d459ef2 | 
@@ -48,9 +48,9 @@
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
# 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
 | 
			
		||||
if [ "$(id -u)" -eq 0 ]; then
 | 
			
		||||
    echo "This script is not supposed to be run as root!"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Check for dependencies
 | 
			
		||||
@@ -126,6 +126,11 @@ else
 | 
			
		||||
    lug_logo="info"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Github repo and script version info
 | 
			
		||||
repo="the-sane/lug-helper"
 | 
			
		||||
releases_url="https://github.com/the-sane/lug-helper/releases"
 | 
			
		||||
current_version="v1.9.2"
 | 
			
		||||
 | 
			
		||||
############################################################################
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
@@ -258,6 +263,7 @@ message() {
 | 
			
		||||
#   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.
 | 
			
		||||
# - The string "cancel_label" should contain the text of the cancel button.
 | 
			
		||||
# 
 | 
			
		||||
# The final element in each array is expected to be a quit option.
 | 
			
		||||
#
 | 
			
		||||
@@ -279,6 +285,8 @@ menu() {
 | 
			
		||||
        debug_print exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
 | 
			
		||||
    elif [ -z "$menu_height" ]; then
 | 
			
		||||
        debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
 | 
			
		||||
    elif [ -z "$cancel_label" ]; then
 | 
			
		||||
        debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
 | 
			
		||||
    fi
 | 
			
		||||
    
 | 
			
		||||
    # Use Zenity if it is available
 | 
			
		||||
@@ -298,7 +306,7 @@ menu() {
 | 
			
		||||
        done
 | 
			
		||||
 | 
			
		||||
        # Display the zenity radio button menu
 | 
			
		||||
        choice="$(zenity --list --radiolist --width="480" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --window-icon=$lug_logo --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)"
 | 
			
		||||
        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)"
 | 
			
		||||
 | 
			
		||||
        # Loop through the options array to match the chosen option
 | 
			
		||||
        matched="false"
 | 
			
		||||
@@ -472,7 +480,7 @@ getdirs() {
 | 
			
		||||
    # $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/"
 | 
			
		||||
    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
 | 
			
		||||
@@ -794,6 +802,9 @@ runner_select_delete() {
 | 
			
		||||
        menu_height="400"
 | 
			
		||||
    fi
 | 
			
		||||
    
 | 
			
		||||
    # Set the label for the cancel button
 | 
			
		||||
    cancel_label="Go Back"
 | 
			
		||||
       
 | 
			
		||||
    # Call the menu function.  It will use the options as configured above
 | 
			
		||||
    menu
 | 
			
		||||
}
 | 
			
		||||
@@ -824,9 +835,6 @@ runner_install() {
 | 
			
		||||
        *.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."
 | 
			
		||||
            ;;
 | 
			
		||||
@@ -837,7 +845,6 @@ 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
 | 
			
		||||
@@ -882,7 +889,7 @@ runner_install() {
 | 
			
		||||
    # Get the path of the first item listed in the archive
 | 
			
		||||
    # This should either be a subdirectory or the path ./
 | 
			
		||||
    # depending on how the archive was created
 | 
			
		||||
    first_filepath="$(stdbuf -oL tar -tzf "$tmp_dir/$runner_file" | head -n 1)"
 | 
			
		||||
    first_filepath="$(stdbuf -oL tar -tf "$tmp_dir/$runner_file" | head -n 1)"
 | 
			
		||||
    
 | 
			
		||||
    # Extract the runner
 | 
			
		||||
    case "$first_filepath" in
 | 
			
		||||
@@ -925,7 +932,8 @@ runner_select_install() {
 | 
			
		||||
        debug_print exit "Script error:  The runner_select_install function expects a numerical argument. Aborting."
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    # Store the url from the selected contributor
 | 
			
		||||
    # Store info from the selected contributor
 | 
			
		||||
    contributor_name="${runner_sources[$1]}"
 | 
			
		||||
    contributor_url="${runner_sources[$1+1]}"
 | 
			
		||||
 | 
			
		||||
    # Check the provided contributor url to make sure we know how to handle it
 | 
			
		||||
@@ -940,15 +948,14 @@ 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"
 | 
			
		||||
    # Check GlibC version against the requirements of the selected runner
 | 
			
		||||
    if [ "$contributor_name" = "/dev/null" ]; then
 | 
			
		||||
        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
 | 
			
		||||
        system_glibc="$(ldd --version | awk '/ldd/{print $NF}')"
 | 
			
		||||
 | 
			
		||||
        if [ "$(bc <<< "$required_glibc > $system_glibc")" = "1" ]; then
 | 
			
		||||
            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
 | 
			
		||||
        fi
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
@@ -956,7 +963,7 @@ runner_select_install() {
 | 
			
		||||
    # To add new sources, handle them here, in the if statement
 | 
			
		||||
    # just above, and the runner_install function above
 | 
			
		||||
    if [ "$runner_url_type" = "github" ]; then
 | 
			
		||||
        runner_versions=($(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | xargs basename -a))
 | 
			
		||||
        runner_versions=($(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | grep -vE "*.sha512sum" | xargs basename -a))
 | 
			
		||||
    else
 | 
			
		||||
        debug_print exit "Script error:  Unknown api/url format in runner_sources array. Aborting."
 | 
			
		||||
    fi
 | 
			
		||||
@@ -992,14 +999,12 @@ runner_select_install() {
 | 
			
		||||
                runner_name="$(basename "${runner_versions[i]}" .tar.xz)"
 | 
			
		||||
                ;;        
 | 
			
		||||
            *)
 | 
			
		||||
                runner_name="skip"
 | 
			
		||||
                debug_print exit "Unknown archive filetype in runner_select_install function. Aborting."
 | 
			
		||||
                ;;
 | 
			
		||||
        esac
 | 
			
		||||
 | 
			
		||||
        # Add the runner names to the menu
 | 
			
		||||
        if [ "$runner_name" = "skip" ]; then
 | 
			
		||||
            continue
 | 
			
		||||
        elif [ -d "$runners_dir/$runner_name" ]; then
 | 
			
		||||
        if [ -d "$runners_dir/$runner_name" ]; then
 | 
			
		||||
            menu_options+=("$runner_name    [installed]")
 | 
			
		||||
        else
 | 
			
		||||
            menu_options+=("$runner_name")
 | 
			
		||||
@@ -1017,6 +1022,9 @@ runner_select_install() {
 | 
			
		||||
        menu_height="400"
 | 
			
		||||
    fi
 | 
			
		||||
    
 | 
			
		||||
    # Set the label for the cancel button
 | 
			
		||||
    cancel_label="Go Back"
 | 
			
		||||
       
 | 
			
		||||
    # Call the menu function.  It will use the options as configured above
 | 
			
		||||
    menu
 | 
			
		||||
}
 | 
			
		||||
@@ -1064,6 +1072,9 @@ runner_manage() {
 | 
			
		||||
        # Calculate the total height the menu should be
 | 
			
		||||
        menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
 | 
			
		||||
        
 | 
			
		||||
       # Set the label for the cancel button
 | 
			
		||||
       cancel_label="Go Back"
 | 
			
		||||
       
 | 
			
		||||
        # Call the menu function.  It will use the options as configured above
 | 
			
		||||
        menu
 | 
			
		||||
    done
 | 
			
		||||
@@ -1202,6 +1213,9 @@ maintenance_menu() {
 | 
			
		||||
        # Calculate the total height the menu should be
 | 
			
		||||
        menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
 | 
			
		||||
       
 | 
			
		||||
       # Set the label for the cancel button
 | 
			
		||||
       cancel_label="Go Back"
 | 
			
		||||
       
 | 
			
		||||
        # Call the menu function.  It will use the options as configured above
 | 
			
		||||
        menu
 | 
			
		||||
    done
 | 
			
		||||
@@ -1242,6 +1256,19 @@ reset_helper() {
 | 
			
		||||
    fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# 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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
quit() {
 | 
			
		||||
    exit 0
 | 
			
		||||
}
 | 
			
		||||
@@ -1261,22 +1288,17 @@ fi
 | 
			
		||||
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"
 | 
			
		||||
# Check if a newer verison of the script is available
 | 
			
		||||
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"
 | 
			
		||||
    if [ "$use_zenity" -eq 1 ]; then
 | 
			
		||||
        releases_url_formatted="<a href='$releases_url'>$releases_url</a>"
 | 
			
		||||
    else
 | 
			
		||||
        releases_url_formatted="$releases_url"
 | 
			
		||||
    fi
 | 
			
		||||
    
 | 
			
		||||
    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_formatted"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# If invoked with command line arguments, process them and exit
 | 
			
		||||
@@ -1387,6 +1409,9 @@ while true; do
 | 
			
		||||
    # Calculate the total height the menu should be
 | 
			
		||||
    menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
 | 
			
		||||
    
 | 
			
		||||
    # Set the label for the cancel button
 | 
			
		||||
    cancel_label="Quit"
 | 
			
		||||
    
 | 
			
		||||
    # Call the menu function.  It will use the options as configured above
 | 
			
		||||
    menu
 | 
			
		||||
done
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user