mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-25 18:04:16 +08:00
refactored the steamclient_loader script for Linux + relocate to a separate folder
This commit is contained in:
parent
4282a4f248
commit
09cd6414f1
@ -1,67 +0,0 @@
|
||||
#!/bin/sh
|
||||
EXE="./hl2.sh"
|
||||
EXE_RUN_DIR="$(dirname ${0})"
|
||||
EXE_COMMAND_LINE="-steam -game cstrike"
|
||||
APP_ID=240
|
||||
STEAM_CLIENT_SO=steamclient.so
|
||||
STEAM_CLIENT64_SO=steamclient64.so
|
||||
#STEAM_RUNTIME="./steam_runtime/run.sh"
|
||||
|
||||
if [ ! -d ~/.steam/sdk32 ]; then
|
||||
mkdir -p ~/.steam/sdk32
|
||||
fi
|
||||
if [ ! -d ~/.steam/sdk64 ]; then
|
||||
mkdir -p ~/.steam/sdk64
|
||||
fi
|
||||
|
||||
if [ ! -f ${STEAM_CLIENT_SO} ]; then
|
||||
echo "Couldn't find the requested STEAM_CLIENT_SO."
|
||||
exit
|
||||
fi
|
||||
if [ ! -f ${STEAM_CLIENT64_SO} ]; then
|
||||
echo "Couldn't find the requested STEAM_CLIENT64_SO."
|
||||
exit
|
||||
fi
|
||||
|
||||
# for system failure assume orig files are still good
|
||||
if [ -f ~/.steam/steam.pid.orig ]; then
|
||||
mv -f ~/.steam/steam.pid.orig ~/.steam/steam.pid
|
||||
fi
|
||||
if [ -f ~/.steam/sdk32/steamclient.so.orig ]; then
|
||||
mv -f ~/.steam/sdk32/steamclient.so.orig ~/.steam/sdk32/steamclient.so
|
||||
fi
|
||||
if [ -f ~/.steam/sdk64/steamclient.so.orig ]; then
|
||||
mv -f ~/.steam/sdk64/steamclient.so.orig ~/.steam/sdk64/steamclient.so
|
||||
fi
|
||||
|
||||
if [ -f ~/.steam/steam.pid ]; then
|
||||
mv -f ~/.steam/steam.pid ~/.steam/steam.pid.orig
|
||||
fi
|
||||
if [ -f ~/.steam/sdk32/steamclient.so ]; then
|
||||
mv -f ~/.steam/sdk32/steamclient.so ~/.steam/sdk32/steamclient.so.orig
|
||||
fi
|
||||
if [ -f ~/.steam/sdk64/steamclient.so ]; then
|
||||
mv -f ~/.steam/sdk64/steamclient.so ~/.steam/sdk64/steamclient.so.orig
|
||||
fi
|
||||
|
||||
cp ${STEAM_CLIENT_SO} ~/.steam/sdk32/steamclient.so
|
||||
cp ${STEAM_CLIENT64_SO} ~/.steam/sdk64/steamclient.so
|
||||
echo ${$} > ~/.steam/steam.pid
|
||||
|
||||
cd ${EXE_RUN_DIR}
|
||||
if [ -z ${STEAM_RUNTIME} ]; then
|
||||
SteamAppPath=${EXE_RUN_DIR} SteamAppId=${APP_ID} SteamGameId=${APP_ID} ${EXE} ${EXE_COMMAND_LINE}
|
||||
else
|
||||
SteamAppPath=${EXE_RUN_DIR} SteamAppId=${APP_ID} SteamGameId=${APP_ID} ${STEAM_RUNTIME} ${EXE} ${EXE_COMMAND_LINE}
|
||||
fi
|
||||
|
||||
if [ -f ~/.steam/steam.pid.orig ]; then
|
||||
mv -f ~/.steam/steam.pid.orig ~/.steam/steam.pid
|
||||
fi
|
||||
if [ -f ~/.steam/sdk32/steamclient.so.orig ]; then
|
||||
mv -f ~/.steam/sdk32/steamclient.so.orig ~/.steam/sdk32/steamclient.so
|
||||
fi
|
||||
if [ -f ~/.steam/sdk64/steamclient.so.orig ]; then
|
||||
mv -f ~/.steam/sdk64/steamclient.so.orig ~/.steam/sdk64/steamclient.so
|
||||
fi
|
||||
|
47
tools_linux/steamclient_loader/README.md
Normal file
47
tools_linux/steamclient_loader/README.md
Normal file
@ -0,0 +1,47 @@
|
||||
>## How to use it:
|
||||
Copy both file
|
||||
- `steamclient.so`
|
||||
- `steamclient64.so`
|
||||
|
||||
beside the script and specify the requird input, either from commdnline or via the configuration files: `ldr_*.txt`
|
||||
|
||||
It is recommended to create a separate setup for each game via the config files
|
||||
to avoid specifying the commandline each time.
|
||||
|
||||
Command line arguments will override the values in the configuration files,
|
||||
with an exception for the arguments passed to the executable, both specified
|
||||
in the cofiguration file and via command line will be passed to the executable.
|
||||
|
||||
---
|
||||
|
||||
>## Command line arguments:
|
||||
* `-exe`: path to the executable
|
||||
* `-appid`: numeric app ID
|
||||
* `-cwd`: *`(optional)`* working directory to switch to when running the executable
|
||||
* `-rt`: *`(optional)`* path to Steam runtime script
|
||||
- ex1: `~/.steam/debian-installation/ubuntu12_64/steam-runtime-heavy.sh`
|
||||
- ex2: `~/.steam/debian-installation/ubuntu12_64/steam-runtime-heavy/run.sh`
|
||||
- ex3: `~/.steam/debian-installation/ubuntu12_32/steam-runtime/run.sh`
|
||||
- ex4: `~/.steam/steam_runtime/run.sh`
|
||||
* `--`: *`(optional)`* everything after these 2 dashes will be passed directly to the executable"
|
||||
|
||||
**Note** that any unknown args will be passed to the executable
|
||||
|
||||
### Examples:
|
||||
* `./steamclient_loader.sh -exe ~/games/mygame/executable -appid 480`
|
||||
* `./steamclient_loader.sh -exe ~/games/mygame/executable -appid 480 -- -opengl`
|
||||
* `./steamclient_loader.sh -exe ~/games/mygame/executable -appid 480 -cwd ~/games/mygame/subdir`
|
||||
* `./steamclient_loader.sh -exe ~/games/mygame/executable -appid 480 -rt ~/.steam/debian-installation/ubuntu12_64/steam-runtime-heavy/run.sh`
|
||||
|
||||
---
|
||||
|
||||
>## Configuraion files:
|
||||
Additionally, you can set these values in the equivalent configuration files,
|
||||
everything on a single line for each file, except `ldr_cmd.txt`:
|
||||
* `ldr_exe.txt`: specify the executable path in this file
|
||||
* `ldr_appid.txt`: specify the app ID in this file
|
||||
* `ldr_cwd.txt`: *`(optional)`* specify the working directory of the executable path in this file
|
||||
* `ldr_steam_rt.txt`: *`(optional)`* specify the path of the Steam runtime script in this file
|
||||
* `ldr_cmd.txt`: *`(optional)`* specify aditional arguments that will be passed to the executable in this file,
|
||||
this file has the exception that the arguments must be specified on separate lines
|
||||
|
1
tools_linux/steamclient_loader/ldr_appid.txt
Normal file
1
tools_linux/steamclient_loader/ldr_appid.txt
Normal file
@ -0,0 +1 @@
|
||||
480
|
3
tools_linux/steamclient_loader/ldr_cmdline.txt
Normal file
3
tools_linux/steamclient_loader/ldr_cmdline.txt
Normal file
@ -0,0 +1,3 @@
|
||||
-steam
|
||||
-game
|
||||
-vulkan
|
1
tools_linux/steamclient_loader/ldr_cwd.txt
Normal file
1
tools_linux/steamclient_loader/ldr_cwd.txt
Normal file
@ -0,0 +1 @@
|
||||
./my_game/base_folder/
|
1
tools_linux/steamclient_loader/ldr_exe.txt
Normal file
1
tools_linux/steamclient_loader/ldr_exe.txt
Normal file
@ -0,0 +1 @@
|
||||
my_game_executable
|
1
tools_linux/steamclient_loader/ldr_steam_rt.txt
Normal file
1
tools_linux/steamclient_loader/ldr_steam_rt.txt
Normal file
@ -0,0 +1 @@
|
||||
~/.steam/debian-installation/ubuntu12_64/steam-runtime-heavy.sh
|
218
tools_linux/steamclient_loader/steamclient_loader.sh
Normal file
218
tools_linux/steamclient_loader/steamclient_loader.sh
Normal file
@ -0,0 +1,218 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
EXE="" #"./hl2.sh"
|
||||
APP_ID="" #480
|
||||
EXE_RUN_DIR="" #"$(dirname ${0})"
|
||||
STEAM_RUNTIME="" #"./steam_runtime/run.sh"
|
||||
EXE_COMMAND_LINE=()
|
||||
|
||||
LDR_FILE_EXE="ldr_exe.txt"
|
||||
LDR_FILE_APP_ID="ldr_appid.txt"
|
||||
LDR_FILE_EXE_RUN_DIR="ldr_cwd.txt"
|
||||
LDR_FILE_STEAM_RUNTIME="ldr_steam_rt.txt"
|
||||
LDR_FILE_EXE_COMMAND_LINE="ldr_cmd.txt"
|
||||
|
||||
# MUST be beside this script
|
||||
STEAM_CLIENT_SO=steamclient.so
|
||||
STEAM_CLIENT64_SO=steamclient64.so
|
||||
|
||||
script_dir=$( cd -- "$( dirname -- "${0}" )" &> /dev/null && pwd )
|
||||
steam_base_dir="$( echo ~/.steam )"
|
||||
|
||||
function help_page () {
|
||||
echo;
|
||||
echo "Command line arguments:"
|
||||
echo " -exe: path to the executable"
|
||||
echo " -appid: numeric app ID"
|
||||
echo " -cwd: (optional) working directory to switch to when running the executable"
|
||||
echo " -rt: (optional) path to Steam runtime script"
|
||||
echo " ex1: $steam_base_dir/debian-installation/ubuntu12_64/steam-runtime-heavy.sh"
|
||||
echo " ex2: $steam_base_dir/debian-installation/ubuntu12_64/steam-runtime-heavy/run.sh"
|
||||
echo " ex3: $steam_base_dir/debian-installation/ubuntu12_32/steam-runtime/run.sh"
|
||||
echo " ex4: $steam_base_dir/steam_runtime/run.sh"
|
||||
echo " --: everything after these 2 dashes will be passed directly to the executable"
|
||||
echo;
|
||||
echo "note that any unknown args will be passed to the executable"
|
||||
echo;
|
||||
echo "Additionally, you can set these values in the equivalent configuration files, everything on a single line for each file:"
|
||||
echo " "$LDR_FILE_EXE": specify the executable path in this file"
|
||||
echo " "$LDR_FILE_APP_ID": specify the app ID in this file"
|
||||
echo " "$LDR_FILE_EXE_RUN_DIR": specify the working directory of the executable path in this file"
|
||||
echo " "$LDR_FILE_STEAM_RUNTIME": specify the path of the Steam runtime script in this file"
|
||||
echo " "$LDR_FILE_EXE_COMMAND_LINE": specify aditional arguments that will be passed to the executable in this file,"
|
||||
echo " this file has the exception that the arguments must be specified on separate lines"
|
||||
echo;
|
||||
echo "Command line arguments will override the values in the configuration files,"
|
||||
echo "with an exception for the arguments passed to the executable, both specified"
|
||||
echo "in the cofiguration file and via command line will be passed to the executable"
|
||||
echo;
|
||||
}
|
||||
|
||||
# mandatory checks
|
||||
if [[ ! -f "$script_dir/${STEAM_CLIENT_SO}" ]]; then
|
||||
echo "'$STEAM_CLIENT_SO' must be placed beside this script"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$script_dir/${STEAM_CLIENT64_SO}" ]; then
|
||||
echo "'$STEAM_CLIENT64_SO' must be placed beside this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# no args = help page
|
||||
if [[ $# = 0 ]]; then
|
||||
help_page
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# try to load from config files first
|
||||
# unfortunately we need eval to expand stuff like ~/my_path
|
||||
if [[ -f "$script_dir/$LDR_FILE_EXE" ]]; then
|
||||
read -r -s EXE < "$script_dir/$LDR_FILE_EXE"
|
||||
[[ ! -z "$EXE" ]] && EXE="$(eval echo "$EXE")"
|
||||
fi
|
||||
if [[ -f "$script_dir/$LDR_FILE_APP_ID" ]]; then
|
||||
read -r -s APP_ID < "$script_dir/$LDR_FILE_APP_ID"
|
||||
fi
|
||||
if [[ -f "$script_dir/$LDR_FILE_EXE_RUN_DIR" ]]; then
|
||||
read -r -s EXE_RUN_DIR < "$script_dir/$LDR_FILE_EXE_RUN_DIR"
|
||||
[[ ! -z "$EXE_RUN_DIR" ]] && EXE_RUN_DIR="$(eval echo "$EXE_RUN_DIR")"
|
||||
fi
|
||||
if [[ -f "$script_dir/$LDR_FILE_STEAM_RUNTIME" ]]; then
|
||||
read -r -s STEAM_RUNTIME < "$script_dir/$LDR_FILE_STEAM_RUNTIME"
|
||||
[[ ! -z "$STEAM_RUNTIME" ]] && STEAM_RUNTIME="$(eval echo "$STEAM_RUNTIME")"
|
||||
fi
|
||||
if [[ -f "$script_dir/$LDR_FILE_EXE_COMMAND_LINE" ]]; then
|
||||
EXTRA_EXE_COMMAND_LINE=()
|
||||
readarray -t EXTRA_EXE_COMMAND_LINE < "$script_dir/$LDR_FILE_EXE_COMMAND_LINE"
|
||||
for arg in "${EXTRA_EXE_COMMAND_LINE[@]}"; do
|
||||
arg="$(eval echo "$arg")"
|
||||
EXE_COMMAND_LINE+=("$arg")
|
||||
done
|
||||
fi
|
||||
|
||||
# then read command line args
|
||||
i=1 # 0 is script path
|
||||
for (( ; i<=$#; i++ )); do
|
||||
var="${!i}"
|
||||
if [[ "$var" = "-exe" ]]; then
|
||||
i=$((i+1))
|
||||
EXE="${!i}"
|
||||
elif [[ "$var" = "-appid" ]]; then
|
||||
i=$((i+1))
|
||||
APP_ID="${!i}"
|
||||
elif [[ "$var" = "-cwd" ]]; then
|
||||
i=$((i+1))
|
||||
EXE_RUN_DIR="${!i}"
|
||||
elif [[ "$var" = "-rt" ]]; then
|
||||
i=$((i+1))
|
||||
STEAM_RUNTIME="${!i}"
|
||||
elif [[ "$var" = "--" ]]; then # stop processing args, everything else is passed to app
|
||||
i=$((i+1))
|
||||
break
|
||||
else # pass unknown args to app
|
||||
EXE_COMMAND_LINE+=("$var")
|
||||
fi
|
||||
done
|
||||
|
||||
# extra args after '--' will be processed here
|
||||
for (( ; i<=$#; i++ )); do
|
||||
EXE_COMMAND_LINE+=("${!i}")
|
||||
done
|
||||
|
||||
# sanity checks
|
||||
# prepending the script dir helps sudo users when for example EXE=./mygame
|
||||
[[ -f "$EXE" ]] || EXE="$script_dir/$EXE"
|
||||
if [[ ! -f "$EXE" ]]; then
|
||||
echo "[X] executable was not set or not found" >&2
|
||||
help_page
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$APP_ID" =~ ^[0-9]+$ ]]; then
|
||||
echo "[X] app ID was not set or not a valid number" >&2
|
||||
help_page
|
||||
exit 1
|
||||
fi
|
||||
# use the exe's dir if non-specified
|
||||
[[ -z "$EXE_RUN_DIR" ]] && EXE_RUN_DIR="$(dirname "$EXE")"
|
||||
if [[ ! -d "$EXE_RUN_DIR" ]]; then
|
||||
echo "[X] executable working directory is invalid" >&2
|
||||
help_page
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -z "$STEAM_RUNTIME" ]] && [[ ! -f "$STEAM_RUNTIME" ]]; then
|
||||
echo "[X] Steam runtime script was set but the file was not found" >&2
|
||||
help_page
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# print everything
|
||||
echo EXE = "'$EXE'"
|
||||
echo APP_ID = $APP_ID
|
||||
echo EXE_RUN_DIR = "'$EXE_RUN_DIR'"
|
||||
|
||||
if [[ -z "$STEAM_RUNTIME" ]]; then
|
||||
echo "STEAM_RUNTIME was not set"
|
||||
else
|
||||
echo STEAM_RUNTIME = "'$STEAM_RUNTIME'"
|
||||
fi
|
||||
|
||||
echo EXE_COMMAND_LINE = "${EXE_COMMAND_LINE[@]}"
|
||||
|
||||
# prepare the required dirs
|
||||
if [[ ! -d "$steam_base_dir/sdk32" ]]; then
|
||||
mkdir -p "$steam_base_dir/sdk32"
|
||||
fi
|
||||
if [[ ! -d "$steam_base_dir/sdk64" ]]; then
|
||||
mkdir -p "$steam_base_dir/sdk64"
|
||||
fi
|
||||
|
||||
# restore earlier backup, we do this here because the user may have crashed the script in an earlier run
|
||||
# before it could restore the backup at the last stage
|
||||
if [ -f "$steam_base_dir/steam.pid.orig" ]; then
|
||||
mv -f "$steam_base_dir/steam.pid.orig" "$steam_base_dir/steam.pid"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk32/steamclient.so.orig" ]; then
|
||||
mv -f "$steam_base_dir/sdk32/steamclient.so.orig" "$steam_base_dir/sdk32/steamclient.so"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk64/steamclient.so.orig" ]; then
|
||||
mv -f "$steam_base_dir/sdk64/steamclient.so.orig" "$steam_base_dir/sdk64/steamclient.so"
|
||||
fi
|
||||
|
||||
# make a backup of original files
|
||||
if [ -f "$steam_base_dir/steam.pid" ]; then
|
||||
mv -f "$steam_base_dir/steam.pid" "$steam_base_dir/steam.pid.orig"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk32/steamclient.so" ]; then
|
||||
mv -f "$steam_base_dir/sdk32/steamclient.so" "$steam_base_dir/sdk32/steamclient.so.orig"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk64/steamclient.so" ]; then
|
||||
mv -f "$steam_base_dir/sdk64/steamclient.so" "$steam_base_dir/sdk64/steamclient.so.orig"
|
||||
fi
|
||||
|
||||
# copy our files
|
||||
cp -f "$script_dir/$STEAM_CLIENT_SO" "$steam_base_dir/sdk32/steamclient.so"
|
||||
cp -f "$script_dir/$STEAM_CLIENT64_SO" "$steam_base_dir/sdk64/steamclient.so"
|
||||
echo ${$} > "$steam_base_dir/steam.pid"
|
||||
|
||||
# set variables and run the app
|
||||
pushd "${EXE_RUN_DIR}"
|
||||
|
||||
if [ -z "${STEAM_RUNTIME}" ]; then
|
||||
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$EXE" "${EXE_COMMAND_LINE[@]}"
|
||||
else
|
||||
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$STEAM_RUNTIME" "$EXE" "${EXE_COMMAND_LINE[@]}"
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
#restore backup
|
||||
if [ -f "$steam_base_dir/steam.pid.orig" ]; then
|
||||
mv -f "$steam_base_dir/steam.pid.orig" "$steam_base_dir/steam.pid"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk32/steamclient.so.orig" ]; then
|
||||
mv -f "$steam_base_dir/sdk32/steamclient.so.orig" "$steam_base_dir/sdk32/steamclient.so"
|
||||
fi
|
||||
if [ -f "$steam_base_dir/sdk64/steamclient.so.orig" ]; then
|
||||
mv -f "$steam_base_dir/sdk64/steamclient.so.orig" "$steam_base_dir/sdk64/steamclient.so"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user