start-wechat-viewer
1.29 KB
#!/data/data/com.termux/files/usr/bin/bash
# Boot script: 设备重启后自动启动 WeChat Viewer + wake-lock
# 需要安装 Termux:Boot (F-Droid) 才能生效
# 路径: ~/.termux/boot/start-wechat-viewer
termux-wake-lock
# 等系统完全就绪
sleep 10
cd /data/data/com.termux/files/home/wechat-viewer
# 杀掉可能的残留
pkill -f 'python3 app.py' 2>/dev/null
sleep 1
fuser -k 5001/tcp 2>/dev/null
# 启动 WeChat Viewer
nohup python3 app.py > /tmp/wechat-viewer.log 2>&1 &
echo "[$(date)] WeChat Viewer started by boot script" >> /tmp/wechat-viewer-boot.log
# 启动 task.hexdo.com 命名隧道(pixel-wechat-viewer → 127.0.0.1:5001)
# 2026-08-07: 之前这里没有启动逻辑,重启后隧道要么不起、要么被人手动
# 起成 `cloudflared tunnel --url`(临时随机域名,不是 task.hexdo.com)顶替,见
# ~/.cloudflared/config.yml 与 pixelphone 仓库 memory task-hexdo-reverse-proxy-outage.md
pkill -f 'cloudflared tunnel --config' 2>/dev/null
pkill -f 'cloudflared tunnel --url' 2>/dev/null
sleep 1
nohup cloudflared tunnel --config /data/data/com.termux/files/home/.cloudflared/config.yml run pixel-wechat-viewer > /data/data/com.termux/files/home/.cloudflared/tunnel.log 2>&1 &
echo "[$(date)] cloudflared (task.hexdo.com) started by boot script" >> /tmp/wechat-viewer-boot.log