mirror of https://github.com/certd/certd
fix: 增加权限相关helper说明
parent
836d18f07e
commit
4304c9443a
|
@ -11,6 +11,7 @@ export class AliyunAccess {
|
||||||
component: {
|
component: {
|
||||||
placeholder: "accessKeyId",
|
placeholder: "accessKeyId",
|
||||||
},
|
},
|
||||||
|
helper:"注意:证书申请,需要dns解析权限;其他阿里云插件,也需要对应的权限,比如证书上传需要证书管理权限",
|
||||||
required: true,
|
required: true,
|
||||||
})
|
})
|
||||||
accessKeyId = "";
|
accessKeyId = "";
|
||||||
|
|
|
@ -19,8 +19,8 @@ export class SshClient {
|
||||||
}
|
}
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
uploadFiles(options: { connectConf: any; transports: any; sudo: boolean }) {
|
uploadFiles(options: { connectConf: any; transports: any; }) {
|
||||||
const { connectConf, transports, sudo } = options;
|
const { connectConf, transports } = options;
|
||||||
const conn = new ssh2.Client();
|
const conn = new ssh2.Client();
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -35,8 +35,7 @@ export class SshClient {
|
||||||
try {
|
try {
|
||||||
for (const transport of transports) {
|
for (const transport of transports) {
|
||||||
this.logger.info("上传文件:", JSON.stringify(transport));
|
this.logger.info("上传文件:", JSON.stringify(transport));
|
||||||
const sudoCmd = sudo ? "sudo" : "";
|
await this.exec({ connectConf, script: `mkdir -p ${path.dirname(transport.remotePath)} ` });
|
||||||
await this.exec({ connectConf, script: `${sudoCmd} mkdir -p ${path.dirname(transport.remotePath)} ` });
|
|
||||||
await this.fastPut({ sftp, ...transport });
|
await this.fastPut({ sftp, ...transport });
|
||||||
}
|
}
|
||||||
resolve({});
|
resolve({});
|
||||||
|
|
|
@ -15,10 +15,18 @@ import * as fs from "fs";
|
||||||
export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
title: "证书保存路径",
|
title: "证书保存路径",
|
||||||
|
helper: "需要有写入权限,路径要包含证书文件名",
|
||||||
|
component:{
|
||||||
|
placeholder:"/root/deploy/nginx/cert.crt",
|
||||||
|
}
|
||||||
})
|
})
|
||||||
crtPath!: string;
|
crtPath!: string;
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
title: "私钥保存路径",
|
title: "私钥保存路径",
|
||||||
|
helper: "需要有写入权限,路径要包含证书文件名",
|
||||||
|
component:{
|
||||||
|
placeholder:"/root/deploy/nginx/cert.crt",
|
||||||
|
}
|
||||||
})
|
})
|
||||||
keyPath!: string;
|
keyPath!: string;
|
||||||
@TaskInput({
|
@TaskInput({
|
||||||
|
@ -40,14 +48,6 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
rules: [{ required: true, message: "此项必填" }],
|
rules: [{ required: true, message: "此项必填" }],
|
||||||
})
|
})
|
||||||
accessId!: string;
|
accessId!: string;
|
||||||
@TaskInput({
|
|
||||||
title: "是否sudo",
|
|
||||||
component: {
|
|
||||||
name: "a-checkbox",
|
|
||||||
vModel: "checked",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
sudo!: boolean;
|
|
||||||
|
|
||||||
@TaskOutput({
|
@TaskOutput({
|
||||||
title: "证书保存路径",
|
title: "证书保存路径",
|
||||||
|
@ -67,7 +67,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
this.logger = this.ctx.logger;
|
this.logger = this.ctx.logger;
|
||||||
}
|
}
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<void> {
|
||||||
const { crtPath, keyPath, cert, accessId, sudo } = this;
|
const { crtPath, keyPath, cert, accessId } = this;
|
||||||
const certReader = new CertReader(cert);
|
const certReader = new CertReader(cert);
|
||||||
const connectConf = await this.accessService.getById(accessId);
|
const connectConf = await this.accessService.getById(accessId);
|
||||||
const sshClient = new SshClient(this.logger);
|
const sshClient = new SshClient(this.logger);
|
||||||
|
@ -87,7 +87,6 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
remotePath: keyPath,
|
remotePath: keyPath,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sudo,
|
|
||||||
});
|
});
|
||||||
this.logger.info("证书上传成功:crtPath=", crtPath, ",keyPath=", keyPath);
|
this.logger.info("证书上传成功:crtPath=", crtPath, ",keyPath=", keyPath);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue