mirror of
https://github.com/certd/certd.git
synced 2026-07-30 01:07:38 +08:00
chore: format
This commit is contained in:
@@ -1 +1 @@
|
||||
export * from './plugins/index.js';
|
||||
export * from "./plugins/index.js";
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './plugin-qnap.js';
|
||||
export * from "./plugin-qnap.js";
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertInfo } from "@certd/plugin-cert";
|
||||
import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
|
||||
import { tmpdir } from 'node:os';
|
||||
import fs from 'fs';
|
||||
import { SshAccess, SshClient } from '../../plugin-lib/ssh/index.js';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
import { tmpdir } from "node:os";
|
||||
import fs from "fs";
|
||||
import { SshAccess, SshClient } from "../../plugin-lib/ssh/index.js";
|
||||
import { CertApplyPluginNames } from "@certd/plugin-cert";
|
||||
@IsTaskPlugin({
|
||||
name: 'QnapDeploy',
|
||||
title: '威联通-部署证书到威联通',
|
||||
icon: 'svg:icon-qnap',
|
||||
name: "QnapDeploy",
|
||||
title: "威联通-部署证书到威联通",
|
||||
icon: "svg:icon-qnap",
|
||||
group: pluginGroups.panel.key,
|
||||
desc: '部署证书到qnap',
|
||||
desc: "部署证书到qnap",
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
@@ -21,10 +21,10 @@ import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
export class QnapDeploy extends AbstractPlusTaskPlugin {
|
||||
//证书选择,此项必须要有
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
helper: '请选择前置任务输出的域名证书',
|
||||
title: "域名证书",
|
||||
helper: "请选择前置任务输出的域名证书",
|
||||
component: {
|
||||
name: 'output-selector',
|
||||
name: "output-selector",
|
||||
from: [...CertApplyPluginNames],
|
||||
},
|
||||
required: true,
|
||||
@@ -33,11 +33,11 @@ export class QnapDeploy extends AbstractPlusTaskPlugin {
|
||||
|
||||
//授权选择框
|
||||
@TaskInput({
|
||||
title: 'ssh登录授权',
|
||||
helper: 'ssh登录授权',
|
||||
title: "ssh登录授权",
|
||||
helper: "ssh登录授权",
|
||||
component: {
|
||||
name: 'access-selector',
|
||||
type: 'ssh',
|
||||
name: "access-selector",
|
||||
type: "ssh",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
@@ -48,16 +48,16 @@ export class QnapDeploy extends AbstractPlusTaskPlugin {
|
||||
const { cert, accessId } = this;
|
||||
|
||||
if (!accessId) {
|
||||
throw new Error('主机登录授权配置不能为空');
|
||||
throw new Error("主机登录授权配置不能为空");
|
||||
}
|
||||
|
||||
const connectConf = await this.getAccess<SshAccess>(accessId);
|
||||
const sshClient = new SshClient(this.logger);
|
||||
//合并证书
|
||||
const newCert = cert.key + '\n' + cert.crt;
|
||||
const tmpCertPath = tmpdir() + '/certd/cert.pem';
|
||||
const newCert = cert.key + "\n" + cert.crt;
|
||||
const tmpCertPath = tmpdir() + "/certd/cert.pem";
|
||||
fs.writeFileSync(tmpCertPath, newCert);
|
||||
const targetPath = '/etc/stunnel/stunnel.pem';
|
||||
const targetPath = "/etc/stunnel/stunnel.pem";
|
||||
this.logger.info(`准备上传证书到服务器:${targetPath}`);
|
||||
|
||||
const transports: any = [];
|
||||
@@ -65,21 +65,21 @@ export class QnapDeploy extends AbstractPlusTaskPlugin {
|
||||
localPath: tmpCertPath,
|
||||
remotePath: targetPath,
|
||||
});
|
||||
this.logger.info('开始上传文件到服务器');
|
||||
this.logger.info("开始上传文件到服务器");
|
||||
await sshClient.uploadFiles({
|
||||
connectConf,
|
||||
transports,
|
||||
mkdirs: true,
|
||||
});
|
||||
this.logger.info('上传文件到服务器成功');
|
||||
this.logger.info("上传文件到服务器成功");
|
||||
//重启服务
|
||||
const restartCmd = '/bin/bash /etc/init.d/stunnel.sh restart';
|
||||
this.logger.info('重启stunnel服务');
|
||||
const restartCmd = "/bin/bash /etc/init.d/stunnel.sh restart";
|
||||
this.logger.info("重启stunnel服务");
|
||||
await sshClient.exec({
|
||||
connectConf,
|
||||
script: [restartCmd],
|
||||
});
|
||||
this.logger.info('执行成功');
|
||||
this.logger.info("执行成功");
|
||||
}
|
||||
}
|
||||
new QnapDeploy();
|
||||
|
||||
Reference in New Issue
Block a user