poll-until-done.sh 1.7 KB

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