Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Helper for downloading Windows-only Steam games on Linux (eg. for the ScummVM resources)
#!/bin/sh
#
# A simple helper to automate the process of downloading Windows-only games
# using the Linux version of SteamCMD.
#
# (This is what happens when I self-nerd-snipe on something despite finding
# it distasteful, like downloading ScummVM resources from Steam because the
# Humble Bundle DRM-free downloads were missing a couple of the games offered
# by the included the Steam key.)
#
# Installation:
# 0. OPTIONAL: Create a VM to isolate SteamCMD from your LAN
# a. Install Linux in VirtualBox and lock it down however you want
# b. Disable 3D acceleration in the VM's display settings
# (Last I checked, Steam refused to run with VirtualBox's OpenGL)
# b. Mount a shared folder at /media/sf_from_steam_vm so
# this script's default settings can exfiltrate files.
# c. Get Steam working so you can use the GUI client to cache your
# login credentials and redeem new keys.
# (You may need the included run_steam.sh)
# 1. OPTIONAL: Install Zenity (only required for non-terminal use)
# sudo apt-get install zenity
# 2. Install SteamCMD
# https://developer.valvesoftware.com/wiki/SteamCMD#Linux
# 3. Save this script into the steamcmd folder and mark it
# as being executable.
# 4. OPTIONAL: Edit the TARGET_PATH line
#
# Usage:
# 0. Make sure your Steam login credentials have been cached
# 1. Go to https://steamdb.info/ and look up the ID for your game.
# 2a. If you have Zenity, double-click this script and type in the ID.
# OR
# 2b. If you prefer using a terminal, run `grab_id.sh` and pass the
# desired IDs as command-line arguments.
# 3. Wait for the script to exit.
#
# If the process fails, you will be left with a `grab_id_script.txt` file in
# the steamcmd folder for debugging purposes.
#
# If you want to place this somewhere other than the steamcmd folder, the
# main thing you'll need to change is the `./steamcmd.sh` at the bottom.
# Where the games will be downloaded to
# TODO: Figure out how to quote spaces in paths in steamcmd scripts
TARGET_PATH=/media/sf_from_steam_vm/steam_games
# If no arguments were provided, prompt for IDs using Zenity and re-exec
if [ $# = 0 ]; then
ID="$(zenity --entry --title="grab_id.sh" --text="Enter Steam IDs:")"
if [ "$?" != 0 ]; then
exit
fi
# shellcheck disable=SC2086
exec "$0" $ID
fi
# Ensure paths are relative to the steamcmd folder
cd "$(dirname "$(readlink -f "$0")")"
# Build the SteamCMD script
echo "@sSteamCmdForcePlatformType windows" > grab_id_script.txt
echo "login deitarion" >> grab_id_script.txt
echo "force_install_dir $TARGET_PATH" >> grab_id_script.txt
for X in "$@"; do
echo "app_update $X validate" >> grab_id_script.txt
done
echo "quit" >> grab_id_script.txt
# Ensure the target directory exists
mkdir -p "$TARGET_PATH"
# Run SteamCMD and remove the script on success
echo "Grabbing games with IDs: $@"
./steamcmd.sh +runscript grab_id_script.txt && rm grab_id_script.txt
#!/bin/sh
# Wrapper to work around problems I experience when trying to run the GUI
# Steam client in Lubuntu 14.04 under VirtualBox.
#
# NOTE: Removing libstdc++ from the steam runtime is only technically
# necessary for whichever version the client actually uses.
# (When I built my original VM, that was the 32-bit version.)
# Steam dies when it can't properly autodetect the CPU speed in VirtualBox
export CPU_MHZ=2000
# Steam dies when the Steam runtime's libstdc++ doesn't play nice with Lubuntu 14.04
find ~/.steam/steam/ubuntu12_32/steam-runtime/ -iname '*libstdc++.so*' -execdir mv {} {}.bak \;
find ~/.steam/steam/ubuntu12_64/steam-runtime/ -iname '*libstdc++.so*' -execdir mv {} {}.bak \;
steam "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment