diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e83ff6..247c9d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: uses: ludeeus/action-shellcheck@2.0.0 with: scandir: '.' - additional_files: 'install.sh install-lite.sh install-mac.sh doctor.sh keepalive.sh scripts/safe-update.sh scripts/switch-regime.sh scripts/init-personas.sh scripts/extract-personas.sh scripts/backup-all.sh scripts/memory-backup.sh' + additional_files: 'install-lite.sh install-mac.sh doctor.sh keepalive.sh scripts/safe-update.sh scripts/switch-regime.sh scripts/init-personas.sh scripts/extract-personas.sh scripts/backup-all.sh scripts/memory-backup.sh' severity: warning - name: Check Dockerfile builds diff --git a/doctor.sh b/doctor.sh index ece1e54..55e2dfa 100755 --- a/doctor.sh +++ b/doctor.sh @@ -349,7 +349,6 @@ for g in guilds: # 用第一个有效 Token 获取服务器角色 FIRST_TOKEN="" - FIRST_GUILD="" DISCORD_ACCOUNTS_2=$(json_keys "$CONFIG_FILE" "channels.discord.accounts") while IFS= read -r acct; do [ -z "$acct" ] && continue @@ -386,7 +385,8 @@ try: if perm & MENTION_EVERYONE: managed = r.get('managed', False) tag = ' (Bot 托管角色)' if managed else '' - problems.append(f'{r["name"]}{tag}') + name = r.get('name', '?') + problems.append(name + tag) if problems: print('|'.join(problems)) except: pass diff --git a/scripts/backup-all.sh b/scripts/backup-all.sh index cfed438..3f2ede5 100755 --- a/scripts/backup-all.sh +++ b/scripts/backup-all.sh @@ -94,8 +94,9 @@ backup_file() { return 0 fi - local dest="$dest_dir/$(basename "$src").$TIMESTAMP" - + local dest + dest="$dest_dir/$(basename "$src").$TIMESTAMP" + if cp -p "$src" "$dest" 2>/dev/null; then chmod 600 "$dest" echo -e " ${GREEN}✓${NC} $desc → $dest" @@ -122,8 +123,9 @@ backup_dir() { return 0 fi - local dest="$dest_dir/$(basename "$src").$TIMESTAMP.tar.gz" - + local dest + dest="$dest_dir/$(basename "$src").$TIMESTAMP.tar.gz" + if tar -czf "$dest" -C "$(dirname "$src")" "$(basename "$src")" 2>/dev/null; then chmod 600 "$dest" echo -e " ${GREEN}✓${NC} $desc → $dest" diff --git a/scripts/cleanup-repo.sh b/scripts/cleanup-repo.sh index 87532e8..b633542 100755 --- a/scripts/cleanup-repo.sh +++ b/scripts/cleanup-repo.sh @@ -7,7 +7,6 @@ set -e -RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' diff --git a/scripts/extract-personas.sh b/scripts/extract-personas.sh index eec9433..2f0865e 100755 --- a/scripts/extract-personas.sh +++ b/scripts/extract-personas.sh @@ -14,7 +14,6 @@ REGIME="${1:-ming-neige}" CONFIG_FILE="$DANGHUANGSHANG_ROOT/configs/$REGIME/openclaw.json" AGENTS_DIR="$DANGHUANGSHANG_ROOT/configs/$REGIME/agents" -CYAN='\033[0;36m' GREEN='\033[0;32m' NC='\033[0m' diff --git a/scripts/full-install.sh b/scripts/full-install.sh index 6978c45..99543be 100755 --- a/scripts/full-install.sh +++ b/scripts/full-install.sh @@ -134,15 +134,14 @@ CLAWDBOT_CONFIG="$HOME/.clawdbot/openclaw.json" CONFIG_FILE="$CONFIG_DIR/openclaw.json" # 检测配置目录 -ACTUAL_CONFIG_DIR="$CONFIG_DIR" if [ -f "$CLAWDBOT_CONFIG" ] && [ ! -f "$CONFIG_FILE" ]; then - ACTUAL_CONFIG_DIR="$HOME/.clawdbot" + CONFIG_DIR="$HOME/.clawdbot" CONFIG_FILE="$CLAWDBOT_CONFIG" echo -e " ${YELLOW}i${NC} 使用 .clawdbot 配置目录" elif [ -f "$CONFIG_FILE" ]; then echo -e " ${YELLOW}i${NC} 使用 .openclaw 配置目录" elif [ -f "$CLAWDBOT_CONFIG" ]; then - ACTUAL_CONFIG_DIR="$HOME/.clawdbot" + CONFIG_DIR="$HOME/.clawdbot" CONFIG_FILE="$CLAWDBOT_CONFIG" echo -e " ${YELLOW}i${NC} 使用 .clawdbot 配置目录" else diff --git a/scripts/pre-update-check.sh b/scripts/pre-update-check.sh index f71a8ee..f4ae4e7 100755 --- a/scripts/pre-update-check.sh +++ b/scripts/pre-update-check.sh @@ -221,9 +221,6 @@ if [ -d "$BACKUP_DIR" ]; then echo -e " 最新备份:$backup_date" # 检查备份是否在 24 小时内 - backup_timestamp=$(echo "$backup_date" | sed 's/_//g') - current_timestamp=$(date +%Y%m%d%H%M%S) - # 简化检查:如果是今天的备份 backup_today=$(echo "$backup_date" | cut -d_ -f1) today=$(date +%Y%m%d) diff --git a/scripts/refresh-oauth-token.sh b/scripts/refresh-oauth-token.sh index 65fa53a..9f94196 100755 --- a/scripts/refresh-oauth-token.sh +++ b/scripts/refresh-oauth-token.sh @@ -1,5 +1,4 @@ #!/bin/bash -AUTH_FILE="/home/ubuntu/.clawdbot/agents/main/agent/auth-profiles.json" LOG="/tmp/oauth-refresh.log" echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) Starting OAuth token refresh..." >> "$LOG" diff --git a/scripts/safe-update.sh b/scripts/safe-update.sh index bf6e82e..e1e692d 100755 --- a/scripts/safe-update.sh +++ b/scripts/safe-update.sh @@ -82,7 +82,8 @@ safety_check() { # 检查 1: allowBots 设置 if [ -f "$OPENCLAW_CONFIG" ]; then - local allow_bots=$(grep -o '"allowBots"[[:space:]]*:[[:space:]]*"[^"]*"' "$OPENCLAW_CONFIG" | head -1) + local allow_bots + allow_bots=$(grep -o '"allowBots"[[:space:]]*:[[:space:]]*"[^"]*"' "$OPENCLAW_CONFIG" | head -1) if echo "$allow_bots" | grep -q '"mentions"'; then success "allowBots 配置正确:mentions" elif echo "$allow_bots" | grep -q 'true'; then @@ -140,7 +141,8 @@ do_update() { # 回滚 rollback() { - local latest_backup=$(cat "$BACKUP_DIR/latest" 2>/dev/null) + local latest_backup + latest_backup=$(cat "$BACKUP_DIR/latest" 2>/dev/null) if [ -z "$latest_backup" ] || [ ! -d "$latest_backup" ]; then error "未找到备份,无法回滚"