From c9597cf1a0f91dcefbbada8e41ef5f7975e59e02 Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Mon, 11 May 2026 10:06:17 +0800 Subject: [PATCH] fix: rewrite install.sh in ASCII English to fix garbled characters Co-authored-by: Cursor --- install.sh | 144 ++++++++++++++++++++++++++--------------------------- 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/install.sh b/install.sh index c335c20..948e309 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# clawd ?????? -# ???curl -fsSL https://git.cutos.ai/claw-daemon/clawd/raw/branch/main/install.sh | sudo bash -# ?? root ???????? Node.js >= 18 +# clawd installer +# Run: curl -fsSL https://git.cutos.ai/claw-daemon/clawd/raw/branch/main/install.sh | sudo bash +# Requires root and Node.js >= 18 set -e @@ -11,26 +11,26 @@ info() { echo -e "${GREEN}[clawd]${NC} $*"; } warn() { echo -e "${YELLOW}[clawd]${NC} $*"; } error() { echo -e "${RED}[clawd]${NC} $*"; exit 1; } -# ?? ?? root ???????????????????????????????????????????????????????????????? +# Check root if [ "$EUID" -ne 0 ]; then - error "?? root ?????sudo bash install.sh?" + error "Please run as root: sudo bash install.sh" fi -# ?? ?? Node.js ????????????????????????????????????????????????????????????? +# Check Node.js if ! command -v node &>/dev/null; then - error "??? Node.js????? Node.js >= 18" + error "Node.js not found. Please install Node.js >= 18" fi NODE_VER=$(node -e "process.stdout.write(process.versions.node)") MAJOR=$(echo "$NODE_VER" | cut -d. -f1) if [ "$MAJOR" -lt 18 ]; then - error "Node.js ??????? $NODE_VER???? >= 18" + error "Node.js version $NODE_VER is too old. Requires >= 18" fi -info "Node.js $NODE_VER ?" +info "Node.js $NODE_VER OK" -# ?? ??/?? dnsmasq?WiFi ??????????????????????????????????????????? +# Install dnsmasq (required for WiFi captive portal) if ! command -v dnsmasq &>/dev/null; then - info "?? dnsmasq?WiFi ?????..." + info "Installing dnsmasq for WiFi captive portal..." if command -v apt-get &>/dev/null; then apt-get install -y -qq dnsmasq >/dev/null 2>&1 elif command -v yum &>/dev/null; then @@ -38,25 +38,25 @@ if ! command -v dnsmasq &>/dev/null; then elif command -v apk &>/dev/null; then apk add --quiet dnsmasq >/dev/null 2>&1 else - warn "?????? dnsmasq?WiFi ?????????" + warn "Cannot install dnsmasq. WiFi captive portal may not work." fi - # ?? dnsmasq ???????clawd ????? + # Disable system dnsmasq; clawd manages it directly systemctl disable dnsmasq 2>/dev/null || true systemctl stop dnsmasq 2>/dev/null || true fi if command -v dnsmasq &>/dev/null; then - info "dnsmasq ?" + info "dnsmasq OK" fi -# ?? ?? NetworkManager?WiFi ??????????????????????????????????????????? +# Configure NetworkManager for WiFi if command -v nmcli &>/dev/null; then if ! systemctl is-active --quiet NetworkManager 2>/dev/null; then - info "?? NetworkManager..." + info "Starting NetworkManager..." systemctl enable --now NetworkManager 2>/dev/null || true fi - info "NetworkManager ?" + info "NetworkManager OK" - # ?? DNS ???????? /etc ?????? + # Write captive-portal DNS config NM_DNSMASQ_DIR="/etc/NetworkManager/dnsmasq-shared.d" mkdir -p "$NM_DNSMASQ_DIR" cat > "$NM_DNSMASQ_DIR/clawd-captive.conf" << 'DNSCONF' @@ -64,20 +64,20 @@ 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 captive config written to $NM_DNSMASQ_DIR" fi -# ?? WiFi rfkill ??????????? WiFi????????????????????????????????? +# Unblock WiFi via rfkill for rf in /sys/class/rfkill/rfkill*; do if [ -f "$rf/type" ] && [ "$(cat "$rf/type")" = "wlan" ]; then if [ "$(cat "$rf/soft")" = "1" ]; then - info "?? WiFi ($(basename "$rf"))..." + info "Unblocking WiFi ($(basename "$rf"))..." echo 0 > "$rf/soft" fi fi done -# ???????? + systemd ??????????? WiFi +# Install rfkill unblock script + systemd unit for persistence RFKILL_SCRIPT="/usr/local/bin/clawd-unblock-wifi.sh" cat > "$RFKILL_SCRIPT" << 'SCRIPT' #!/bin/sh @@ -108,39 +108,39 @@ WantedBy=multi-user.target UNIT systemctl daemon-reload systemctl enable clawd-rfkill -info "WiFi rfkill ??????? ?" +info "WiFi rfkill service installed" -# ?? ?? ttyd?Web ??????????????????????????????????????????????????????? -info "?? ttyd..." +# Install ttyd (Web terminal) +info "Installing ttyd..." if apt-get install -y ttyd >/dev/null 2>&1; then - info "ttyd ??? ?" + info "ttyd installed OK" else - warn "ttyd ?????Web ????????" + warn "ttyd install failed. Web terminal will not be available." fi -# ?? ?? clawd ??????????????????????????????????????????????????????????????? +# Clone / update clawd INSTALL_DIR="/opt/clawd" CONFIG_DIR="/etc/clawd" ENV_FILE="$CONFIG_DIR/env" -info "??? $INSTALL_DIR ..." +info "Setting up $INSTALL_DIR ..." mkdir -p "$INSTALL_DIR" cd "$INSTALL_DIR" -# ?????????? package.json?????/???????? git/tarball? +# Use git if available, fall back to tarball CUTOS_REPO="https://git.cutos.ai/claw-daemon/clawd.git" if command -v git &>/dev/null && [ -d ".git" ]; then CURRENT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "") if echo "$CURRENT_REMOTE" | grep -q "github.com"; then - info "?? git remote ? git.cutos.ai ..." + info "Migrating git remote to git.cutos.ai ..." git remote set-url origin "$CUTOS_REPO" fi - info "??????..." + info "Pulling latest code..." git fetch origin git reset --hard origin/main git clean -fd elif [ -f "package.json" ]; then - info "????????? git??????" + info "Files already present, skipping git clone" elif command -v git &>/dev/null; then git clone --depth=1 "$CUTOS_REPO" . else @@ -148,18 +148,18 @@ else curl -fsSL "$TARBALL_URL" | tar -xz --strip-components=1 fi -# ???? -info "?? npm ??..." +# Install npm dependencies +info "Running npm install..." npm install --omit=dev --silent -# ??????? +# Create symlink 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 symlinked to /usr/local/bin/clawd" -# ?? ?????? + ?????? ?????????????????????????????????????????????? +# Write default config files mkdir -p "$CONFIG_DIR" if [ ! -f "$CONFIG_DIR/config.json" ]; then @@ -171,36 +171,35 @@ if [ ! -f "$CONFIG_DIR/config.json" ]; then "heartbeat_interval": 30 } EOF - info "????????$CONFIG_DIR/config.json ?" + info "Default config written to $CONFIG_DIR/config.json" fi if [ ! -f "$ENV_FILE" ]; then cat > "$ENV_FILE" < "$JOURNAL_CONF" </dev/null || true - info "journald ??????? ?" + info "journald config written" fi -# ?? ????? ?????????????????????????????????????????????????????????????? +# Enable and start clawd systemctl daemon-reload systemctl enable clawd systemctl restart clawd sleep 2 if systemctl is-active --quiet clawd; then - info "clawd ????? ?" + info "clawd is running" echo "" - echo " ????? journalctl -u clawd -f" - echo " ????? systemctl status clawd" - echo " ????? systemctl stop clawd" - echo " ????? $CONFIG_DIR/config.json" - echo " ????? $ENV_FILE" - echo " ????? $CONFIG_DIR/logs/clawd.log" + echo " Logs: journalctl -u clawd -f" + echo " Status: systemctl status clawd" + echo " Stop: systemctl stop clawd" + echo " Config: $CONFIG_DIR/config.json" + echo " Env: $ENV_FILE" + echo " Log dir: $CONFIG_DIR/logs/clawd.log" echo "" else - warn "?????????????" + warn "clawd failed to start. Check logs:" echo " journalctl -u clawd -n 50 --no-pager" fi