showRunStrategy: false
default:
  strategy:
    runStrategy: 1
name: uploadCertToHost
title: 主机-部署证书到SSH主机
icon: line-md:uploading-loop
group: host
desc: SFTP上传证书到主机，然后SSH执行部署脚本命令
order: 1
input:
  cert:
    title: 域名证书
    helper: 请选择前置任务输出的域名证书
    component:
      name: output-selector
      from:
        - CertApply
        - CertApplyLego
        - CertApplyUpload
    required: true
    order: 0
  certType:
    title: 证书格式
    helper: 要部署的证书格式，支持pem、pfx、der、jks
    component:
      name: a-select
      options:
        - value: pem
          label: pem（crt），Nginx等大部分应用
        - value: pfx
          label: pfx，一般用于IIS
        - value: der
          label: der，一般用于Apache
        - value: jks
          label: jks，一般用于JAVA应用
        - value: one
          label: 证书私钥一体，crt+key简单合并为一个pem文件
    required: true
    order: 0
  crtPath:
    title: 证书保存路径
    helper: 填写应用原本的证书保存路径，路径要包含证书文件名，例如：/tmp/cert.pem
    component:
      placeholder: /root/deploy/nginx/full_chain.pem
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'pem';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  keyPath:
    title: 私钥保存路径
    helper: 需要有写入权限，路径要包含私钥文件名，例如：/tmp/cert.key
    component:
      placeholder: /root/deploy/nginx/cert.key
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'pem';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  icPath:
    title: 中间证书保存路径
    helper: 路径要包含文件名，一般情况传上面两个文件即可，极少数情况需要这个中间证书
    component:
      placeholder: /root/deploy/nginx/intermediate.pem
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'pem';
              })
            }
          
    rules:
      - type: filepath
    order: 0
  pfxPath:
    title: PFX证书保存路径
    helper: 填写应用原本的证书保存路径，路径要包含证书文件名，例如：D:\iis\cert.pfx
    component:
      placeholder: D:\iis\cert.pfx
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'pfx';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  derPath:
    title: DER证书保存路径
    helper: 填写应用原本的证书保存路径，路径要包含证书文件名，例如：/tmp/cert.der
    component:
      placeholder: /root/deploy/apache/cert.der
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'der';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  jksPath:
    title: jks证书保存路径
    helper: 填写应用原本的证书保存路径，路径要包含证书文件名，例如：/tmp/cert.jks
    component:
      placeholder: /root/deploy/java_app/cert.jks
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'jks';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  onePath:
    title: 一体证书保存路径
    helper: 填写应用原本的证书保存路径，路径要包含证书文件名，例如：/tmp/crt_key.pem
    component:
      placeholder: /root/deploy/app/crt_key.pem
    mergeScript: |2-

            return {
              show: ctx.compute(({form})=>{
                return form.certType === 'one';
              })
            }
          
    required: true
    rules:
      - type: filepath
    order: 0
  accessId:
    title: 主机登录配置
    helper: access授权
    component:
      name: access-selector
      type: ssh
    required: true
    order: 0
  uploadType:
    title: 上传方式
    helper: 选择上传方式，sftp或者scp
    value: sftp
    component:
      name: a-select
      options:
        - value: sftp
          label: sftp
        - value: scp
          label: scp
    required: true
    order: 0
  mkdirs:
    title: 自动创建远程目录
    helper: 是否自动创建远程目录,如果关闭则你需要自己确保远程目录存在
    value: true
    component:
      name: a-switch
      vModel: checked
    order: 0
  script:
    title: shell脚本命令
    component:
      name: a-textarea
      vModel: value
      rows: 6
    helper: |-
      上传后执行脚本命令，不填则不执行
      注意：如果目标主机是windows，且终端是cmd，系统会自动将多行命令通过“&&”连接成一行
    required: false
    order: 0
  injectEnv:
    title: 注入环境变量
    value: false
    component:
      name: a-switch
      vModel: checked
    helper: 是否将证书域名、路径等信息注入脚本执行环境变量中，具体的变量名称，可以运行后从日志中查看
    required: false
    order: 0
output:
  hostCrtPath:
    title: 证书保存路径
  hostKeyPath:
    title: 私钥保存路径
  hostIcPath:
    title: 中间证书保存路径
  hostPfxPath:
    title: PFX保存路径
  hostDerPath:
    title: DER保存路径
  hostJksPath:
    title: jks保存路径
  hostOnePath:
    title: 一体证书保存路径
type: builtIn
pluginType: deploy
scriptFilePath: ../../../plugins/plugin-host/plugin/upload-to-host/index.js
