← Files Lexmount Browser AutomationARCHIVED FILE
skills/lexmount-cloud-browser/scripts/browser.sh
1.95 KB · Nov 11, 2026 · 12:47 UTC
#!/bin/sh
set -eu
. "$(dirname -- "$0")/runtime.sh"
site='global'
api='https://api.lexmount.com'
connect='https://browser.lexmount.com'
if [ ! -f "$binary" ]; then
echo "CLI is not installed at $binary. Run this Skill's scripts/bootstrap.sh." >&2
exit 127
fi
for argument in "$@"; do
case "$argument" in
--connect-base-url|--connect-base-url=*|--credentials-file|--credentials-file=*)
echo "This edition fixes its authorization site. Use LEXMOUNT_BROWSER_CREDENTIALS_FILE only for same-site task credentials." >&2
exit 2 ;;
esac
done
if [ -n "${LEXMOUNT_BASE_URL:-}" ] && [ "${LEXMOUNT_BASE_URL%/}" != "$api" ]; then
echo "LEXMOUNT_BASE_URL conflicts with the installed $site edition." >&2
exit 2
fi
if [ -n "${LEXMOUNT_API_KEY:-}${LEXMOUNT_PROJECT_ID:-}" ]; then
if [ -z "${LEXMOUNT_API_KEY:-}" ] || [ -z "${LEXMOUNT_PROJECT_ID:-}" ] || [ -z "${LEXMOUNT_BASE_URL:-}" ]; then
echo "Managed credentials require both key and project plus this edition's explicit LEXMOUNT_BASE_URL." >&2
exit 2
fi
fi
export LEXMOUNT_BASE_URL="$api"
export LEXMOUNT_BROWSER_CREDENTIALS_FILE="${LEXMOUNT_BROWSER_CREDENTIALS_FILE:-${HOME:?HOME is required}/.config/lexmount/browser-cli/sites/$site/credentials.json}"
if [ "${1:-}" = auth ] && [ "${2:-}" = login ]; then
exec "$binary" "$@" --connect-base-url "$connect"
fi
if [ "${1:-}" = auth ] && [ "${2:-}" = logout ]; then
exec "$binary" "$@"
fi
if [ "${1:-}" != version ] && [ "${1:-}" != --help ] && [ "${1:-}" != --version ] && [ -z "${LEXMOUNT_API_KEY:-}" ]; then
status_json=$("$binary" auth status) || { echo 'Cannot read credential status; repair same-site authorization before continuing.' >&2; exit 2; }
stored_api=$(printf '%s\n' "$status_json" | sed -n 's/.*"api_base_url"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')
if [ -n "$stored_api" ] && [ "${stored_api%/}" != "$api" ]; then
echo 'Credentials belong to another site; authorize this edition separately.' >&2
exit 2
fi
fi
exec "$binary" "$@"
SHA-256: e9e0fe5608324a48bdafa4b75a72e26a6f2bef8800c8057452a7c98dce9727ec