#!/bin/bash
# Define SteamCMD executable path (adjust if needed)
STEAMCMD_PATH="/usr/games/steamcmd"
# Ensure steamcmd is installed
if [ ! -f "$STEAMCMD_PATH" ]; then
echo "Error: SteamCMD not found at $STEAMCMD_PATH"
exit 1
fi
# Prompt for Game ID
read -p "Enter the Steam Game ID: " GAME_ID
# Validate input
if ! [[ "$GAME_ID" =~ ^[0-9]+$ ]]; then
echo "Invalid Game ID. Please enter a numeric value."
exit 1
fi
# Prompt for Install Directory
read -p "Enter the install directory (absolute path): " INSTALL_DIR
# Ensure the directory exists or create it
mkdir -p "$INSTALL_DIR"
# Run SteamCMD to install the game
"$STEAMCMD_PATH" +login anonymous +force_install_dir "$INSTALL_DIR" +app_update "$GAME_ID" validate +quit
# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "Game ID $GAME_ID installed successfully in $INSTALL_DIR"
else
echo "Error: Installation failed."
exit 1
fi