@@ -57,44 +57,49 @@ sudo systemctl restart docker
57
57
58
58
** 由于SQLite对于多并发读写并不友好,所以在完成优化和测试前不再推荐使用SQLite,默认数据库更换为PostgresSQL**
59
59
60
- 根据系统架构在release页面获取 prepare 二进制文件,如果所用系统架构没有对应的release,请参照contribution自行build
60
+ 根据系统架构在release页面获取 ojtool 二进制文件,如果所用系统架构没有对应的release,请参照contribution自行build
61
61
62
62
63
63
64
64
``` 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
67
67
```
68
68
69
69
** 中国用户请使用Mirror的参数执行**
70
70
71
- 执行` prepare ` 会在当前目录下生成配置文件目录` resources ` ,安装完成后目录应该如下所示,其中` https.crt ` 、` https.key ` 文件不会默认生成。平台启动时会自动检测这两个文件,如果存在,就自动启用https模式,否则采用http模式
71
+ 执行` ojtool prepare` 会在当前目录下生成配置文件目录` resources ` ,安装完成后目录应该如下所示,其中` https.crt ` 、` https.key ` 文件不会默认生成。平台启动时会自动检测这两个文件,如果存在,就自动启用https模式,否则采用http模式
72
72
73
73
` home.html ` 为提供了主页面定制化的功能,在前后端一体化的单文件模式下,如果平台` resources ` 目录中存在` home.html ` 会将其作为平台主页展示
74
74
75
75
```
76
76
.
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 #「配置完毕后启动」启动脚本
98
103
```
99
104
100
105
然后使用 ` start.sh ` 启动平台
@@ -124,36 +129,37 @@ To uninstall K3s from an agent node, run:
124
129
#### 平台配置说明
125
130
126
131
``` 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" # 「不建议修改」排行榜历史数据存储文件路径
157
163
` ` `
158
164
159
165
邮件服务配置为必要配置,用户重置和修改密码依赖于邮件服务,**未配置邮件服务将导致用户无法修改密码**
@@ -301,17 +307,24 @@ nodeConfig:
301
307
302
308
### 数据库导出或备份
303
309
304
- 提供exporter工具,使用以下命令编译
310
+ 命令行工具 ` ojtool`提供导出功能(需要在平台启动后使用)
305
311
306
- ` ` ` bash
307
- go build -tags DatabasePostgres -o expost server/exporter
312
+ ` ` ` shell
313
+ ./ojtool export [-dir <export folder>]
308
314
` ` `
309
315
310
- 切换到平台启动目录使用(也就是perpare运行初始化的目录)
316
+ 通过 `-dir` 指定导出到的目录,默认导出到`data`目录
317
+
318
+ # ## 用户批量导入
311
319
312
- 通过 ` -dir ` 指定导出到的目录
320
+ 命令行工具`ojtool`提供从csv文件批量导入用户的功能(需要在平台启动后使用)
321
+
322
+ ` ` ` shell
323
+ ./ojtool load -welcome=<true/false> <csv file>
324
+ ` ` `
313
325
314
- ##
326
+ - ` welcome` 参数用于指定在导入用户后是否向用户发送初始化邮件
327
+ - ` <csv file>` 为包含需要导入的用户数据的csv文件,格式为`<mail>,<username>`,不含表头
315
328
316
329
# # 开发指南
317
330
@@ -327,7 +340,7 @@ go build -tags DatabasePostgres -o expost server/exporter
327
340
328
341
# ## 接口相关
329
342
330
- - GraphQL的schema文件定义在` server/src/resources/ schema ` 目录下
343
+ - GraphQL的schema文件定义在`server/services/ schema.graphql `目录下
331
344
332
345
- 请求成功返回message 为空字符串(没有消息就是好消息)
333
346
@@ -346,15 +359,9 @@ npm install #必要情况下可以删除package-lock.json
346
359
npm run prepare
347
360
` ` `
348
361
349
- 构建前后端一体化可执行文件 :依赖golang,在server目录下执行
362
+ 构建命令行工具和前后端一体化可执行文件 :依赖golang,在server目录下执行
350
363
351
364
` ` ` shell
352
365
go run build.go --postgres #postgres版本
353
366
go run build.go --sqlite #sqlite版本暂时弃用
354
367
` ` `
355
-
356
- 构建prepare可执行文件
357
-
358
- ``` shell
359
- go build prepare.go
360
- ```
0 commit comments