diff --git a/asset.sh b/asset.sh index 597da0a..90a29cf 100644 --- a/asset.sh +++ b/asset.sh @@ -2,11 +2,47 @@ get_github_latest_version() { VERSION=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'); } +get_architecture() { + case "$(uname -m)" in + 'i386' | 'i686') + MACHINE='i386' + ;; + 'amd64' | 'x86_64') + MACHINE='amd64' + ;; + 'armv7' | 'armv7l') + MACHINE='arm' + ;; + 'armv8' | 'aarch64') + MACHINE='arm64' + ;; + *) + echo "The architecture is not supported." + exit 1 + ;; + esac +} + XRAY_DIR="/tmp/xray" ASSET_DIR="/tmp/asset" mkdir -p $XRAY_DIR/pkg -XRAY_PKG_NAME="Xray-linux-arm64-v8a.zip" +get_architecture +case "$MACHINE" in + 'i386') + XRAY_PKG_NAME="Xray-linux-32.zip" + ;; + 'amd64') + XRAY_PKG_NAME="Xray-linux-64.zip" + ;; + 'arm') + XRAY_PKG_NAME="Xray-linux-arm32-v7a.zip" + ;; + 'arm64') + XRAY_PKG_NAME="Xray-linux-arm64-v8a.zip" + ;; +esac + get_github_latest_version "XTLS/Xray-core" wget -P $XRAY_DIR/pkg "https://hub.fastgit.org/XTLS/Xray-core/releases/download/$VERSION/$XRAY_PKG_NAME" unzip $XRAY_DIR/pkg/$XRAY_PKG_NAME -d /$XRAY_DIR/pkg