fix: 修复 CI shellcheck warnings + 移除不存在的 install.sh 引用

- ci.yml: 移除对不存在的 install.sh 的引用
- doctor.sh: 移除未使用的 FIRST_GUILD 变量,修复 Python f-string 引号问题
- scripts/*.sh: 修复 SC2155 (declare and assign separately)
- scripts/*.sh: 移除未使用的变量 (SC2034)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chairman's chair
2026-03-27 01:24:44 +08:00
parent 6d0ba39939
commit eccfa0fbeb
9 changed files with 15 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -7,7 +7,6 @@
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

View File

@@ -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'

View File

@@ -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

View File

@@ -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)

View File

@@ -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"

View File

@@ -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 "未找到备份,无法回滚"