# host-redroid **Repository Path**: cyberant/host-redroid ## Basic Information - **Project Name**: host-redroid - **Description**: 使用redroid docker技术搭建虚拟机 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-21 - **Last Updated**: 2026-03-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Cloud-Control ReDroid 镜像与主机配置 ## 项目结构 ``` host-redroid/ ├── Dockerfile # ReDroid云控专用镜像构建文件 ├── docker-compose.yml # Docker Compose配置(包含云控服务) ├── scripts/ │ ├── container-init.sh # 容器启动初始化脚本 │ ├── node-agent.py # NodeAgent主机代理 │ ├── install-node-agent.sh # NodeAgent安装脚本 │ ├── node-agent.service # Systemd服务配置 │ ├── requirements.txt # Python依赖 │ ├── .env.example # 环境变量示例 │ └── install.sh # Ubuntu 22.04批量装机脚本 └── README.md # 本文档 ``` ## 功能说明 ### 1. ReDroid云控专用镜像 基于官方 `redroid/redroid:14.0.0_latest` 镜像构建,预装以下组件: - **Magisk (Zygisk模式)**: v27.0 - **LSPosed**: v1.9.2 - **必备LSPosed模块**: - DeviceInfo Spoof (机型伪装) - Fake Location (定位模拟) - SSL Unpinning (SSL Pinning绕过) - Proxy Forwarder (代理转发) ### 2. NodeAgent主机代理 Python编写的轻量级代理程序,功能包括: - 主机自动注册 - 定期心跳上报(CPU、内存、磁盘使用率) - 接收并执行云控命令(创建/启动/停止/删除实例) - **scrcpy视频流转发**(实时投屏支持) - 截屏功能 - ADB命令执行 - 断线自动重连 - **Systemd服务化运行**(开机自启、崩溃重启) ### 3. Ubuntu 22.04批量装机脚本 一键安装脚本,自动完成: - Docker CE安装 - NVIDIA Container Toolkit安装(自动检测GPU) - Docker镜像加速配置 - ReDroid镜像拉取 - 云控专用镜像构建 - NodeAgent安装 - 防火墙规则配置 ## 使用说明 ### 在新主机上安装NodeAgent NodeAgent提供两种安装方式: #### 方式1:使用安装脚本(推荐) ```bash cd /opt wget https://your-server/scripts/install-node-agent.sh chmod +x install-node-agent.sh sudo ./install-node-agent.sh ``` 安装完成后,编辑配置文件: ```bash vi /opt/node-agent/.env ``` 修改 `CLOUD_SERVER_URL` 为您的云控服务器地址: ```bash CLOUD_SERVER_URL=http://your-cloud-server:3000 ``` 启动服务: ```bash systemctl start node-agent systemctl enable node-agent ``` #### 方式2:手动安装 ```bash # 创建安装目录 mkdir -p /opt/node-agent cd /opt/node-agent # 复制脚本文件 cp node-agent.py . chmod +x node-agent.py # 安装Python依赖 pip3 install -r requirements.txt # 复制并编辑配置文件 cp .env.example .env vi .env # 修改CLOUD_SERVER_URL # 安装systemd服务 cp node-agent.service /etc/systemd/system/ systemctl daemon-reload systemctl start node-agent systemctl enable node-agent ``` 1. 下载安装脚本: ```bash wget https://your-server/install.sh chmod +x install.sh ``` 2. 设置云控服务器地址(可选): ```bash export CLOUD_SERVER_URL=http://your-cloud-server:3000 ``` 3. 执行安装: ```bash sudo ./install.sh ``` ### 构建ReDroid云控镜像 在安装了Docker的主机上: ```bash cd /path/to/host-redroid docker build -t redevice-cloud:latest . ``` ### 使用Docker Compose启动云控服务 ```bash cd /path/to/host-redroid docker-compose up -d ``` 服务将启动: - 云控后端服务: http://localhost:3000 - MySQL数据库: localhost:3306 - Redis缓存: localhost:6379 ### 创建ReDroid实例 手动创建(示例): ```bash docker run -d \ --name my-emu-1 \ --privileged \ -p 5555:5555 \ -p 5901:5900 \ -e DEVICE_MODEL=SM-S928B \ -e RESOLUTION=1440x3120 \ -e DNS_SERVERS=8.8.8.8,8.8.4.4 \ redevice-cloud:latest ``` 通过云控Web界面创建实例,后端将自动下发创建命令到NodeAgent。 ### 连接ADB ```bash adb connect localhost:5555 adb shell ``` ### 连接VNC 使用VNC客户端连接: - 地址: `<主机IP>:5901` - 密码: redroid ## 环境变量 ### Docker容器环境变量 | 变量 | 说明 | 默认值 | |------|------|--------| | DEVICE_MODEL | 机型型号 | SM-S928B | | DEVICE_BRAND | 设备品牌 | Samsung | | DEVICE_MANUFACTURER | 设备厂商 | samsung | | RESOLUTION | 屏幕分辨率 | 1440x3120 | | DENSITY | 屏幕密度 | 560 | | ANDROID_VERSION | Android版本 | 14 | | DNS_SERVERS | DNS服务器 | 8.8.8.8,8.8.4.4 | | PROXY_IP | 代理IP地址 | - | | PROXY_PORT | 代理端口 | - | | INSTALL_AUTOJS | 是否安装AutoJS6 | false | ### NodeAgent环境变量 | 变量 | 说明 | 默认值 | |------|------|--------| | CLOUD_SERVER_URL | 云控服务器地址 | http://localhost:3000 | | HOST_NAME | 主机名称 | 系统主机名 | | REGISTER_TOKEN | 注册Token | - | | HEARTBEAT_INTERVAL | 心跳间隔(秒) | 30 | | RETRY_INTERVAL | 重试间隔(秒) | 10 | ### scrcpy视频流 NodeAgent支持scrcpy视频流转发,用于实时投屏功能: 1. **启动scrcpy-server**:收到云控命令后,在容器中启动scrcpy-server 2. **视频流转发**:通过WebSocket将视频帧转发到云控服务器 3. **控制命令**:接收并转发触摸、滑动、按键等控制命令到容器 视频流使用独立WebSocket端口(默认27180),与主服务端口分离,提高稳定性。 ## 支持的机型 预置机型配置: - 三星 S24 Ultra (SM-S928B) - 三星 S23 Ultra (SM-S918B) - 三星 S22 Ultra (SM-S908B) - Pixel 7 Pro (cheetah) - Pixel 6 Pro (raven) - 小米 14 Ultra (23090RA98C) - 小米 13 Ultra (2304FPN6DC) - 华为 Mate 60 Pro (ALN-AL00) - OPPO Find X7 (PHJ110) - VIVO X100 Pro (V2309A) ## 常见问题 ### 1. NodeAgent无法连接云控服务器 检查: - CLOUD_SERVER_URL配置是否正确 - 防火墙是否允许3000端口 - 网络是否通 ### 2. ReDroid容器无法启动 检查: - Docker是否正常运行:`systemctl status docker` - 是否安装了NVIDIA Container Toolkit(如果主机有GPU) - 容器日志:`docker logs ` ### 3. ADB连接失败 检查: - 端口是否正确映射:`-p 5555:5555` - 容器是否已启动 - 等待容器完全启动(约30-60秒) ### 4. 心跳上报失败 检查: - REGISTER_TOKEN是否有效 - 主机在云控系统中状态是否为"在线" ### 5. scrcpy视频流无法连接 检查: - scrcpy-server是否已启动:`docker exec ps aux | grep scrcpy` - WebSocket端口27180是否开放:`ss -tlnp | grep 27180` - /dev/video0是否存在(v4l2模式):`docker exec ls /dev/video0` - 容器是否有足够权限:`docker inspect | grep Privileged` - socat是否安装:`which socat` ## 服务管理 ### 查看NodeAgent日志 ```bash # Systemd日志 journalctl -u node-agent -f # 或查看日志文件 tail -f /var/log/node-agent.log ``` ### 查看NodeAgent状态 ```bash systemctl status node-agent ``` ### 重启NodeAgent ```bash systemctl restart node-agent ``` ### 停止NodeAgent ```bash systemctl stop node-agent ``` ### 开机自启管理 ```bash # 启用开机自启 systemctl enable node-agent # 禁用开机自启 systemctl disable node-agent ``` ## 监控与运维 ### NodeAgent健康检查 ```bash # 检查服务状态 systemctl is-active node-agent && echo "运行中" || echo "已停止" # 检查最近心跳 journalctl -u node-agent --since "10 minutes ago" | grep "心跳" # 检查错误日志 journalctl -u node-agent --since "1 hour ago" | grep -i error ``` ### 资源使用监控 NodeAgent会定期上报主机的CPU、内存、磁盘使用率。在云控管理界面可以查看: - 主机在线状态 - 资源使用趋势 - 容器运行情况 - scrcpy连接状态 ### 日志轮转 配置日志轮转防止日志文件过大: ```bash cat > /etc/logrotate.d/node-agent << EOF /var/log/node-agent.log { daily rotate 7 compress missingok notifempty create 0644 root root } EOF ``` ## 安全建议 1. 仅允许必要的端口访问 2. 使用强密码保护数据库 3. 定期更新系统和Docker镜像 4. 监控主机资源使用情况 5. 使用HTTPS协议连接云控服务器(生产环境) ## 许可证 本项目中使用的软件遵循各自的许可协议: - ReDroid: Apache 2.0 - Magisk: GPL v3 - LSPosed: GPL v3 - Node.js: MIT ## 贡献 欢迎提交Issue和Pull Request来改进本项目。 ## 联系方式 如有问题,请通过以下方式联系: - GitHub Issues - Email: support@cloud-control.com