Skip to content

Instantly share code, notes, and snippets.

@getchoo
Created March 1, 2022 03:04
Show Gist options
  • Select an option

  • Save getchoo/fe43565ea4918048b9775d5a74c92fe0 to your computer and use it in GitHub Desktop.

Select an option

Save getchoo/fe43565ea4918048b9775d5a74c92fe0 to your computer and use it in GitHub Desktop.
a small bash script for updating proton-ge
#!/usr/bin/env bash
################
# protongup - a small bash script for updating proton-ge
################
## constants
_REPO="GloriousEggroll/proton-ge-custom"
_STEAMPATH="$HOME/.steam/root/compatibilitytools.d"
function clean_up() {
cd "$_STEAMPATH/"
rm -rf ./*.tar.gz ./*.sha512sum
}
function get_current_version() {
## check for current release
if [ ! -f "$_STEAMPATH/proton-ge_version.txt" ]
then
echo "NULL"
else
cat "$_STEAMPATH/proton-ge_version.txt"
fi
}
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
function repo_api_request() {
## get info from latest release
curl -fsSL "https://api.github.com/repos/$_REPO/releases/latest" |
grep "\"$1\":" |
sed -E 's/.*"([^"]+)".*/\1/'
}
function update_proton_ge() {
_pwd=$(pwd)
mkdir -p "$_STEAMPATH"
cd "$_STEAMPATH/"
sum_url="$(repo_api_request browser_download_url | head -n 1)"
download_url="$(repo_api_request browser_download_url | tail -n 1)"
echo "downloading..."
curl -fsSLO "$download_url"
curl -fsSLO "$sum_url"
echo "verifying..."
if [ -z "$(sha512sum -c *.sha512sum 2>&1 | grep 'OK')" ]
then
echo "files failed to verify! cleaning up..."
clean_up
fi
echo "extracting..."
tar -xzf ./*.tar.gz -C "$_STEAMPATH/"
echo "updating version number"
echo "$newest_version" > "proton-ge_version.txt"
echo "cleaning up..."
clean_up
echo "done."
cd "$_pwd/"
}
## get versions
current_version=$(get_current_version 2>&1)
echo "current version is $current_version"
newest_version=$(repo_api_request tag_name 2>&1)
echo "newest version is $newest_version"
## check if updated is needed
if [ "$current_version" == "$newest_version" ]
then
echo "proton-ge is already up to date."
exit
## check if proton-ge is installed
elif [ "$current_version" == NULL ]
then
echo "installing proton-ge for the first time..."
## update otherwise
else
echo "proton-ge is out of date. getting the newest release..."
fi
update_proton_ge
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment