-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·36 lines (29 loc) · 892 Bytes
/
install.sh
File metadata and controls
executable file
·36 lines (29 loc) · 892 Bytes
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
#!/bin/sh
set -e
REPO="afumu/openlink"
BIN="openlink"
INSTALL_DIR="/usr/local/bin"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "不支持的架构: $ARCH"; exit 1 ;;
esac
VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/${REPO}/releases/latest" | sed 's|.*/tag/||')
if [ -z "$VERSION" ]; then
echo "获取版本失败"; exit 1
fi
FILE="${BIN}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILE}"
echo "正在安装 openlink ${VERSION} (${OS}/${ARCH})..."
TMP=$(mktemp -d)
curl -fsSL "$URL" | tar -xz -C "$TMP"
if [ -w "$INSTALL_DIR" ]; then
mv "$TMP/$BIN" "$INSTALL_DIR/$BIN"
else
sudo mv "$TMP/$BIN" "$INSTALL_DIR/$BIN"
fi
rm -rf "$TMP"
echo "安装完成: $(which $BIN)"
echo "运行 'openlink' 启动服务"