Skip to content

Commit

Permalink
Updated ludusavi from v0.10.0 to v0.19.0 (v0.22.0 is bugged), added v…
Browse files Browse the repository at this point in the history
…ariables for ludusavi versions, moved a warning to README.md and fixed small issues
  • Loading branch information
AngeIo committed Jan 19, 2024
1 parent 3c32ae4 commit ab97834
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ Here are examples of behaviour you can apply by modifying the `STEAM_LOPTS` vari
```

### Final touches
Once you are satisfied with your variables in the `.env` file, you can launch the installation by typing this command:
> [!WARNING]
> All your Launch Options will be overwritten by the following script!
>
> But don't worry, you can always rollback:
>
> A copy of `localconfig.vdf` is created and the script gives you a command to easily restore it back!
Once you are satisfied with your variables in the `.env` file, you can launch the installation:
```
./steam-backup-setup.sh
```
Expand Down
6 changes: 5 additions & 1 deletion init-steam-backup-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export STEAM_BKUPER_REPO="${STEAM_BKUPER_REPO:-'https://github.com/AngeIo/steam-
export STEAM_SAVES_REPO="${STEAM_SAVES_REPO:?}"
export STEAM_PATH="${STEAM_PATH:-'/home/deck/.local/share/Steam/userdata'}"
export STEAM_LOPTS="${STEAM_LOPTS:-%command%;$BIN_DIR/my-steam-backup.sh}"
export LUDUSAVI_VER="${LUDUSAVI_VER:-v0.19.0}"
export LUDUSAVI_FILE="${LUDUSAVI_FILE:-ludusavi-$LUDUSAVI_VER-linux.zip}"

# Uncomment for debugging
# echo "STEAM_BKUPER_DIR = $STEAM_BKUPER_DIR"
Expand All @@ -25,4 +27,6 @@ export STEAM_LOPTS="${STEAM_LOPTS:-%command%;$BIN_DIR/my-steam-backup.sh}"
# echo "STEAM_ACCOUNTID = $STEAM_ACCOUNTID"
# echo "BIN_DIR = $BIN_DIR"
# echo "STEAM_LOPTS = $STEAM_LOPTS"
# echo "STEAM_LAST_LOPTS = $STEAM_LAST_LOPTS"
# echo "STEAM_LAST_LOPTS = $STEAM_LAST_LOPTS"
# echo "LUDUSAVI_VER = $LUDUSAVI_VER"
# echo "LUDUSAVI_FILE = $LUDUSAVI_FILE"
23 changes: 15 additions & 8 deletions steam-backup-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ln -s $SCRIPT_DIR/.env $HOME/steam-bkuper.env &>/dev/null || true
source $SCRIPT_DIR/init-steam-backup-vars.sh

cd $BIN_DIR
wget -qc https://github.com/mtkennerly/ludusavi/releases/download/v0.10.0/ludusavi-v0.10.0-linux.zip -O ludusavi-v0.10.0-linux.zip
unzip -oq ludusavi-v0.10.0-linux.zip
rm ludusavi-v0.10.0-linux.zip
wget -qc https://github.com/mtkennerly/ludusavi/releases/download/$LUDUSAVI_VER/$LUDUSAVI_FILE -O $LUDUSAVI_FILE
unzip -oq $LUDUSAVI_FILE
rm $LUDUSAVI_FILE

if [ ! -d "$STEAM_BKUPER_DIR" ]; then
git clone $STEAM_BKUPER_REPO $STEAM_BKUPER_DIR
Expand Down Expand Up @@ -94,7 +94,6 @@ if [[ "$STEAM_LOPTS" != "NULL" ]]; then
# Edit the localconfig.vdf file to add the command to each of your games' launch options
LCVDFO="$HOME/.steam/steam/userdata/$STEAM_ACCOUNTID/config/localconfig.vdf"
LCVDF="$LCVDFO.bak.$TIMEEPOCH"
printf "/!\ WARNING /!\ \nAll your Launch Options will be overwritten by this script!\nAre you sure you want to continue?\nIn case you want to rollback, you could always restore:\n$LCVDF\n\nPress Enter to confirm or CTRL+C to exit the current script. " && read ans
LOPTS="\\\t\t\t\t\t\t\"LaunchOptions\" \"$STEAM_LOPTS\""
if [ ! -f $LCVDF ]; then
# DEBUG
Expand All @@ -110,17 +109,25 @@ if [[ "$STEAM_LOPTS" != "NULL" ]]; then
sed -i '/"Playtime"/i '"$LOPTS"'' $LCVDFO
echo "Successfully applied your Launch Options to your Steam library!"
echo ""
echo "To restore the previous version of localconfig.vdf, type the following commands:"
echo "If you want to restore the previous version of your localconfig.vdf, type the following commands:"
echo "cp $LCVDFO $LCVDFO.bak"
echo "cp $LCVDF $LCVDFO"
echo ""
###

###
# Define STEAM_LAST_LOPTS variable in $STEAM_BKUPER_DIR/.env
if [ -f "$STEAM_BKUPER_DIR/.env" ]; then
# Use sed to replace the value of STEAM_LAST_LOPTS
sed -i --expression "s@export STEAM_LAST_LOPTS=\"[^\"]*\"@export STEAM_LAST_LOPTS=\"${STEAM_LOPTS}\"@" $STEAM_BKUPER_DIR/.env
echo "Successfully updated STEAM_LAST_LOPTS in .env file."
# Check if the line containing STEAM_LAST_LOPTS exists (ignoring comments)
if grep -q "^export STEAM_LAST_LOPTS=" "$STEAM_BKUPER_DIR/.env"; then
# Use sed to replace the value of STEAM_LAST_LOPTS
sed -i --expression "s@^export STEAM_LAST_LOPTS=\"[^\"]*\"@export STEAM_LAST_LOPTS=\"$STEAM_LOPTS\"@" $STEAM_BKUPER_DIR/.env
echo "Successfully updated STEAM_LAST_LOPTS in .env file."
else
# If the line doesn't exist, add it to a new line at the end of the file
echo -e "\nexport STEAM_LAST_LOPTS=\"$STEAM_LOPTS\"" >> $STEAM_BKUPER_DIR/.env
echo "Added STEAM_LAST_LOPTS to .env file."
fi
else
echo ".env file not found. Please make sure the file exists in the current directory."
fi
Expand Down

0 comments on commit ab97834

Please sign in to comment.