mirror of
https://github.com/seanbetts/steam-hardware-watch.git
synced 2026-10-06 01:00:18 +02:00
63 lines
2.0 KiB
Bash
Executable File
63 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname "$0")" && pwd)"
|
|
REPO_DIR="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)"
|
|
LOCAL_DIR="$REPO_DIR/.local"
|
|
|
|
PROFILE_DIR="${1:-${STEAMDB_PROFILE_DIR:-$LOCAL_DIR/playwright-steamdb-profile}}"
|
|
PORT="${2:-${STEAMDB_CDP_PORT:-55685}}"
|
|
URL="${STEAMDB_BOOTSTRAP_URL:-https://steamdb.info/app/4165870/}"
|
|
ENV_FILE="${STEAMDB_ENV_FILE:-$LOCAL_DIR/steamdb-env.sh}"
|
|
|
|
mkdir -p "$PROFILE_DIR" "$LOCAL_DIR"
|
|
|
|
existing_pid="$(ps aux | awk -v profile="$PROFILE_DIR" -v port="$PORT" '
|
|
index($0, "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome") &&
|
|
index($0, profile) &&
|
|
index($0, "--remote-debugging-port=" port) {
|
|
print $2
|
|
exit
|
|
}
|
|
')"
|
|
|
|
if [ -z "$existing_pid" ]; then
|
|
open -g -na "Google Chrome" --args \
|
|
"--user-data-dir=$PROFILE_DIR" \
|
|
"--remote-debugging-port=$PORT" \
|
|
--no-first-run \
|
|
--disable-sync \
|
|
--new-window \
|
|
"$URL"
|
|
|
|
attempts=0
|
|
until curl -fsS "http://127.0.0.1:$PORT/json/version" >/dev/null 2>&1; do
|
|
attempts=$((attempts + 1))
|
|
if [ "$attempts" -ge 30 ]; then
|
|
echo "failed to observe a Chrome CDP endpoint on port $PORT" >&2
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
else
|
|
echo "SteamDB bootstrap browser already running on port $PORT (pid $existing_pid)."
|
|
fi
|
|
|
|
cat > "$ENV_FILE" <<EOF
|
|
export STEAMDB_PLAYWRIGHT_FALLBACK=1
|
|
export STEAMDB_PROFILE_DIR="$PROFILE_DIR"
|
|
export STEAMDB_CDP_ENDPOINT="http://127.0.0.1:$PORT"
|
|
export STEAMDB_BROWSER_CHANNEL="chrome"
|
|
export STEAMDB_REFERER="https://steamdb.info/app/4165870/"
|
|
EOF
|
|
|
|
printf '%s\n' "SteamDB browser bootstrap ready."
|
|
printf '%s\n' "Profile: $PROFILE_DIR"
|
|
printf '%s\n' "CDP endpoint: http://127.0.0.1:$PORT"
|
|
printf '%s\n' "Env file: $ENV_FILE"
|
|
printf '%s\n' ""
|
|
printf '%s\n' "Next steps:"
|
|
printf '%s\n' "1. If SteamDB needs manual interaction, switch to the dedicated Chrome window when convenient."
|
|
printf '%s\n' "2. Leave that dedicated browser running in the background."
|
|
printf '%s\n' "3. Source the env file before a run, or let check_steamdb.sh pick it up automatically."
|