#!/bin/bash # 自动轮询:等待收尾任务完成(改名 + 图标 + MIT 全文) # 间隔 8 分钟,最多 20 轮(约 2.6 小时),全部完成则 exit 0 PJ="/Users/eastudio/DevEcoStudioProjects/dsh-harmony" LOG="/Users/eastudio/Documents/EvanAgent/assets/store/poll-status.log" INTERVAL=480 MAX=20 : > "$LOG" check_rename() { grep -rhiE "dotouch" "$PJ/AppScope/resources/base/element/string.json" \ "$PJ/entry/src/main/resources/base/element/string.json" 2>/dev/null | grep -qi "dotouch" } check_icon() { python3 - <<'EOF' >/dev/null 2>&1 from PIL import Image p="/Users/eastudio/DevEcoStudioProjects/dsh-harmony/AppScope/resources/base/media/foreground.png" try: im=Image.open(p).convert("RGBA"); red=blue=0 for r,g,b,a in im.getdata(): if a<40: continue if r>200 and g<80 and b<80: red+=1 if b>120 and r<60 and g<80: blue+=1 exit(0 if (red>50 and blue>100) else 1) except Exception: exit(1) EOF } check_mit() { # LICENSE 文件存在即视为完成 [ -f "$PJ/LICENSE" ] && return 0 # 源码/资源中出现 MIT 字样即视为完成 grep -rliE "MIT" "$PJ/entry/src" "$PJ/AppScope" 2>/dev/null | grep -q . } for i in $(seq 1 "$MAX"); do ts=$(date '+%m-%d %H:%M:%S') rn=$(check_rename && echo OK || echo NO) ic=$(check_icon && echo OK || echo NO) mt=$(check_mit && echo OK || echo NO) echo "[$ts] #$i 改名=$rn 图标=$ic MIT=$mt" | tee -a "$LOG" if [ "$rn" = OK ] && [ "$ic" = OK ] && [ "$mt" = OK ]; then echo "[$ts] ✅ 三项全部完成" | tee -a "$LOG" exit 0 fi [ "$i" -lt "$MAX" ] && sleep "$INTERVAL" done echo "[$(date '+%m-%d %H:%M:%S')] ⏰ 轮询超时($MAX 轮)" | tee -a "$LOG" exit 1