| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | #!/bin/bash# Use environment variable VERSION if set, otherwise use defaultVERSION=${VERSION:-0.0.1}# Detect OS and architectureOS=$(uname -s | tr '[:upper:]' '[:lower:]')ARCH=$(uname -m)# Convert architecture namingif [ "$ARCH" = "x86_64" ]; then    ARCH="amd64"elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then    ARCH="arm64"else    echo "Unsupported architecture: $ARCH"    exit 1fi# Only allow macOS and Linuxif [ "$OS" != "darwin" ] && [ "$OS" != "linux" ]; then    echo "Unsupported operating system: $OS"    exit 1fi# Define download URL and binary nameBINARY_NAME="dify-plugin-$OS-$ARCH"DOWNLOAD_URL="https://github.com/langgenius/dify-plugin-daemon/releases/download/$VERSION/$BINARY_NAME"# Set installation directory based on OSif [ "$OS" = "darwin" ]; then    INSTALL_DIR="$HOME/.local/bin"    mkdir -p "$INSTALL_DIR"    NEED_SUDO=falseelse    INSTALL_DIR="/usr/local/bin"    # Check if we have write permission to /usr/local/bin    if [ -w "$INSTALL_DIR" ]; then        NEED_SUDO=false    else        NEED_SUDO=true    fifi# Create temporary directory for downloadTMP_DIR=$(mktemp -d)cd "$TMP_DIR" || exit 1# Download the binaryecho "Downloading $BINARY_NAME..."if command -v curl >/dev/null 2>&1; then    curl -L -o "dify-plugin-daemon" "$DOWNLOAD_URL"elif command -v wget >/dev/null 2>&1; then    wget -O "dify-plugin-daemon" "$DOWNLOAD_URL"else    echo "Error: Neither curl nor wget is installed"    rm -rf "$TMP_DIR"    exit 1fi# Make binary executablechmod +x "dify-plugin-daemon"# Install the binary with the new nameif [ "$NEED_SUDO" = true ]; then    echo "Installing to $INSTALL_DIR (requires sudo)..."    sudo mv "dify-plugin-daemon" "$INSTALL_DIR/dify-plugin"else    echo "Installing to $INSTALL_DIR..."    mv "dify-plugin-daemon" "$INSTALL_DIR/dify-plugin"fi# Clean uprm -rf "$TMP_DIR"# For macOS, ensure ~/.local/bin is in PATHif [ "$OS" = "darwin" ]; then    if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then        SHELL_CONFIG=""        if [ -f "$HOME/.zshrc" ]; then            SHELL_CONFIG="$HOME/.zshrc"        elif [ -f "$HOME/.bashrc" ]; then            SHELL_CONFIG="$HOME/.bashrc"        elif [ -f "$HOME/.bash_profile" ]; then            SHELL_CONFIG="$HOME/.bash_profile"        fi        if [ -n "$SHELL_CONFIG" ]; then            echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$SHELL_CONFIG"            echo "Added $INSTALL_DIR to PATH in $SHELL_CONFIG"            echo "Please run: source $SHELL_CONFIG"        else            echo "Please add the following line to your shell configuration file:"            echo "export PATH=\"\$PATH:$INSTALL_DIR\""        fi    fifiecho "Installation completed! The dify plugin daemon has been installed to $INSTALL_DIR/dify-plugin" 
 |