Skip to content

Commit 748c3aa

Browse files
committed
update readme for next release
1 parent 3bcf6f6 commit 748c3aa

File tree

4 files changed

+99
-72
lines changed

4 files changed

+99
-72
lines changed

README.md

+76-69
Original file line numberDiff line numberDiff line change
@@ -57,44 +57,49 @@ sudo systemctl restart docker
5757

5858
**由于SQLite对于多并发读写并不友好,所以在完成优化和测试前不再推荐使用SQLite,默认数据库更换为PostgresSQL**
5959

60-
根据系统架构在release页面获取 prepare 二进制文件,如果所用系统架构没有对应的release,请参照contribution自行build
60+
根据系统架构在release页面获取 ojtool 二进制文件,如果所用系统架构没有对应的release,请参照contribution自行build
6161

6262

6363

6464
```shell
65-
./prepare -MasterIP xxx.xxx.xxx.xxx --postgres
66-
INSTALL_K3S_MIRROR=cn ./prepare -MasterIP xxx.xxx.xxx.xxx --postgres #for CHINA
65+
./ojtool prepare -MasterIP xxx.xxx.xxx.xxx --postgres
66+
INSTALL_K3S_MIRROR=cn ./ojtool prepare -MasterIP xxx.xxx.xxx.xxx --postgres #for CHINA
6767
```
6868

6969
**中国用户请使用Mirror的参数执行**
7070

71-
执行`prepare` 会在当前目录下生成配置文件目录`resources`,安装完成后目录应该如下所示,其中`https.crt``https.key` 文件不会默认生成。平台启动时会自动检测这两个文件,如果存在,就自动启用https模式,否则采用http模式
71+
执行`ojtool prepare` 会在当前目录下生成配置文件目录`resources`,安装完成后目录应该如下所示,其中`https.crt``https.key` 文件不会默认生成。平台启动时会自动检测这两个文件,如果存在,就自动启用https模式,否则采用http模式
7272

7373
`home.html`为提供了主页面定制化的功能,在前后端一体化的单文件模式下,如果平台`resources` 目录中存在`home.html` 会将其作为平台主页展示
7474

7575
```
7676
.
77-
├── agent-install.sh #「在从节点服务器上使用」从节点安装文件
78-
├── OJ #平台二进制文件
79-
├── prepare #部署器二进制文件
80-
├── resources #配置文件目录
81-
│   ├── ca.crt #镜像仓库自签名根证书备份
82-
│   ├── config.yaml #「平台启动前请修改」平台配置文件模板
83-
│   ├── docker-registry #镜像仓库相关目录
84-
│   │   ├── auth #镜像仓库授权文件目录
85-
│   │   │   └── htpasswd #授权文件
86-
│   │   ├── certs #镜像仓库证书目录
87-
│   │   │   ├── tls.crt #镜像仓库证书
88-
│   │   │   └── tls.key #镜像仓库私钥
89-
│   │   └── data #镜像仓库数据存储目录
90-
| ├── [postgres] #postgres数据目录
91-
│ ├── [https.crt] #「非自动生成」网站TLS证书
92-
│   ├── [https.key] #「非自动生成」网站TLS私钥
93-
│   ├── k3s.yaml #自动生成的k3s配置文件,不需要修改
94-
| ├── [home.html] #「非自动生成」如果存在,会加载该网页做为主页面
95-
│   ├── tls.crt #镜像仓库公私钥备份
96-
│   └── tls.key #镜像仓库公私钥备份
97-
└── start.sh #「配置完毕后启动」启动脚本
77+
├── agent-install.sh #「在从节点服务器上使用」从节点安装文件
78+
├── OJ #平台二进制文件
79+
├── ojtool #命令行工具二进制文件
80+
├── resources #配置文件目录
81+
│   ├── ca.crt #镜像仓库自签名根证书备份
82+
│   ├── config.yaml #「平台启动前请修改」平台配置文件模板
83+
│   ├── docker-registry #镜像仓库相关目录
84+
│   │   ├── auth #镜像仓库授权文件目录
85+
│   │   │   └── htpasswd #授权文件
86+
│   │   ├── certs #镜像仓库证书目录
87+
│   │   │   ├── tls.crt #镜像仓库证书
88+
│   │   │   └── tls.key #镜像仓库私钥
89+
│   │   └── data #镜像仓库数据存储目录
90+
| ├── [postgres] #postgres数据目录
91+
│ ├── [https.crt] #「非自动生成」网站TLS证书
92+
│   ├── [https.key] #「非自动生成」网站TLS私钥
93+
│   ├── k3s.yaml #自动生成的k3s配置文件,不需要修改
94+
| ├── [home.html] #「非自动生成」如果存在,会加载该网页做为主页面
95+
| ├── [timeline.save] #「启动后生成」排行榜历史数据存储文件
96+
| ├── [emails] #「非自动生成」邮件模板目录
97+
│   │   ├── [reset.html] #「非自动生成」密码重置邮件模板
98+
│   │   └── [welcome.html] #「非自动生成」导入账户初始化邮件模板
99+
│   ├── tls.crt #镜像仓库公私钥备份
100+
│   └── tls.key #镜像仓库公私钥备份
101+
├── [writeup] #「启动后生成」writeup存储目录
102+
└── start.sh #「配置完毕后启动」启动脚本
98103
```
99104

100105
然后使用 `start.sh`启动平台
@@ -124,36 +129,37 @@ To uninstall K3s from an agent node, run:
124129
#### 平台配置说明
125130

126131
```yaml
127-
server: #平台服务器的配置参数
128-
host: 127.0.0.1 #设置为Host,用于重置密码和CORS等(仅hostname部分不含协议端口和路径)
129-
username: Tp0t #默认admin用户名
130-
password: password #默认admin账号密码
131-
mail: [email protected] #默认admin账号邮箱
132-
port: 0 #0时自动选择80/443,非0指定端口
133-
salt: "xxxxxxxxxx" #用于密码保护的salt,自动生成
134-
behaviorLog: false #用于记录选手关键行为,默认不开启
135-
debug: #debug相关功能,生产环境请勿开启
136-
dockerOpDetail: false #开启可以查看容器构建和下发的问题
137-
noOriginCheck: false #开启禁用orgin检查,禁用csrf检查,禁用CSP
138-
dbOpDetail: false #开启查看所有数据库请求
139-
cookieExpiresSeconds: 3600 #cookie过期秒数,0表示不会过期,-1表示在关闭浏览器时过期
140-
email: #邮件服务配置
141-
host: smtp.example.com #邮件服务提供商服务器
142-
username: exampleUsername #邮件发送账号
143-
password: examplePassword #邮件发送账号密码(可能为授权码)
144-
challenge: #题目分数控制参数
145-
firstBloodReward: 0.1 #一血分数奖励比例
146-
secondBloodReward: 0.08 #二血分数奖励比例
147-
thirdBloodReward: 0.05 #三血分数奖励比例
148-
halfLife: 20 #题目分值减半所需解题人数
149-
kubernetes: #k8s集群配置参数
150-
portAllocBegin: 30000 #自动分配端口范围起点
151-
portAllocEnd: 31000 #自动分配端口终点
152-
username: xxxxxxxx #「不可修改」镜像仓库用户名
153-
password: xxxxxxxx #「不可修改」镜像仓库密码
154-
registryHost: xxx.xxx.xxx.xxx:5000 #「不可修改」镜像仓库地址(与平台一致)
155-
database: #数据库连接参数
156-
dsn: "..." #数据库连接配置,自动生成
132+
server: #平台服务器的配置参数
133+
host: 127.0.0.1 #设置为Host,用于重置密码和CORS等(仅hostname部分不含协议端口和路径)
134+
username: Tp0t #默认admin用户名
135+
password: password #默认admin账号密码
136+
mail: [email protected] #默认admin账号邮箱
137+
port: 0 #0时自动选择80/443,非0指定端口
138+
salt: "xxxxxxxxxx" #用于密码保护的salt,自动生成
139+
behaviorLog: false #用于记录选手关键行为,默认不开启
140+
debug: #debug相关功能,生产环境请勿开启
141+
dockerOpDetail: false #开启可以查看容器构建和下发的问题
142+
noOriginCheck: false #开启禁用orgin检查,禁用csrf检查,禁用CSP
143+
dbOpDetail: false #开启查看所有数据库请求
144+
cookieExpiresSeconds: 3600 #cookie过期秒数,0表示不会过期,-1表示在关闭浏览器时过期
145+
email: #邮件服务配置
146+
host: smtp.example.com #邮件服务提供商服务器
147+
username: exampleUsername #邮件发送账号
148+
password: examplePassword #邮件发送账号密码(可能为授权码)
149+
challenge: #题目分数控制参数
150+
firstBloodReward: 0.1 #一血分数奖励比例
151+
secondBloodReward: 0.08 #二血分数奖励比例
152+
thirdBloodReward: 0.05 #三血分数奖励比例
153+
halfLife: 20 #题目分值减半所需解题人数
154+
kubernetes: #k8s集群配置参数
155+
portAllocBegin: 30000 #自动分配端口范围起点
156+
portAllocEnd: 31000 #自动分配端口终点
157+
username: xxxxxxxx #「不可修改」镜像仓库用户名
158+
password: xxxxxxxx #「不可修改」镜像仓库密码
159+
registryHost: xxx.xxx.xxx.xxx:5000 #「不可修改」镜像仓库地址(与平台一致)
160+
database: #数据库连接参数
161+
dsn: "..." #数据库连接配置,自动生成
162+
timelineFile: "resources/timeline.save" #「不建议修改」排行榜历史数据存储文件路径
157163
```
158164
159165
邮件服务配置为必要配置,用户重置和修改密码依赖于邮件服务,**未配置邮件服务将导致用户无法修改密码**
@@ -301,17 +307,24 @@ nodeConfig:
301307
302308
### 数据库导出或备份
303309
304-
提供exporter工具,使用以下命令编译
310+
命令行工具`ojtool`提供导出功能(需要在平台启动后使用)
305311

306-
```bash
307-
go build -tags DatabasePostgres -o expost server/exporter
312+
```shell
313+
./ojtool export [-dir <export folder>]
308314
```
309315

310-
切换到平台启动目录使用(也就是perpare运行初始化的目录)
316+
通过 `-dir` 指定导出到的目录,默认导出到`data`目录
317+
318+
### 用户批量导入
311319

312-
通过 `-dir` 指定导出到的目录
320+
命令行工具`ojtool`提供从csv文件批量导入用户的功能(需要在平台启动后使用)
321+
322+
```shell
323+
./ojtool load -welcome=<true/false> <csv file>
324+
```
313325

314-
##
326+
- `welcome`参数用于指定在导入用户后是否向用户发送初始化邮件
327+
- `<csv file>`为包含需要导入的用户数据的csv文件,格式为`<mail>,<username>`,不含表头
315328

316329
## 开发指南
317330

@@ -327,7 +340,7 @@ go build -tags DatabasePostgres -o expost server/exporter
327340

328341
### 接口相关
329342

330-
- GraphQL的schema文件定义在`server/src/resources/schema`目录下
343+
- GraphQL的schema文件定义在`server/services/schema.graphql`目录下
331344

332345
- 请求成功返回message 为空字符串(没有消息就是好消息)
333346

@@ -346,15 +359,9 @@ npm install #必要情况下可以删除package-lock.json
346359
npm run prepare
347360
```
348361

349-
构建前后端一体化可执行文件:依赖golang,在server目录下执行
362+
构建命令行工具和前后端一体化可执行文件:依赖golang,在server目录下执行
350363

351364
```shell
352365
go run build.go --postgres #postgres版本
353366
go run build.go --sqlite #sqlite版本暂时弃用
354367
```
355-
356-
构建prepare可执行文件
357-
358-
```shell
359-
go build prepare.go
360-
```

app/public/home.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ <h1>Welcome To Tp0t OJ</h1>
8383
11rr:;is-rr:i
8484

8585
</pre>
86-
<h4>Version 2.3-release</h4>
86+
<h4>Version 2.4-release</h4>
8787
</body>
8888
</html>

server/go.mod

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.17
44

55
require (
66
github.com/badoux/checkmail v1.2.1
7+
github.com/cheggaaa/pb/v3 v3.1.0
78
github.com/docker/distribution v2.8.1+incompatible
89
github.com/docker/docker v20.10.13+incompatible
910
github.com/dustin/go-humanize v1.0.0
@@ -30,12 +31,14 @@ require (
3031

3132
require (
3233
github.com/Microsoft/go-winio v0.5.1 // indirect
34+
github.com/VividCortex/ewma v1.1.1 // indirect
3335
github.com/andybalholm/brotli v1.0.0 // indirect
3436
github.com/containerd/containerd v1.6.1 // indirect
3537
github.com/davecgh/go-spew v1.1.1 // indirect
3638
github.com/docker/go-connections v0.4.0 // indirect
3739
github.com/docker/go-units v0.4.0 // indirect
3840
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
41+
github.com/fatih/color v1.10.0 // indirect
3942
github.com/glebarez/go-sqlite v1.17.3 // indirect
4043
github.com/go-logr/logr v1.2.2 // indirect
4144
github.com/gogo/protobuf v1.3.2 // indirect
@@ -56,22 +59,25 @@ require (
5659
github.com/jinzhu/now v1.1.4 // indirect
5760
github.com/json-iterator/go v1.1.12 // indirect
5861
github.com/klauspost/compress v1.11.13 // indirect
62+
github.com/mattn/go-colorable v0.1.8 // indirect
5963
github.com/mattn/go-isatty v0.0.14 // indirect
64+
github.com/mattn/go-runewidth v0.0.12 // indirect
6065
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
6166
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6267
github.com/modern-go/reflect2 v1.0.2 // indirect
6368
github.com/opencontainers/image-spec v1.0.2 // indirect
6469
github.com/opentracing/opentracing-go v1.1.0 // indirect
6570
github.com/pkg/errors v0.9.1 // indirect
6671
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
72+
github.com/rivo/uniseg v0.2.0 // indirect
6773
github.com/sirupsen/logrus v1.8.1 // indirect
6874
github.com/spf13/pflag v1.0.5 // indirect
6975
github.com/valyala/bytebufferpool v1.0.0 // indirect
7076
github.com/valyala/fasthttp v1.15.1 // indirect
7177
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
7278
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
7379
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
74-
golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 // indirect
80+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
7581
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
7682
google.golang.org/appengine v1.6.7 // indirect
7783
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect

0 commit comments

Comments
 (0)