fix: change clone source from github to git.cutos.ai

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
stswangzhiping
2026-05-04 17:24:41 +08:00
parent 844d3c89ae
commit e4e99c9aed

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#!/usr/bin/env bash
# clawd 一键安装脚本
# 用法curl -fsSL https://raw.githubusercontent.com/stswangzhiping/clawd/main/install.sh | bash
# 用法curl -fsSL https://git.cutos.ai/claw-daemon/clawd/raw/branch/main/install.sh | sudo bash
# 需要 root 权限,需要已安装 Node.js >= 18
set -e
@@ -11,12 +11,12 @@ info() { echo -e "${GREEN}[clawd]${NC} $*"; }
warn() { echo -e "${YELLOW}[clawd]${NC} $*"; }
error() { echo -e "${RED}[clawd]${NC} $*"; exit 1; }
# ── 检查 root ────────────────────────────────────────────────────────────────
# -- 检查 root
if [ "$EUID" -ne 0 ]; then
error "请以 root 身份运行sudo bash install.sh"
fi
# ── 检查 Node.js ─────────────────────────────────────────────────────────────
# -- 检查 Node.js
if ! command -v node &>/dev/null; then
error "未找到 Node.js请先安装 Node.js >= 18"
fi
@@ -26,9 +26,9 @@ MAJOR=$(echo "$NODE_VER" | cut -d. -f1)
if [ "$MAJOR" -lt 18 ]; then
error "Node.js 版本过低(当前 $NODE_VER),需要 >= 18"
fi
info "Node.js $NODE_VER "
info "Node.js $NODE_VER OK"
# ── 检查/安装 dnsmasqWiFi 配网需要)──────────────────────────────────────
# -- 检查/安装 dnsmasqWiFi 配网需要)
if ! command -v dnsmasq &>/dev/null; then
info "安装 dnsmasqWiFi 配网所需)..."
if command -v apt-get &>/dev/null; then
@@ -45,16 +45,16 @@ if ! command -v dnsmasq &>/dev/null; then
systemctl stop dnsmasq 2>/dev/null || true
fi
if command -v dnsmasq &>/dev/null; then
info "dnsmasq "
info "dnsmasq OK"
fi
# ── 启用 NetworkManagerWiFi 配网需要)──────────────────────────────────────
# -- 启用 NetworkManagerWiFi 配网需要)
if command -v nmcli &>/dev/null; then
if ! systemctl is-active --quiet NetworkManager 2>/dev/null; then
info "启用 NetworkManager..."
systemctl enable --now NetworkManager 2>/dev/null || true
fi
info "NetworkManager "
info "NetworkManager OK"
# 预写 DNS 劫持配置(运行时 /etc 可能为只读)
NM_DNSMASQ_DIR="/etc/NetworkManager/dnsmasq-shared.d"
@@ -64,10 +64,10 @@ if command -v nmcli &>/dev/null; then
# All DNS queries resolve to gateway to trigger captive portal
address=/#/10.42.0.1
DNSCONF
info "DNS 劫持配置已写入 $NM_DNSMASQ_DIR"
info "DNS 劫持配置已写入 $NM_DNSMASQ_DIR"
fi
# ── WiFi rfkill 解锁(部分设备默认禁用 WiFi────────────────────────────────
# -- WiFi rfkill 解锁(部分设备默认禁用 WiFi
for rf in /sys/class/rfkill/rfkill*; do
if [ -f "$rf/type" ] && [ "$(cat "$rf/type")" = "wlan" ]; then
if [ "$(cat "$rf/soft")" = "1" ]; then
@@ -108,17 +108,17 @@ WantedBy=multi-user.target
UNIT
systemctl daemon-reload
systemctl enable clawd-rfkill
info "WiFi rfkill 解锁服务已创建"
info "WiFi rfkill 解锁服务已创建"
# ── 安装 ttydWeb 终端)────────────────────────────────────────────────────
# -- 安装 ttydWeb 终端)
info "安装 ttyd..."
if apt-get install -y ttyd >/dev/null 2>&1; then
info "ttyd 已安装"
info "ttyd 已安装"
else
warn "ttyd 安装失败Web 终端功能将不可用"
fi
# ── 安装 clawd ───────────────────────────────────────────────────────────────
# -- 安装 clawd
INSTALL_DIR="/opt/clawd"
CONFIG_DIR="/etc/clawd"
ENV_FILE="$CONFIG_DIR/env"
@@ -127,17 +127,17 @@ info "安装到 $INSTALL_DIR ..."
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
# 下载源码(若目录已有 package.json视为离线/已解压部署,跳过 git/tarball;避免设备无法访问 github.com
# 下载源码(若目录已有 package.json视为离线/已解压部署,跳过 git/tarball
if [ -f "package.json" ]; then
info "检测到已有源码,跳过 git/tarball 下载"
elif command -v git &>/dev/null; then
if [ -d ".git" ]; then
git pull --quiet
else
git clone --depth=1 https://github.com/stswangzhiping/clawd.git .
git clone --depth=1 https://git.cutos.ai/claw-daemon/clawd.git .
fi
else
TARBALL_URL="https://github.com/stswangzhiping/clawd/archive/refs/heads/main.tar.gz"
TARBALL_URL="https://git.cutos.ai/claw-daemon/clawd/archive/main.tar.gz"
curl -fsSL "$TARBALL_URL" | tar -xz --strip-components=1
fi
@@ -149,10 +149,10 @@ npm install --omit=dev --silent
ln -sf "$INSTALL_DIR/bin/clawd.js" /usr/local/bin/clawd
chmod +x "$INSTALL_DIR/bin/clawd.js"
info "clawd 已安装到 /usr/local/bin/clawd"
info "clawd 已安装到 /usr/local/bin/clawd"
# ── 创建配置目录 + 环境变量文件 ──────────────────────────────────────────────
# -- 创建配置目录 + 环境变量文件
mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_DIR/config.json" ]; then
@@ -164,7 +164,7 @@ if [ ! -f "$CONFIG_DIR/config.json" ]; then
"heartbeat_interval": 30
}
EOF
info "配置文件已创建:$CONFIG_DIR/config.json"
info "配置文件已创建:$CONFIG_DIR/config.json"
fi
if [ ! -f "$ENV_FILE" ]; then
@@ -186,21 +186,21 @@ CLAWD_LOG_FILE=1
# 多网口/特殊板型可固定 LAN 灯监控的以太网口(默认由 clawd 自动锁定首次 carrier 口)
# CLAWD_ETH_IFACE=end0
EOF
info "环境变量文件已创建:$ENV_FILE"
info "环境变量文件已创建:$ENV_FILE"
fi
# ── 创建日志目录 ─────────────────────────────────────────────────────────────
# -- 创建日志目录
mkdir -p "$CONFIG_DIR/logs"
info "日志目录:$CONFIG_DIR/logs"
info "日志目录:$CONFIG_DIR/logs"
# ── 创建 systemd service ────────────────────────────────────────────────────
# -- 创建 systemd service
NODE_BIN=$(command -v node)
SERVICE_FILE="/etc/systemd/system/clawd.service"
cat > "$SERVICE_FILE" <<EOF
[Unit]
Description=Claw Box Daemon
Documentation=https://github.com/stswangzhiping/clawd
Documentation=https://git.cutos.ai/claw-daemon/clawd
After=NetworkManager.service
Wants=NetworkManager.service
@@ -245,9 +245,9 @@ WatchdogSec=60
WantedBy=multi-user.target
EOF
info "systemd 服务文件已创建"
info "systemd 服务文件已创建"
# ── journald 日志限制(可选) ────────────────────────────────────────────────
# -- journald 日志限制(可选)
JOURNAL_CONF="/etc/systemd/journald.conf.d/clawd.conf"
if [ ! -f "$JOURNAL_CONF" ]; then
mkdir -p /etc/systemd/journald.conf.d
@@ -258,17 +258,17 @@ SystemMaxUse=100M
MaxFileSec=7day
EOF
systemctl restart systemd-journald 2>/dev/null || true
info "journald 日志限制已配置"
info "journald 日志限制已配置"
fi
# ── 启用并启动 ──────────────────────────────────────────────────────────────
# -- 启用并启动
systemctl daemon-reload
systemctl enable clawd
systemctl restart clawd
sleep 2
if systemctl is-active --quiet clawd; then
info "clawd 服务运行中"
info "clawd 服务运行中"
echo ""
echo " 查看日志: journalctl -u clawd -f"
echo " 查看状态: systemctl status clawd"
@@ -280,4 +280,4 @@ if systemctl is-active --quiet clawd; then
else
warn "服务启动失败,请检查日志:"
echo " journalctl -u clawd -n 50 --no-pager"
fi
fi