Minor syntax, formatting, and organizational tweaks

This commit is contained in:
the Sane 2021-09-18 12:57:22 -04:00 committed by GitHub
parent 675621c4c3
commit c42d459ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,9 +48,9 @@
############################################################################ ############################################################################
# Check if script is run as root # Check if script is run as root
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" -eq 0 ]; then
echo "This script is not supposed to be run as root!" echo "This script is not supposed to be run as root!"
exit 1 exit 1
fi fi
# Check for dependencies # Check for dependencies
@ -126,6 +126,10 @@ else
lug_logo="info" lug_logo="info"
fi fi
# Github repo and script version info
repo="the-sane/lug-helper"
current_version="v1.9.1"
############################################################################ ############################################################################
############################################################################ ############################################################################
@ -925,7 +929,8 @@ runner_select_install() {
debug_print exit "Script error: The runner_select_install function expects a numerical argument. Aborting." debug_print exit "Script error: The runner_select_install function expects a numerical argument. Aborting."
fi 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]}" contributor_url="${runner_sources[$1+1]}"
# Check the provided contributor url to make sure we know how to handle it # Check the provided contributor url to make sure we know how to handle it
@ -940,15 +945,14 @@ runner_select_install() {
;; ;;
esac esac
# Check for GlibC-Version if TKG is selected, as he requires 2.33 # Check GlibC version against the requirements of the selected runner
if [ "$contributor_url" = "https://api.github.com/repos/gort818/wine-sc-lug/releases" ]; then if [ "$contributor_name" = "/dev/null" ]; 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" required_glibc="2.33"
if [ "$(bc <<< "$required_glibc>$system_glibc")" == "1" ]; then system_glibc="$(ldd --version | awk '/ldd/{print $NF}')"
message warning "Your glibc version is too low, /dev/null requires v$required_glibc "
proton_manage 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
fi fi
@ -1242,6 +1246,19 @@ reset_helper() {
fi 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() { quit() {
exit 0 exit 0
} }
@ -1261,22 +1278,15 @@ fi
live_or_ptu="$live_dir" live_or_ptu="$live_dir"
lutris_needs_restart="false" lutris_needs_restart="false"
# Credits for this go to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c # Check if a newer verison of the script is available
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") latest_version=$(get_latest_release "$repo")
if [ "$latest_version" != "$current_version" ]; then if [ "$latest_version" != "$current_version" ]; then
# Print to stdout and also try warning the user through message if [ "$use_zenity" -eq 1 ]; then
printf "New version available, check https://github.com/the-sane/lug-helper/releases \n" 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<a href='https://github.com/the-sane/lug-helper/releases'>https://github.com/the-sane/lug-helper/releases</a>"
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" else
message info "The latest version of the LUG Helper is $latest_version\nYou are using $current_version\n\nYou can download new releases here:\nhttps://github.com/the-sane/lug-helper/releases"
fi
fi fi
# If invoked with command line arguments, process them and exit # If invoked with command line arguments, process them and exit