Skip to content

Conversation

@zhende1113
Copy link

@zhende1113 zhende1113 commented Oct 27, 2025

维护人员 您好
我为您的项目提供了部署脚本
该脚本是使用纯shell写的 包括以下几个部署流程
定义全局变量
检查sudo和是否是root用户
检测软件包管理器
选择GitHub克隆源
安装依赖
使用我维护的脚本安装uv支持GitHub代理
克隆项目
同步依赖
复制配置文件
下载启动脚本初始化
打印部署完成的输出脚本结束
启动脚本使用screen会话管理使用简单 支持很多Linux发行版 除(termux安装proot容器外 因为proot的环境太特殊了导致mofox后台启动后 找不到screen会话 这个是没有办法的 安卓的环境太特殊了)
提供简单的菜单 前台后台启动 停止附加screen会话 更新mofox使用git pull和同步uv依赖 退出脚本
该脚本已经过测试
archlinux-20251025-testlog.txt

ubuntu-20251025-testlog.txt

测试均正常 代码透明 无恶意代码
我会给脚本提供提供维护更新
望通过谢谢
使用命令您可以使用

bash <(curl -sSL https://raw.githubusercontent.com/Astriora/Antlia/refs/heads/main/Script/MoFox-Studio/MoFox-install.sh)

来使用这个脚本
您可以把脚本的raw链接修改为您的仓库的链接
期待您的反馈,谢谢!

Summary by Sourcery

Automate MoFox_Bot deployment and lifecycle management using pure shell scripts with cross-distro support and GitHub proxy selection.

New Features:

  • Add MoFox-install.sh to automate environment detection, dependency installation, repository cloning, and configuration for MoFox_Bot across multiple Linux distributions
  • Add mofox CLI script to ~/.local/bin with a global symlink for easy management (start, stop, update) of the bot via screen sessions

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 27, 2025

Reviewer's Guide

Introduces a pure-shell MoFox deployment workflow by adding a comprehensive installer script that handles environment detection, dependency management, cloning, configuration, and setup of a CLI launcher.

Sequence diagram for MoFox deployment workflow

sequenceDiagram
    actor User
    participant Script
    participant System
    participant GitHub
    User->>Script: Run MoFox-install.sh
    Script->>System: Check root/sudo, detect OS & package manager
    Script->>User: Prompt for GitHub proxy selection
    User->>Script: Select proxy
    Script->>System: Install dependencies (git, python3, screen, etc.)
    Script->>GitHub: Download uv installer script
    Script->>System: Install uv
    Script->>GitHub: Clone MoFox_Bot repository
    Script->>System: Install Python dependencies via uv
    Script->>GitHub: Download CLI launcher (mofox)
    Script->>System: Configure launcher and write path.conf
    Script->>User: Print completion message and usage instructions
    User->>System: Edit config files and launch MoFox
Loading

Class diagram for main shell script functions and responsibilities

classDiagram
    class MoFoxInstallScript {
      +get_script_dir()
      +command_exists(cmd)
      +info(msg)
      +ok(msg)
      +warn(msg)
      +err(msg)
      +print_title(title)
      +download_with_retry(url, output)
      +select_github_proxy()
      +check_sudo()
      +detect_system()
      +detect_package_manager()
      +install_package(package)
      +install_system_dependencies()
      +install_uv_environment()
      +clone_MoFox_Bot()
      +install_python_dependencies()
      +download_script()
      +show_text()
      +main()
    }
    MoFoxInstallScript : manages deployment workflow
    MoFoxInstallScript : handles user interaction, environment detection, dependency installation, project setup, and finalization
Loading

File-Level Changes

Change Details Files
Add MoFox-install.sh to orchestrate the full deployment process
  • Initialize global variables and validate the deployment directory
  • Define colored logging and helper functions (download retries, directory detection)
  • Implement GitHub proxy selection and user prompts
  • Detect OS, architecture, sudo availability, and package manager
  • Install system dependencies and Python prerequisites across distros
  • Set up uv environment and export paths
  • Clone MoFox_Bot repo, sync Python deps, and copy config templates
  • Download and install the mofox startup script, create symlink, write path.conf
  • Print final user guidance and launch instructions
MoFox-install.sh
Add mofox launcher script for screen-session management
  • Introduce a standalone CLI entrypoint script for starting/stopping/attaching the bot
  • Place script in ~/.local/bin and symlink under /usr/local/bin for global use
  • Integrate simple menu for process control and updates
mofox

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider adding a non-interactive/unattended flag or environment variables to bypass the interactive prompts (select and read) for automated or CI-driven deployments.
  • Wrap all variable expansions (especially when concatenating URLs or file paths, e.g. "$GITHUB_PROXY" plus path) in quotes to avoid word-splitting or globbing issues.
  • The script is quite monolithic—splitting it into smaller, focused scripts or sourced modules (e.g. system detection, dependency installation, cloning) would improve readability and maintainability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a non-interactive/unattended flag or environment variables to bypass the interactive prompts (select and read) for automated or CI-driven deployments.
- Wrap all variable expansions (especially when concatenating URLs or file paths, e.g. "$GITHUB_PROXY" plus path) in quotes to avoid word-splitting or globbing issues.
- The script is quite monolithic—splitting it into smaller, focused scripts or sourced modules (e.g. system detection, dependency installation, cloning) would improve readability and maintainability.

## Individual Comments

### Comment 1
<location> `MoFox-install.sh:264-265` </location>
<code_context>
+    apk)
+        $SUDO apk add gcc musl-dev linux-headers "$package" #安装包
+        ;;
+    brew)
+        $SUDO install "$package" #安装包
+        ;;
+    *)
</code_context>

<issue_to_address>
**issue (bug_risk):** The Homebrew install command is incorrect.

Replace `$SUDO install "$package"` with `$SUDO brew install "$package"` to ensure proper installation via Homebrew and avoid failures.
</issue_to_address>

### Comment 2
<location> `MoFox-install.sh:459-460` </location>
<code_context>
+    ok "mofox 脚本已下载到 $TARGET_FILE"
+
+    # 软链到 /usr/local/bin 方便全局调用
+    $SUDO ln -sf "$TARGET_FILE" /usr/local/bin/mofox
+
+    # 直接写 path.conf 到用户目录,不用初始化
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Symlinking to /usr/local/bin may fail without sufficient permissions.

Check for write access to /usr/local/bin before creating the symlink, and provide a fallback to ~/.local/bin if permissions are insufficient.

```suggestion
    # 检查 /usr/local/bin 是否可写,否则软链到 ~/.local/bin
    if [ -w /usr/local/bin ] || [ "$(id -u)" -eq 0 ]; then
        $SUDO ln -sf "$TARGET_FILE" /usr/local/bin/mofox
        ok "已创建软链到 /usr/local/bin/mofox"
    else
        # fallback to ~/.local/bin
        local LOCAL_BIN_DIR="$HOME/.local/bin"
        mkdir -p "$LOCAL_BIN_DIR"
        ln -sf "$TARGET_FILE" "$LOCAL_BIN_DIR/mofox"
        ok "无权限写入 /usr/local/bin,已创建软链到 $LOCAL_BIN_DIR/mofox"
        ok "请确保 $LOCAL_BIN_DIR 已加入 PATH"
    fi
```
</issue_to_address>

### Comment 3
<location> `MoFox-install.sh:393` </location>
<code_context>
+    # 配置 uv 镜像源
+    export UV_INDEX_URL="https://mirrors.ustc.edu.cn/pypi/simple/"
+    mkdir -p ~/.cache/uv
+    chown -R "$(whoami):$(whoami)" ~/.cache/uv
+
+    # 安装 MoFox_Bot 依赖
</code_context>

<issue_to_address>
**suggestion:** Using chown with $(whoami):$(whoami) may not work on all systems.

Some systems lack a group matching the username, which can cause chown to fail. Use `$(id -u):$(id -g)` or handle chown errors appropriately.

```suggestion
    chown -R "$(id -u):$(id -g)" ~/.cache/uv || warn "chown ~/.cache/uv 失败, 请检查权限"
```
</issue_to_address>

### Comment 4
<location> `MoFox-install.sh:439-440` </location>
<code_context>
+        warn "未找到 template/model_config_template.toml"
+    fi
+
+    if [[ -f "template/bot_config_template.toml" ]]; then
+        cp "template/bot_config_template.toml" "config/bot_config.toml"
+        ok "已复制 bot_config_template.toml"
+    else
</code_context>

<issue_to_address>
**suggestion:** The copied config file name does not match the referenced file in the completion message.

The instructions should reference 'bot_config.toml' instead of 'bot_config_template.toml' to avoid user confusion.

```suggestion
        cp "template/bot_config_template.toml" "config/bot_config.toml"
        ok "已复制 bot_config.toml"
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

zhende1113 and others added 4 commits October 27, 2025 21:03
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@minecraft1024a
Copy link
Contributor

其实我建议是把自己的脚本放在独立仓库
然后再写一篇文档pr到文档仓库

一件包目前只维护Windows端,
不过还是谢谢PR喵
顺带一提你把我们项目名字写错了,是MoFox不是FoMox

@minecraft1024a
Copy link
Contributor

onekey-plus仓库我们都不常看,导致我现在才看到

@minecraft1024a minecraft1024a changed the title 添加FoMox部署 添加MoFox Liunx部署脚本 Nov 11, 2025
@zhende1113
Copy link
Author

onekey-plus仓库我们都不常看,导致我现在才看到

好的 我这个周六日就更新一次(添加一些参数支持和优化代码质量) 以后我会2个星期保底维护一次的 因为我只是一名学生(最近在准备期中考试现在考完了) 脚本本身就是在独立的仓库里面https://github.com/Astriora/Antlia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants