From 985608bfe733e69bccea805886326a108bd2cce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=B0=8F=E9=99=8C?= Date: Sat, 21 Dec 2024 22:46:55 +0800 Subject: [PATCH] 1111 --- README.md | 10 ++++ go.php => index.php | 0 install.sh | 108 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) rename go.php => index.php (100%) create mode 100644 install.sh diff --git a/README.md b/README.md index b54b7b5..9ec6dea 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ ## 安装步骤 + +### 一键安装方法, install.sh + +```bash +curl -o install.sh https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/install.sh && chmod +x install.sh && ./install.sh +``` + + + + ### 使用 Node.js 版本 1. **下载代理脚本** diff --git a/go.php b/index.php similarity index 100% rename from go.php rename to index.php diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..7f7fe4b --- /dev/null +++ b/install.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +# Determine OS and architecture +OS=$(uname -s) +ARCH=$(uname -m) + +# swoole-cli 版本号 +VERSION="5.1.4" + +# Set the download URL based on OS and architecture +case "$OS" in + Linux) + case "$ARCH" in + arm64) + FILE_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-v${VERSION}-linux-arm64.tar.xz" + ;; + x86_64) + FILE_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-v${VERSION}-linux-x64.tar.xz" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; + esac + ;; + Darwin) + case "$ARCH" in + arm64) + FILE_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-v${VERSION}-macos-arm64.tar.xz" + ;; + x86_64) + FILE_URL="https://wenda-1252906962.file.myqcloud.com/dist/swoole-cli-v${VERSION}-macos-x64.tar.xz" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; + esac + ;; + *) + echo "Unsupported OS: $OS" + exit 1 + ;; +esac + +# Check if Node.js is installed +if command -v node &> /dev/null; then + echo "Node.js is installed. Proceeding with Node.js script setup." + + # Download the Node.js proxy script + echo "Downloading index.js..." + if ! curl -o "index.js" "https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/index.js"; then + echo "Failed to download index.js. Please check your internet connection and try again." + exit 1 + fi + + # Run the Node.js proxy service + echo "Running Node.js proxy service..." + node index.js +else + echo "Node.js is not installed. Proceeding with swoole-cli setup." + + # Set the fixed file name + FILE_NAME="swoole-cli.tar.xz" + + # Create a temporary directory + TEMP_DIR=$(mktemp -d) + mkdir -p "$TEMP_DIR" + + # Download the file to the temporary directory + echo "Downloading $FILE_NAME from $FILE_URL to $TEMP_DIR..." + if ! curl -o "$TEMP_DIR/$FILE_NAME" "$FILE_URL"; then + echo "Download failed. Please check your internet connection and try again." + exit 1 + fi + + # Verify the download + if [ ! -f "$TEMP_DIR/$FILE_NAME" ]; then + echo "Downloaded file not found in $TEMP_DIR. Download may have failed." + exit 1 + fi + + # Extract the file to the temporary directory + tar -xf "$TEMP_DIR/$FILE_NAME" -C "$TEMP_DIR" || { + echo "Extraction failed. Please make sure you have the necessary tools to extract the file." + exit 1 + } + + # Move the extracted file to the current directory + mv "$TEMP_DIR"/swoole-cli . + + # Remove unnecessary files + echo "Removing unnecessary files..." + rm -rf "$TEMP_DIR" + + # Check if index.php file exists, if not, download it + if [ ! -f "index.php" ]; then + echo "Downloading index.php..." + if ! curl -o "index.php" "https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/index.php"; then + echo "Failed to download index.php. Please check your internet connection and try again." + exit 1 + fi + fi + + # Run the PHP indexer + echo "Running PHP indexer..." + ./swoole-cli ./index.php +fi