Skip to content

Instantly share code, notes, and snippets.

@Azkali
Created February 23, 2026 07:12
Show Gist options
  • Select an option

  • Save Azkali/dbf418cae25236c0fd61a56478c89dfb to your computer and use it in GitHub Desktop.

Select an option

Save Azkali/dbf418cae25236c0fd61a56478c89dfb to your computer and use it in GitHub Desktop.
Steamcmd + Goldberg wrapper
#!/bin/bash
set -ex
export GAME="$1"
setup() {
[[ -z "${GAME}" ]] && echo "Game name missing" && exit
mkdir -p "${HOME}/SteamGames/${GAME}"
cd "${HOME}/SteamGames"
if [[ ! -f "${HOME}/SteamGames/steamcmd.sh" ]]; then
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
fi
if [[ ! -e "${HOME}/.local/share/goldberg" ]]; then
wget https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/jobs/4247811310/artifacts/download -O goldberg.zip
unzip goldberg.zip -d "${HOME}/.local/share/goldberg"
rm goldberg.zip
fi
if [[ ! -f "${HOME}/SteamGames/.api_key" ]]; then
echo "To use this script, you need to get your Steam API key."
echo "You can obtain one by registering at https://steamcommunity.com/dev/apikey"
echo "Enter your Steam API key:"
until [[ -z ${API_KEY} ]]; do read -r API_KEY; done
echo "API_KEY=${API_KEY}" >> "${HOME}/SteamGames/.api_key"
export API_KEY
else
source "${HOME}/SteamGames/.api_key"
fi
}
get_game_id() {
if [[ -z ${GAME//[0-9]} ]]; then
echo "Using given Game ID for fetching the game"
APPID=${GAME}
else
set +x
STEAMDB=$(curl -sS "http://api.steampowered.com/IStoreService/GetAppList/v1/?key=${API_KEY}&max_results=50000")
APPID=$(echo "${STEAMDB}" | jq -r '.response.apps.[] | select (.name=="'"${GAME}"'") | .appid')
LAST_APPID=$(echo ${STEAMDB} | jq -r '.response.apps.[-1].appid')
while [[ -z ${APPID} && ${LAST_APPID} != ${CUR_APPID} ]]; do
STEAMDB=$(curl -sS "http://api.steampowered.com/IStoreService/GetAppList/v1/?key=${API_KEY}&max_results=50000&last_appid=${LAST_APPID}")
APPID=$(echo "${STEAMDB}" | jq -r '.response.apps.[] | select (.name=="'"${GAME}"'") | .appid')
CUR_APPID=${LAST_APPID}
LAST_APPID=$(echo ${STEAMDB} | jq -r '.response.apps.[-1].appid')
echo "Trying to find ${GAME} ID: ${APPID} parsing 50k list, last appid in the list ${LAST_APPID}"
done
[[ -z $APPID ]] && echo "$GAME is not a valid Steam Game name'; Please run ./$0 \"GAME NAME\" if your game contains spaces"
echo "Found valid ${APPID} for ${GAME}"
set -x
fi
export APPID
}
validate_login() {
[[ -z "${STEAM_USER}" ]] && read -r -p "Steam username: " STEAM_USER
[[ -z "${STEAM_PASSWORD}" ]] && read -r -p "Steam password: " STEAM_PASSWORD
[[ -z "${STEAM_GUARD}" ]] && read -r -p "Do you have Steam Guard installed ?(y/n): " STEAM_GUARD
until [[ "${STEAM_GUARD}" != 'y' || "${STEAM_GUARD}" != 'n' ]]; do read -r -p "Do you have Steam Guard installed ?(y/n): " STEAM_GUARD; done
[[ "${STEAM_GUARD}" == "y" ]] && read -r -p "Input Steam Guard code: " STEAM_CODE;
export STEAM_USER STEAM_PASSWORD STEAM_CODE STEAM_GUARD
${HOME}/SteamGames/steamcmd.sh +login "${STEAM_USER}" "${STEAM_PASSWORD}" "${STEAM_CODE}" +quit
return $?
}
login() {
if [[ ! -f "${HOME}/SteamGames/.credentials" || ! -s "${HOME}/SteamGames/.credentials" ]]; then
until validate_login; do echo "Wrong Username/Password combo, missing steam guard code or steam guard code timeout; Retrying"; done
echo -e "STEAM_USER=${STEAM_USER}\nSTEAM_PASSWORD=${STEAM_PASSWORD}\nSTEAM_GUARD=${STEAM_GUARD}" > "${HOME}/SteamGames/.credentials"
else source "${HOME}/SteamGames/.credentials"; fi
}
download() {
cat << EOT > ${APPID}.txt
@ShutdownOnFailedCommand 1
@NoPromptForPassword 1
force_install_dir "${HOME}/SteamGames/${GAME}"
login ${STEAM_USER} ${STEAM_PASSWORD} ${STEAM_CODE}
app_update ${APPID} validate
quit
EOT
${HOME}/SteamGames/steamcmd.sh +runscript ${APPID}.txt
}
remove_drm() {
while IFS= read -r -d '' fn; do
base=$(basename "$fn")
ext=${fn##*.}
# Only process shared objects and DLLs we care about
case "$base" in
steam_api*.so|steam_api*.dll|steamclient.so) ;;
*) continue ;;
esac
fileinfo=$(file -b "$fn")
if [[ $fileinfo == *"Intel i386"* ]]; then
arch=x86
elif [[ $fileinfo == *"x86-64"* ]]; then
arch=x86_64
else
echo "Unrecognized architecture: $fn"
continue
fi
case "$base" in
steam_api*.so)
src="$HOME/.local/share/goldberg/linux/$arch/libsteam_api.so"
;;
steam_api*.dll)
if [[ $arch == x86 ]]; then
src="$HOME/.local/share/goldberg/steam_api.dll"
else
src="$HOME/.local/share/goldberg/steam_api64.dll"
fi
;;
steamclient.so)
src="$HOME/.local/share/goldberg/linux/$arch/steamclient.so"
;;
*)
continue
;;
esac
cp "$src" "$fn"
done < <(find "${HOME}/SteamGames/${GAME}" -name 'steam_api*.*' -print0)
}
main() {
setup
get_game_id
login
download
remove_drm
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment