更新包名
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
## Moltbot (原 ClawdBot) 一键安装与管理脚本
|
||||
## openclaw (原 ClawdBot) 一键安装与管理脚本
|
||||
|
||||
### linux 脚本
|
||||
```
|
||||
bash <(curl -sSL https://raw.githubusercontent.com/sky22333/shell/main/moltbot/install.sh)
|
||||
bash <(curl -sSL https://raw.githubusercontent.com/sky22333/shell/main/openclaw/install.sh)
|
||||
```
|
||||
|
||||
### windows 脚本
|
||||
直接下载使用编译好的二进制文件:https://github.com/sky22333/shell/raw/main/moltbot/installer/installer.exe
|
||||
直接下载使用编译好的二进制文件:https://github.com/sky22333/shell/raw/main/openclaw/installer/installer.exe
|
||||
|
||||
下载后使用管理员权限运行
|
||||
|
||||
@@ -17,7 +17,7 @@ set GIT_PROXY=https://g.blfrp.cn/
|
||||
installer.exe
|
||||
```
|
||||
|
||||
如果你选择跳过设置TG机器人,启动后可以访问ClawdBot内置的Web面板进行对话:`http://127.0.0.1:18789`
|
||||
如果你选择跳过设置TG机器人,启动后可以访问OpenClaw内置的Web面板进行对话:`http://127.0.0.1:18789`
|
||||
|
||||
### 构建(可选)
|
||||
如果你不放心预编译的二进制文件,可以自己构建。
|
||||
@@ -26,7 +26,7 @@ installer.exe
|
||||
|
||||
2:进入项目目录
|
||||
```
|
||||
cd moltbot/installer
|
||||
cd openclaw/installer
|
||||
```
|
||||
3:安装依赖
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Moltbot (原 ClawdBot) 一键安装与管理脚本
|
||||
# OpenClaw 一键安装与管理脚本
|
||||
# 兼容 Debian / Ubuntu
|
||||
# 官方文档: https://docs.molt.bot
|
||||
# 官方文档: https://docs.openclaw.app
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
@@ -13,10 +13,10 @@ CYAN='\033[0;36m'
|
||||
PLAIN='\033[0m'
|
||||
|
||||
# 配置文件路径
|
||||
# Moltbot 依然使用 .clawdbot 目录以保持兼容性
|
||||
CONFIG_DIR="${HOME}/.clawdbot"
|
||||
CONFIG_FILE="${CONFIG_DIR}/clawdbot.json"
|
||||
SERVICE_FILE="/etc/systemd/system/moltbot.service"
|
||||
# OpenClaw 使用 .openclaw 目录
|
||||
CONFIG_DIR="${HOME}/.openclaw"
|
||||
CONFIG_FILE="${CONFIG_DIR}/openclaw.json"
|
||||
SERVICE_FILE="/etc/systemd/system/openclaw.service"
|
||||
|
||||
check_root() {
|
||||
if [ $EUID -ne 0 ]; then
|
||||
@@ -62,10 +62,10 @@ install_nodejs() {
|
||||
log_info "Node.js 已安装且版本符合要求 (${NODE_VERSION_FULL}),无需重复安装。"
|
||||
return
|
||||
else
|
||||
log_warn "检测到旧版本 Node.js (${NODE_VERSION_FULL}),Moltbot 需要 Node.js 22+"
|
||||
log_warn "检测到旧版本 Node.js (${NODE_VERSION_FULL}),OpenClaw 需要 Node.js 22+"
|
||||
read -p "是否升级 Node.js 到 22.x?(这将覆盖现有版本) [y/n]: " upgrade_node
|
||||
if [ "$upgrade_node" != "y" ]; then
|
||||
log_error "已取消 Node.js 升级。Moltbot 可能无法正常运行。"
|
||||
log_error "已取消 Node.js 升级。OpenClaw 可能无法正常运行。"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -86,13 +86,13 @@ install_nodejs() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装 Moltbot
|
||||
install_moltbot_core() {
|
||||
log_info "正在安装 Moltbot..."
|
||||
# 安装 OpenClaw
|
||||
install_openclaw_core() {
|
||||
log_info "正在安装 OpenClaw..."
|
||||
|
||||
if command -v clawdbot >/dev/null 2>&1; then
|
||||
CURRENT_VERSION=$(clawdbot --version)
|
||||
log_warn "ClawdBot (Moltbot) 已安装 (版本: ${CURRENT_VERSION})"
|
||||
if command -v openclaw >/dev/null 2>&1; then
|
||||
CURRENT_VERSION=$(openclaw --version)
|
||||
log_warn "OpenClaw 已安装 (版本: ${CURRENT_VERSION})"
|
||||
read -p "是否强制重新安装/更新?[y/n]: " force_install
|
||||
if [ "$force_install" != "y" ]; then
|
||||
log_info "跳过安装步骤。"
|
||||
@@ -100,19 +100,19 @@ install_moltbot_core() {
|
||||
fi
|
||||
fi
|
||||
|
||||
npm install -g clawdbot@latest
|
||||
npm install -g openclaw@latest
|
||||
|
||||
if command -v clawdbot >/dev/null 2>&1; then
|
||||
VERSION=$(clawdbot --version)
|
||||
log_info "ClawdBot 安装成功,版本: ${VERSION}"
|
||||
if command -v openclaw >/dev/null 2>&1; then
|
||||
VERSION=$(openclaw --version)
|
||||
log_info "OpenClaw 安装成功,版本: ${VERSION}"
|
||||
else
|
||||
log_error "ClawdBot 安装失败,请检查 npm 权限或网络!"
|
||||
log_error "OpenClaw 安装失败,请检查 npm 权限或网络!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 配置 Moltbot
|
||||
configure_moltbot() {
|
||||
# 配置 OpenClaw
|
||||
configure_openclaw() {
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
log_warn "检测到已存在配置文件: ${CONFIG_FILE}"
|
||||
read -p "是否覆盖现有配置?[y/n]: " overwrite_config
|
||||
@@ -122,7 +122,7 @@ configure_moltbot() {
|
||||
fi
|
||||
fi
|
||||
|
||||
log_info "开始配置 Moltbot..."
|
||||
log_info "开始配置 OpenClaw..."
|
||||
|
||||
mkdir -p "${CONFIG_DIR}"
|
||||
|
||||
@@ -249,13 +249,13 @@ setup_systemd() {
|
||||
|
||||
cat > "${SERVICE_FILE}" <<EOF
|
||||
[Unit]
|
||||
Description=Moltbot Gateway
|
||||
Description=OpenClaw Gateway
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=$(command -v clawdbot) gateway --verbose
|
||||
ExecStart=$(command -v openclaw) gateway --verbose
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Environment=HOME=${HOME}
|
||||
@@ -265,8 +265,8 @@ WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable moltbot
|
||||
systemctl restart moltbot
|
||||
systemctl enable openclaw
|
||||
systemctl restart openclaw
|
||||
|
||||
log_info "服务已启动并设置开机自启!"
|
||||
}
|
||||
@@ -276,46 +276,47 @@ install() {
|
||||
check_root
|
||||
check_sys
|
||||
install_nodejs
|
||||
install_moltbot_core
|
||||
configure_moltbot
|
||||
install_openclaw_core
|
||||
configure_openclaw
|
||||
setup_systemd
|
||||
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
echo -e "${GREEN} Moltbot 安装配置完成!${PLAIN}"
|
||||
echo -e "${GREEN} OpenClaw 安装配置完成!${PLAIN}"
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
echo -e "请等待Moltbot初始化完成(约1分钟),然后使用Telegram向您的Bot发送消息开始使用。"
|
||||
echo -e "请等待OpenClaw初始化完成(约1分钟),然后使用Telegram向您的Bot发送消息开始使用。"
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
}
|
||||
|
||||
# 卸载流程
|
||||
uninstall() {
|
||||
check_root
|
||||
read -p "确定要卸载 Moltbot 吗?配置文件也将被删除 [y/n]: " confirm
|
||||
read -p "确定要卸载 OpenClaw 吗?配置文件也将被删除 [y/n]: " confirm
|
||||
if [ "$confirm" != "y" ]; then
|
||||
echo "已取消。"
|
||||
return
|
||||
fi
|
||||
|
||||
systemctl stop moltbot
|
||||
systemctl disable moltbot
|
||||
systemctl stop openclaw
|
||||
systemctl disable openclaw
|
||||
rm -f "${SERVICE_FILE}"
|
||||
systemctl daemon-reload
|
||||
|
||||
npm uninstall -g clawdbot
|
||||
npm uninstall -g openclaw
|
||||
npm uninstall -g moltbot # 尝试卸载旧包
|
||||
npm uninstall -g clawdbot # 尝试卸载旧包
|
||||
rm -rf "${CONFIG_DIR}"
|
||||
|
||||
log_info "Moltbot (ClawdBot) 已卸载。"
|
||||
log_info "OpenClaw 已卸载。"
|
||||
}
|
||||
|
||||
# 修改配置 (重新运行配置向导)
|
||||
modify_config() {
|
||||
echo -e "${YELLOW}注意:此操作将重新生成配置文件,并且重启服务。${PLAIN}"
|
||||
configure_moltbot
|
||||
configure_openclaw
|
||||
log_info "正在重启服务以应用更改..."
|
||||
systemctl restart moltbot
|
||||
systemctl restart openclaw
|
||||
sleep 1
|
||||
if systemctl is-active --quiet moltbot; then
|
||||
if systemctl is-active --quiet openclaw; then
|
||||
log_info "服务已重启并正常运行。"
|
||||
else
|
||||
log_error "服务启动失败!请查看日志。"
|
||||
@@ -325,16 +326,16 @@ modify_config() {
|
||||
# 菜单
|
||||
show_menu() {
|
||||
clear
|
||||
echo -e "${CYAN}Moltbot(Clawdbot)管理脚本${PLAIN}"
|
||||
echo -e "${CYAN}OpenClaw 管理脚本${PLAIN}"
|
||||
echo -e "${CYAN}------------------------${PLAIN}"
|
||||
echo -e "1. 安装并配置 Moltbot"
|
||||
echo -e "1. 安装并配置 OpenClaw"
|
||||
echo -e "2. 启动服务"
|
||||
echo -e "3. 停止服务"
|
||||
echo -e "4. 重启服务"
|
||||
echo -e "5. 查看运行状态"
|
||||
echo -e "6. 查看实时日志"
|
||||
echo -e "7. 修改配置文件"
|
||||
echo -e "8. 卸载 Moltbot"
|
||||
echo -e "8. 卸载 OpenClaw"
|
||||
echo -e "9. 运行doctor自检"
|
||||
echo -e "0. 退出脚本"
|
||||
echo -e "${CYAN}------------------------${PLAIN}"
|
||||
@@ -342,14 +343,14 @@ show_menu() {
|
||||
|
||||
case "$choice" in
|
||||
1) install ;;
|
||||
2) systemctl start moltbot && log_info "服务已启动" ;;
|
||||
3) systemctl stop moltbot && log_info "服务已停止" ;;
|
||||
4) systemctl restart moltbot && log_info "服务已重启" ;;
|
||||
5) systemctl status moltbot ;;
|
||||
6) journalctl -u moltbot -f ;;
|
||||
2) systemctl start openclaw && log_info "服务已启动" ;;
|
||||
3) systemctl stop openclaw && log_info "服务已停止" ;;
|
||||
4) systemctl restart openclaw && log_info "服务已重启" ;;
|
||||
5) systemctl status openclaw ;;
|
||||
6) journalctl -u openclaw -f ;;
|
||||
7) modify_config ;;
|
||||
8) uninstall ;;
|
||||
9) clawdbot doctor ;;
|
||||
9) openclaw doctor ;;
|
||||
0) exit 0 ;;
|
||||
*) echo -e "${RED}无效选项,请重新输入${PLAIN}" ;;
|
||||
esac
|
||||
@@ -7,11 +7,11 @@ BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
PLAIN='\033[0m'
|
||||
|
||||
CONFIG_DIR="${HOME}/.clawdbot"
|
||||
CONFIG_FILE="${CONFIG_DIR}/clawdbot.json"
|
||||
PLIST_LABEL="com.moltbot.gateway"
|
||||
CONFIG_DIR="${HOME}/.openclaw"
|
||||
CONFIG_FILE="${CONFIG_DIR}/openclaw.json"
|
||||
PLIST_LABEL="com.openclaw.gateway"
|
||||
PLIST_PATH="${HOME}/Library/LaunchAgents/${PLIST_LABEL}.plist"
|
||||
LOG_DIR="${HOME}/Library/Logs/moltbot"
|
||||
LOG_DIR="${HOME}/Library/Logs/openclaw"
|
||||
LOG_FILE="${LOG_DIR}/gateway.log"
|
||||
ERR_FILE="${LOG_DIR}/gateway.error.log"
|
||||
|
||||
@@ -98,28 +98,28 @@ install_git() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_moltbot_core() {
|
||||
log_info "正在安装 Moltbot..."
|
||||
if command -v clawdbot >/dev/null 2>&1; then
|
||||
CURRENT_VERSION=$(clawdbot --version)
|
||||
log_warn "ClawdBot (Moltbot) 已安装 (版本: ${CURRENT_VERSION})"
|
||||
install_openclaw_core() {
|
||||
log_info "正在安装 OpenClaw..."
|
||||
if command -v openclaw >/dev/null 2>&1; then
|
||||
CURRENT_VERSION=$(openclaw --version)
|
||||
log_warn "OpenClaw 已安装 (版本: ${CURRENT_VERSION})"
|
||||
read -p "是否强制重新安装/更新?[y/n]: " force_install
|
||||
if [ "$force_install" != "y" ]; then
|
||||
log_info "跳过安装步骤。"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
npm install -g clawdbot@latest
|
||||
if command -v clawdbot >/dev/null 2>&1; then
|
||||
VERSION=$(clawdbot --version)
|
||||
log_info "ClawdBot 安装成功,版本: ${VERSION}"
|
||||
npm install -g openclaw@latest
|
||||
if command -v openclaw >/dev/null 2>&1; then
|
||||
VERSION=$(openclaw --version)
|
||||
log_info "OpenClaw 安装成功,版本: ${VERSION}"
|
||||
else
|
||||
log_error "ClawdBot 安装失败,请检查 npm 权限或网络。"
|
||||
log_error "OpenClaw 安装失败,请检查 npm 权限或网络。"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
configure_moltbot() {
|
||||
configure_openclaw() {
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
log_warn "检测到已存在配置文件: ${CONFIG_FILE}"
|
||||
read -p "是否覆盖现有配置?[y/n]: " overwrite_config
|
||||
@@ -128,7 +128,7 @@ configure_moltbot() {
|
||||
return
|
||||
fi
|
||||
fi
|
||||
log_info "开始配置 Moltbot..."
|
||||
log_info "开始配置 OpenClaw..."
|
||||
mkdir -p "${CONFIG_DIR}"
|
||||
echo -e "${CYAN}请选择 API 类型:${PLAIN}"
|
||||
echo "1. Anthropic 官方 API"
|
||||
@@ -342,9 +342,9 @@ setup_launchd() {
|
||||
log_info "正在配置 LaunchAgent 服务..."
|
||||
mkdir -p "$(dirname "${PLIST_PATH}")"
|
||||
mkdir -p "${LOG_DIR}"
|
||||
GATEWAY_BIN=$(command -v clawdbot)
|
||||
GATEWAY_BIN=$(command -v openclaw)
|
||||
if [ -z "${GATEWAY_BIN}" ]; then
|
||||
log_error "未找到 clawdbot 可执行文件。"
|
||||
log_error "未找到 openclaw 可执行文件。"
|
||||
exit 1
|
||||
fi
|
||||
NODE_BIN=$(command -v node)
|
||||
@@ -424,50 +424,51 @@ install() {
|
||||
check_macos
|
||||
install_git
|
||||
install_nodejs
|
||||
install_moltbot_core
|
||||
configure_moltbot
|
||||
install_openclaw_core
|
||||
configure_openclaw
|
||||
setup_launchd
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
echo -e "${GREEN} Moltbot 安装配置完成!${PLAIN}"
|
||||
echo -e "${GREEN} OpenClaw 安装配置完成!${PLAIN}"
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
echo -e "请等待Moltbot初始化完成(约1分钟),然后使用Telegram向您的Bot发送消息开始使用。"
|
||||
echo -e "请等待OpenClaw初始化完成(约1分钟),然后使用Telegram向您的Bot发送消息开始使用。"
|
||||
echo -e "${GREEN}=============================================${PLAIN}"
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
check_macos
|
||||
read -p "确定要卸载 Moltbot 吗?配置文件也将被删除 [y/n]: " confirm
|
||||
read -p "确定要卸载 OpenClaw 吗?配置文件也将被删除 [y/n]: " confirm
|
||||
if [ "$confirm" != "y" ]; then
|
||||
echo "已取消。"
|
||||
return
|
||||
fi
|
||||
service_stop
|
||||
rm -f "${PLIST_PATH}"
|
||||
npm uninstall -g openclaw
|
||||
npm uninstall -g clawdbot
|
||||
npm uninstall -g moltbot
|
||||
rm -rf "${CONFIG_DIR}"
|
||||
log_info "Moltbot (ClawdBot) 已卸载。"
|
||||
log_info "OpenClaw 已卸载。"
|
||||
}
|
||||
|
||||
modify_config() {
|
||||
echo -e "${YELLOW}注意:此操作将重新生成配置文件,并且重启服务。${PLAIN}"
|
||||
configure_moltbot
|
||||
configure_openclaw
|
||||
log_info "正在重启服务以应用更改..."
|
||||
service_restart
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
clear
|
||||
echo -e "${CYAN}Moltbot(Clawdbot)管理脚本${PLAIN}"
|
||||
echo -e "${CYAN}OpenClaw 管理脚本${PLAIN}"
|
||||
echo -e "${CYAN}------------------------${PLAIN}"
|
||||
echo -e "1. 安装并配置 Moltbot"
|
||||
echo -e "1. 安装并配置 OpenClaw"
|
||||
echo -e "2. 启动服务"
|
||||
echo -e "3. 停止服务"
|
||||
echo -e "4. 重启服务"
|
||||
echo -e "5. 查看运行状态"
|
||||
echo -e "6. 查看实时日志"
|
||||
echo -e "7. 修改配置文件"
|
||||
echo -e "8. 卸载 Moltbot"
|
||||
echo -e "8. 卸载 OpenClaw"
|
||||
echo -e "9. 运行doctor自检"
|
||||
echo -e "0. 退出脚本"
|
||||
echo -e "${CYAN}------------------------${PLAIN}"
|
||||
@@ -481,7 +482,7 @@ show_menu() {
|
||||
6) service_logs ;;
|
||||
7) modify_config ;;
|
||||
8) uninstall ;;
|
||||
9) clawdbot doctor ;;
|
||||
9) openclaw doctor ;;
|
||||
0) exit 0 ;;
|
||||
*) echo -e "${RED}无效选项,请重新输入${PLAIN}" ;;
|
||||
esac
|
||||
@@ -1,4 +1,4 @@
|
||||
module moltbot-installer
|
||||
module openclaw-installer
|
||||
|
||||
go 1.25.1
|
||||
|
||||
Binary file not shown.
@@ -56,8 +56,8 @@ const nodeMsiSHA256 = "1a5f0cd914386f3be2fbaf03ad9fff808a588ce50d2e155f338fad553
|
||||
// SHA256 来源 https://github.com/git-for-windows/git/releases/tag/v2.52.0.windows.1
|
||||
const gitExeSHA256 = "d8de7a3152266c8bb13577eab850ea1df6dccf8c2aa48be5b4a1c58b7190d62c"
|
||||
|
||||
// MoltbotConfig 配置结构
|
||||
type MoltbotConfig struct {
|
||||
// OpenclawConfig 配置结构
|
||||
type OpenclawConfig struct {
|
||||
Gateway GatewayConfig `json:"gateway"`
|
||||
Env map[string]string `json:"env,omitempty"`
|
||||
Agents AgentsConfig `json:"agents"`
|
||||
@@ -137,8 +137,12 @@ type TelegramConfig struct {
|
||||
AllowFrom []string `json:"allowFrom"`
|
||||
}
|
||||
|
||||
// GetMoltbotPath 获取执行路径
|
||||
func GetMoltbotPath() (string, error) {
|
||||
// GetOpenclawPath 获取执行路径
|
||||
func GetOpenclawPath() (string, error) {
|
||||
if path, err := exec.LookPath("openclaw"); err == nil {
|
||||
return path, nil
|
||||
}
|
||||
// Legacy fallback
|
||||
if path, err := exec.LookPath("clawdbot"); err == nil {
|
||||
return path, nil
|
||||
}
|
||||
@@ -151,17 +155,18 @@ func GetMoltbotPath() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
possibleClawd := filepath.Join(npmPrefix, "clawdbot.cmd")
|
||||
possibleClawd := filepath.Join(npmPrefix, "openclaw.cmd")
|
||||
if _, err := os.Stat(possibleClawd); err == nil {
|
||||
return possibleClawd, nil
|
||||
}
|
||||
|
||||
// Legacy checks
|
||||
possibleMolt := filepath.Join(npmPrefix, "moltbot.cmd")
|
||||
if _, err := os.Stat(possibleMolt); err == nil {
|
||||
return possibleMolt, nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("未找到 moltbot 或 clawdbot 可执行文件")
|
||||
return "", fmt.Errorf("未找到 openclaw 可执行文件")
|
||||
}
|
||||
|
||||
// GetNodePath 获取 Node 路径
|
||||
@@ -258,11 +263,11 @@ func SetupGitEnv() error {
|
||||
return os.Setenv("PATH", newPath)
|
||||
}
|
||||
|
||||
// CheckMoltbot 检查安装状态
|
||||
func CheckMoltbot() (string, bool) {
|
||||
// CheckOpenclaw 检查安装状态
|
||||
func CheckOpenclaw() (string, bool) {
|
||||
SetupNodeEnv()
|
||||
|
||||
cmdName, err := GetMoltbotPath()
|
||||
cmdName, err := GetOpenclawPath()
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
@@ -812,11 +817,11 @@ func InstallGit() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallMoltbotNpm 安装包
|
||||
func InstallMoltbotNpm(tag string) error {
|
||||
// InstallOpenclawNpm 安装包
|
||||
func InstallOpenclawNpm(tag string) error {
|
||||
SetupNodeEnv()
|
||||
|
||||
pkgName := "clawdbot"
|
||||
pkgName := "openclaw"
|
||||
if tag == "" || tag == "beta" {
|
||||
tag = "latest"
|
||||
}
|
||||
@@ -843,10 +848,10 @@ func InstallMoltbotNpm(tag string) error {
|
||||
|
||||
// EnsureOnPath 检查并配置 PATH
|
||||
func EnsureOnPath() (bool, error) {
|
||||
if _, err := exec.LookPath("clawdbot"); err == nil {
|
||||
if _, err := exec.LookPath("openclaw"); err == nil {
|
||||
return false, nil
|
||||
}
|
||||
if _, err := exec.LookPath("moltbot"); err == nil {
|
||||
if _, err := exec.LookPath("clawdbot"); err == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -858,8 +863,8 @@ func EnsureOnPath() (bool, error) {
|
||||
|
||||
possiblePath := npmPrefix
|
||||
|
||||
if _, err := os.Stat(filepath.Join(npmPrefix, "clawdbot.cmd")); os.IsNotExist(err) {
|
||||
if _, err := os.Stat(filepath.Join(npmPrefix, "moltbot.cmd")); os.IsNotExist(err) {
|
||||
if _, err := os.Stat(filepath.Join(npmPrefix, "openclaw.cmd")); os.IsNotExist(err) {
|
||||
if _, err := os.Stat(filepath.Join(npmPrefix, "clawdbot.cmd")); os.IsNotExist(err) {
|
||||
possiblePath = npmBin
|
||||
}
|
||||
}
|
||||
@@ -878,9 +883,9 @@ func EnsureOnPath() (bool, error) {
|
||||
|
||||
// RunDoctor 运行诊断
|
||||
func RunDoctor() error {
|
||||
cmdName, err := GetMoltbotPath()
|
||||
cmdName, err := GetOpenclawPath()
|
||||
if err != nil {
|
||||
cmdName = "moltbot"
|
||||
cmdName = "openclaw"
|
||||
}
|
||||
|
||||
cmd := exec.Command("cmd", "/c", cmdName, "doctor", "--non-interactive")
|
||||
@@ -889,9 +894,9 @@ func RunDoctor() error {
|
||||
|
||||
// RunOnboard 运行引导
|
||||
func RunOnboard() error {
|
||||
cmdName, err := GetMoltbotPath()
|
||||
cmdName, err := GetOpenclawPath()
|
||||
if err != nil {
|
||||
cmdName = "moltbot"
|
||||
cmdName = "openclaw"
|
||||
}
|
||||
cmd := exec.Command("cmd", "/c", cmdName, "onboard")
|
||||
cmd.Stdin = os.Stdin
|
||||
@@ -917,13 +922,13 @@ func GenerateAndWriteConfig(opts ConfigOptions) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("无法获取用户目录: %v", err)
|
||||
}
|
||||
configDir := filepath.Join(userHome, ".clawdbot")
|
||||
configDir := filepath.Join(userHome, ".openclaw")
|
||||
if err := os.MkdirAll(configDir, 0755); err != nil {
|
||||
return fmt.Errorf("创建配置目录失败: %v", err)
|
||||
}
|
||||
configFile := filepath.Join(configDir, "clawdbot.json")
|
||||
configFile := filepath.Join(configDir, "openclaw.json")
|
||||
|
||||
config := MoltbotConfig{
|
||||
config := OpenclawConfig{
|
||||
Gateway: GatewayConfig{
|
||||
Mode: "local",
|
||||
Bind: "loopback",
|
||||
@@ -1018,9 +1023,9 @@ func GenerateAndWriteConfig(opts ConfigOptions) error {
|
||||
|
||||
// StartGateway 启动网关
|
||||
func StartGateway() error {
|
||||
cmdName, err := GetMoltbotPath()
|
||||
cmdName, err := GetOpenclawPath()
|
||||
if err != nil {
|
||||
cmdName = "moltbot"
|
||||
cmdName = "openclaw"
|
||||
}
|
||||
|
||||
cmd := exec.Command(cmdName, "gateway", "--verbose")
|
||||
@@ -1073,14 +1078,14 @@ func KillGateway() error {
|
||||
return killCmd.Run()
|
||||
}
|
||||
|
||||
// UninstallMoltbot 卸载清理
|
||||
func UninstallMoltbot() error {
|
||||
// UninstallOpenclaw 卸载清理
|
||||
func UninstallOpenclaw() error {
|
||||
npmPath, err := getNpmPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
packages := []string{"clawdbot", "moltbot"}
|
||||
packages := []string{"openclaw", "clawdbot", "moltbot"}
|
||||
for _, pkg := range packages {
|
||||
cmd := exec.Command(npmPath, "uninstall", "-g", pkg)
|
||||
cmd.Stdout = nil
|
||||
@@ -1090,11 +1095,14 @@ func UninstallMoltbot() error {
|
||||
|
||||
userHome, err := os.UserHomeDir()
|
||||
if err == nil {
|
||||
configDir := filepath.Join(userHome, ".clawdbot")
|
||||
configDir := filepath.Join(userHome, ".openclaw")
|
||||
os.RemoveAll(configDir)
|
||||
|
||||
legacyDir := filepath.Join(userHome, ".moltbot")
|
||||
legacyDir := filepath.Join(userHome, ".clawdbot")
|
||||
os.RemoveAll(legacyDir)
|
||||
|
||||
legacyDir2 := filepath.Join(userHome, ".moltbot")
|
||||
os.RemoveAll(legacyDir2)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"moltbot-installer/internal/style"
|
||||
"moltbot-installer/internal/sys"
|
||||
"openclaw-installer/internal/style"
|
||||
"openclaw-installer/internal/sys"
|
||||
|
||||
"github.com/charmbracelet/bubbles/spinner"
|
||||
"github.com/charmbracelet/bubbles/textinput"
|
||||
@@ -71,8 +71,8 @@ type Model struct {
|
||||
// 系统状态缓存
|
||||
nodeVer string
|
||||
nodeOk bool
|
||||
moltbotVer string
|
||||
moltbotOk bool
|
||||
openclawVer string
|
||||
openclawOk bool
|
||||
gitVer string
|
||||
gitOk bool
|
||||
gatewayOk bool
|
||||
@@ -88,8 +88,8 @@ type Model struct {
|
||||
type checkMsg struct {
|
||||
nodeVer string
|
||||
nodeOk bool
|
||||
moltbotVer string
|
||||
moltbotInstalled bool
|
||||
openclawVer string
|
||||
openclawInstalled bool
|
||||
gitVer string
|
||||
gitOk bool
|
||||
gatewayRunning bool
|
||||
@@ -162,15 +162,15 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case checkMsg:
|
||||
m.nodeVer = msg.nodeVer
|
||||
m.nodeOk = msg.nodeOk
|
||||
m.moltbotVer = msg.moltbotVer
|
||||
m.moltbotOk = msg.moltbotInstalled
|
||||
m.openclawVer = msg.openclawVer
|
||||
m.openclawOk = msg.openclawInstalled
|
||||
m.gitVer = msg.gitVer
|
||||
m.gitOk = msg.gitOk
|
||||
m.gatewayOk = msg.gatewayRunning
|
||||
m.checkDone = true
|
||||
if m.envRefreshActive {
|
||||
expect := m.envRefreshExpectInstalled
|
||||
if m.nodeOk == expect && m.gitOk == expect && m.moltbotOk == expect {
|
||||
if m.nodeOk == expect && m.gitOk == expect && m.openclawOk == expect {
|
||||
m.envRefreshActive = false
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ func (m Model) View() string {
|
||||
|
||||
func (m Model) renderDashboard() string {
|
||||
// 1. 标题
|
||||
header := style.HeaderStyle.Render("Moltbot Installer")
|
||||
header := style.HeaderStyle.Render("OpenClaw Installer")
|
||||
|
||||
// 2. 状态栏
|
||||
nodeStatus := style.Badge("检测中...", "info")
|
||||
@@ -430,16 +430,16 @@ func (m Model) renderDashboard() string {
|
||||
}
|
||||
}
|
||||
|
||||
moltStatus := style.Badge("检测中...", "info")
|
||||
openclawStatus := style.Badge("检测中...", "info")
|
||||
if m.checkDone {
|
||||
if m.moltbotOk {
|
||||
ver := m.moltbotVer
|
||||
if m.openclawOk {
|
||||
ver := m.openclawVer
|
||||
if ver == "" {
|
||||
ver = "已安装"
|
||||
}
|
||||
moltStatus = style.Badge(ver, "success")
|
||||
openclawStatus = style.Badge(ver, "success")
|
||||
} else {
|
||||
moltStatus = style.Badge("未安装", "warning")
|
||||
openclawStatus = style.Badge("未安装", "warning")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ func (m Model) renderDashboard() string {
|
||||
style.SubHeaderStyle.Render("系统状态"),
|
||||
fmt.Sprintf("Node.js 环境: %s", nodeStatus),
|
||||
fmt.Sprintf("Git 环境: %s", gitStatus),
|
||||
fmt.Sprintf("Moltbot 核心: %s", moltStatus),
|
||||
fmt.Sprintf("OpenClaw 核心: %s", openclawStatus),
|
||||
fmt.Sprintf("网关进程: %s", gwStatus),
|
||||
))
|
||||
|
||||
@@ -477,7 +477,7 @@ func (m Model) renderDashboard() string {
|
||||
{"启动/重启服务", "管理后台网关进程"},
|
||||
{"配置向导", "设置 API 密钥与机器人参数"},
|
||||
{"安装/更新环境", "一键部署 Node.js 与核心组件"},
|
||||
{"卸载 Moltbot", "清理所有文件与配置"},
|
||||
{"卸载 OpenClaw", "清理所有文件与配置"},
|
||||
{"退出", "关闭控制台"},
|
||||
}
|
||||
|
||||
@@ -593,7 +593,7 @@ func (m Model) renderWizard() string {
|
||||
style.SubHeaderStyle.Render("Step 3: 确认配置"),
|
||||
"",
|
||||
"配置已就绪,准备写入文件。",
|
||||
style.DescriptionStyle.Render("路径: ~/.clawdbot/clawdbot.json"),
|
||||
style.DescriptionStyle.Render("路径: ~/.openclaw/openclaw.json"),
|
||||
"",
|
||||
style.SubtleStyle.Render("Enter 确认写入,Esc 取消"),
|
||||
)
|
||||
@@ -635,14 +635,14 @@ func (m Model) renderAction() string {
|
||||
func checkEnvCmd() tea.Msg {
|
||||
sys.ResetPathCache()
|
||||
nodeVer, nodeOk := sys.CheckNode()
|
||||
moltVer, moltOk := sys.CheckMoltbot()
|
||||
openclawVer, openclawOk := sys.CheckOpenclaw()
|
||||
gitVer, gitOk := sys.CheckGit()
|
||||
gwRun := sys.IsGatewayRunning()
|
||||
return checkMsg{
|
||||
nodeVer: nodeVer,
|
||||
nodeOk: nodeOk,
|
||||
moltbotVer: moltVer,
|
||||
moltbotInstalled: moltOk,
|
||||
openclawVer: openclawVer,
|
||||
openclawInstalled: openclawOk,
|
||||
gitVer: gitVer,
|
||||
gitOk: gitOk,
|
||||
gatewayRunning: gwRun,
|
||||
@@ -684,7 +684,7 @@ func runUninstallCmd() tea.Msg {
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// 2. 卸载文件
|
||||
err := sys.UninstallMoltbot()
|
||||
err := sys.UninstallOpenclaw()
|
||||
return actionResultMsg{err: err}
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ func runSaveConfigCmd(opts sys.ConfigOptions) tea.Cmd {
|
||||
}
|
||||
|
||||
func runInstallFlowCmd() tea.Msg {
|
||||
// 线性流程: 检查Node -> 安装Node -> 检查Git -> 安装Git -> 配置NPM -> 安装Moltbot -> 配置系统
|
||||
// 线性流程: 检查Node -> 安装Node -> 检查Git -> 安装Git -> 配置NPM -> 安装OpenClaw -> 配置系统
|
||||
// 为简化状态,使用阻塞执行
|
||||
|
||||
err := sys.InstallNode()
|
||||
@@ -719,9 +719,9 @@ func runInstallFlowCmd() tea.Msg {
|
||||
return actionResultMsg{err: fmt.Errorf("npm 配置失败: %v", err)}
|
||||
}
|
||||
|
||||
err = sys.InstallMoltbotNpm("latest")
|
||||
err = sys.InstallOpenclawNpm("latest")
|
||||
if err != nil {
|
||||
return actionResultMsg{err: fmt.Errorf("moltbot 安装失败: %v", err)}
|
||||
return actionResultMsg{err: fmt.Errorf("openclaw 安装失败: %v", err)}
|
||||
}
|
||||
|
||||
_, err = sys.EnsureOnPath()
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"moltbot-installer/internal/ui"
|
||||
"openclaw-installer/internal/ui"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
Reference in New Issue
Block a user