forked from unhappychoice/steamfetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·154 lines (136 loc) · 5.01 KB
/
install.sh
File metadata and controls
executable file
·154 lines (136 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
set -e
REPO="unhappychoice/steamfetch"
BINARY_NAME="steamfetch"
get_latest_release() {
curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
}
check_glibc_version() {
if ! command -v ldd &> /dev/null; then
return
fi
GLIBC_VERSION=$(ldd --version 2>&1 | head -n1 | grep -oE '[0-9]+\.[0-9]+' | head -1)
REQUIRED_VERSION="2.35"
if [ -n "$GLIBC_VERSION" ]; then
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$GLIBC_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo ""
echo "WARNING: Your glibc version ($GLIBC_VERSION) is older than $REQUIRED_VERSION."
echo "The pre-built binary may not work on your system."
echo ""
echo "Options:"
echo " 1. Upgrade your OS to get a newer glibc"
echo " 2. Build from source: cargo install steamfetch"
echo " 3. Continue anyway and see if it works"
echo ""
read -p "Continue with installation? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Installation cancelled."
exit 0
fi
fi
fi
}
detect_platform() {
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Linux*)
check_glibc_version
case "$ARCH" in
x86_64)
echo "x86_64-unknown-linux-gnu"
;;
*)
echo "Unsupported architecture: $ARCH (Steam only supports x86_64 on Linux)" >&2
exit 1
;;
esac
;;
Darwin*)
case "$ARCH" in
x86_64)
echo "x86_64-apple-darwin"
;;
arm64)
echo "aarch64-apple-darwin"
;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
;;
MINGW*|MSYS*|CYGWIN*)
echo "x86_64-pc-windows-msvc"
;;
*)
echo "Unsupported OS: $OS" >&2
exit 1
;;
esac
}
main() {
VERSION="${1:-$(get_latest_release)}"
PLATFORM="$(detect_platform)"
if [ -z "$VERSION" ]; then
echo "Failed to detect latest version" >&2
exit 1
fi
echo "Installing $BINARY_NAME $VERSION for $PLATFORM..."
TEMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TEMP_DIR"' EXIT
if [[ "$PLATFORM" == *"windows"* ]]; then
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/${BINARY_NAME}-${VERSION}-${PLATFORM}.zip"
echo "Downloading from $DOWNLOAD_URL..."
curl -sL "$DOWNLOAD_URL" -o "$TEMP_DIR/steamfetch.zip"
unzip -q "$TEMP_DIR/steamfetch.zip" -d "$TEMP_DIR"
rm "$TEMP_DIR/steamfetch.zip"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
else
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/${BINARY_NAME}-${VERSION}-${PLATFORM}.tar.gz"
echo "Downloading from $DOWNLOAD_URL..."
curl -sL "$DOWNLOAD_URL" | tar xz -C "$TEMP_DIR"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
fi
mkdir -p "$INSTALL_DIR"
# Install binary and Steam API library
mv "$TEMP_DIR"/* "$INSTALL_DIR/"
if [[ "$PLATFORM" != *"windows"* ]]; then
chmod +x "$INSTALL_DIR/$BINARY_NAME"
fi
# Verify Steam API library was installed
if [[ "$PLATFORM" == *"linux"* ]] && [ ! -f "$INSTALL_DIR/libsteam_api.so" ]; then
echo "WARNING: libsteam_api.so was not found in the archive."
echo "steamfetch may fail with 'cannot open shared object file' error."
echo ""
fi
if [[ "$PLATFORM" == *"apple"* ]] && [ ! -f "$INSTALL_DIR/libsteam_api.dylib" ]; then
echo "WARNING: libsteam_api.dylib was not found in the archive."
echo "steamfetch may fail with a shared library error."
echo ""
fi
echo "Successfully installed $BINARY_NAME to $INSTALL_DIR/"
echo ""
if [[ "$PLATFORM" == *"windows"* ]]; then
echo "Make sure $INSTALL_DIR is in your PATH"
echo ""
echo "Setup Steam API key:"
echo " 1. Get your API key from: https://steamcommunity.com/dev/apikey"
echo " 2. Find your Steam ID from: https://steamid.io"
echo " 3. Set environment variables:"
echo " set STEAM_API_KEY=your_api_key"
echo " set STEAM_ID=your_steam_id"
else
echo "Make sure $INSTALL_DIR is in your PATH:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
echo ""
echo "Setup Steam API key:"
echo " 1. Get your API key from: https://steamcommunity.com/dev/apikey"
echo " 2. Find your Steam ID from: https://steamid.io"
echo " 3. Set environment variables:"
echo " export STEAM_API_KEY=\"your_api_key\""
echo " export STEAM_ID=\"your_steam_id\""
fi
}
main "$@"