Files
Elsword-GE/scripts/install-compat-tool.sh
T
magges aa7efaa572
build-elsword-ge / build (push) Has been cancelled
feat: add generic release installer
2026-06-27 11:32:45 +02:00

98 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
native_dir_default="${HOME}/.local/share/Steam/compatibilitytools.d"
flatpak_dir_default="${HOME}/.var/app/com.valvesoftware.Steam/data/Steam/compatibilitytools.d"
usage() {
cat <<'EOF'
Usage:
./scripts/install-compat-tool.sh /path/to/Tool.tar.zst
./scripts/install-compat-tool.sh --native /path/to/Tool.tar.zst
./scripts/install-compat-tool.sh --flatpak /path/to/Tool.tar.zst
./scripts/install-compat-tool.sh --all /path/to/Tool.tar.zst
Options:
--native Install into native Steam only
--flatpak Install into Flatpak Steam only
--all Install into both native Steam and Flatpak Steam
EOF
}
mode="auto"
archive=""
while [[ $# -gt 0 ]]; do
case "$1" in
--native|--flatpak|--all)
mode="${1#--}"
shift
;;
-h|--help)
usage
exit 0
;;
*)
archive="$1"
shift
;;
esac
done
[[ -n "$archive" ]] || {
usage >&2
exit 1
}
[[ -f "$archive" ]] || {
printf "Archive not found: %s\n" "$archive" >&2
exit 1
}
mapfile -t archive_entries < <(tar -tf "$archive")
tool_name="${archive_entries[0]%%/*}"
[[ -n "$tool_name" ]] || {
printf "Could not determine tool name from archive: %s\n" "$archive" >&2
exit 1
}
targets=()
case "$mode" in
native)
targets+=("$native_dir_default")
;;
flatpak)
targets+=("$flatpak_dir_default")
;;
all)
targets+=("$native_dir_default" "$flatpak_dir_default")
;;
auto)
if [[ -d "${native_dir_default%/}/.." || -d "$native_dir_default" ]]; then
targets+=("$native_dir_default")
fi
if [[ -d "${flatpak_dir_default%/}/.." || -d "$flatpak_dir_default" ]]; then
targets+=("$flatpak_dir_default")
fi
if [[ ${#targets[@]} -eq 0 ]]; then
targets+=("$native_dir_default")
fi
;;
*)
printf "Unsupported mode: %s\n" "$mode" >&2
exit 1
;;
esac
for target in "${targets[@]}"; do
mkdir -p "$target"
rm -rf "$target/$tool_name"
tar --zstd -xf "$archive" -C "$target"
printf "Installed %s to %s\n" "$tool_name" "$target/$tool_name"
done
printf "Steam restart required.\n"
printf "Select '%s' in the game's compatibility settings.\n" "$tool_name"