mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
fix: 增加权限相关helper说明
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user