From a6919213117ab12e206dc0fb637cec983edb63c2 Mon Sep 17 00:00:00 2001 From: MoritzBoehme Date: Tue, 14 Sep 2021 23:52:39 +0200 Subject: [PATCH] use interactive script --- bin/cproton.sh | 122 +++++++++++++++++++++++++++++++++++++++++++ bin/updatePGEfast.sh | 30 ----------- 2 files changed, 122 insertions(+), 30 deletions(-) create mode 100755 bin/cproton.sh delete mode 100644 bin/updatePGEfast.sh diff --git a/bin/cproton.sh b/bin/cproton.sh new file mode 100755 index 0000000..c8fdb91 --- /dev/null +++ b/bin/cproton.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash +baseuri="https://github.com/GloriousEggroll/proton-ge-custom/releases/download" +latesturi="https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest" +parameter="${1}" +installComplete=false; +dstpath="$HOME/.steam/root/compatibilitytools.d" #### Destinationforlder of the Proton installations +restartSteam=2 +autoInstall=false +#### Set restartSteam=0 to not restart steam after installing Proton (Keep process untouched) +#### Set restartSteam=1 to autorestart steam after installing Proton +#### Set restartSteam=2 to to get a y/n prompt asking if you want to restart Steam after each installation. + +#### Set autoInstall=true to skip the installation prompt and install the latest not-installed, or any forced Proton GE builds +#### Set autoInstall=false to display a installation-confirmation prompt when installing a Proton GE build + +# ########################################## CProton - Custom Proton Installscript 0.2.2 ########################################## +# Disclaimer: Subversions like the MCC versions of Proton 4.21-GE-1, will install as it's main version and not install separately. +# For now, this may result in false "not installed"-detections or errors while force installing a specific subversion. + +PrintReleases() { + echo "----------Description----------" + echo "" + echo "Run './cproton.sh [VersionName]'" + echo "to download specific versions." + echo "" + echo "------------Releases------------" + curl -s https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases | grep -H "tag_name" | cut -d \" -f4 + echo "--------------------------------" +} + +InstallProtonGE() { + rsp="$(curl -sI "$url" | head -1)" + echo "$rsp" | grep -q 302 || { + echo "$rsp" + exit 1 + } + + [ -d "$dstpath" ] || { + mkdir "$dstpath" + echo [Info] Created "$dstpath" + } + curl -sL "$url" > $dstpath/Proton-"$version".tar.gz # Download archive first + if [ ! -z "$sha512url" ]; then # If there is no sha512 the sha512url is empty + if [ $(sha512sum $dstpath/Proton-"$version".tar.gz | cut -b -128) == $((curl -sL $sha512url)| cut -b -128) ]; then # Only the first 128 bytes are significant + tar xfzv $dstpath/Proton-"$version".tar.gz -C "$dstpath" + installComplete=true + else + echo "sha512sum did not match! Stopping installation." + installComplete=false + fi + else + tar xfzv $dstpath/Proton-"$version".tar.gz -C "$dstpath" + installComplete=true + fi + rm $dstpath/Proton-"$version".tar.gz +} + +RestartSteam() { + if [ "$( pgrep steam )" != "" ]; then + echo "Restarting Steam" + pkill -TERM steam #restarting Steam + sleep 5s + nohup steam /dev/null & + fi +} + +RestartSteamCheck() { + if [ "$( pgrep steam )" != "" ] && [ "$installComplete" = true ]; then + if [ $restartSteam == 2 ]; then + read -r -p "Do you want to restart Steam? " prompt + if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then + RestartSteam + else + exit 2 + fi + elif [ $restartSteam == 0 ]; then + exit 0 + fi + RestartSteam + fi +} + +InstallationPrompt() { + if [ "$autoInstall" = true ]; then + if [ ! -d "$dstpath"/Proton-"$version" ]; then + InstallProtonGE + fi + else + read -r -p "Do you want to try to download and (re)install this release? " prompt + if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then + InstallProtonGE + else + echo "Operation canceled" + exit 0 + fi + fi +} + +if [ -z "$parameter" ]; then + version="$(curl -s $latesturi | grep -E -m1 "tag_name" | cut -d \" -f4)" + url=$(curl -s $latesturi | grep -E -m1 "browser_download_url.*.tar.gz" | cut -d \" -f4) + sha512url=$(curl -s $latesturi | grep -E -m1 "browser_download_url.*.sha512sum" | cut -d \" -f4) + if [ -d "$dstpath"/Proton-"$version" ]; then + echo "Proton $version is the latest version and is already installed." + else + echo "Proton $version is the latest version and is not installed yet." + fi +elif [ "$parameter" == "-l" ]; then + PrintReleases +else + url=$baseuri/"$parameter"/Proton-"$parameter".tar.gz + if [ -d "$dstpath"/Proton-"$parameter" ]; then + echo "Proton $parameter is already installed." + else + echo "Proton $parameter is not installed yet." + fi +fi + +if [ ! "$parameter" == "-l" ]; then + InstallationPrompt + RestartSteamCheck +fi diff --git a/bin/updatePGEfast.sh b/bin/updatePGEfast.sh deleted file mode 100644 index d1d7819..0000000 --- a/bin/updatePGEfast.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -baseuri="https://github.com/GloriousEggroll/proton-ge-custom/releases/download" -latesturi="https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest" -dstpath="$HOME/.steam/root/compatibilitytools.d" - - - latestversion="$(curl -s $latesturi | egrep -m1 "tag_name" | cut -d \" -f4)" - if [[ -d $dstpath/Proton-$latestversion ]] - then - echo "Proton $latestversion is the latest version and is already installed." - echo "Exiting..." - exit 0 - else - echo "Proton $latestversion is the latest version and is not installed yet." - echo "Installing Proton $latestverion" - url=$(curl -s $latesturi | egrep -m1 "browser_download_url.*Proton" | cut -d \" -f4) - fi - -rsp="$(curl -sI "$url" | head -1)" -echo "$rsp" | grep -q 302 || { - echo "$rsp" - exit 1 -} - -[ -d "$dstpath" ] || { - mkdir "$dstpath" - echo [Info] Created "$dstpath" -} - -curl -sL "$url" | tar xfzv - -C "$dstpath" \ No newline at end of file