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