feat: add preset scripts for qnap on deployment to ssh

This commit is contained in:
Fu Diwei 2025-06-11 22:55:07 +08:00
parent e4bfa90a77
commit c6dfe11bdb
3 changed files with 42 additions and 9 deletions

View File

@ -46,12 +46,13 @@ const initFormModel = (): DeployNodeConfigFormSSHConfigFieldValues => {
}; };
const initPresetScript = ( const initPresetScript = (
key: Parameters<typeof _initPresetScript>[0] | "sh_replace_synologydsm_ssl" | "sh_replace_fnos_ssl", key: Parameters<typeof _initPresetScript>[0] | "sh_replace_synologydsm_ssl" | "sh_replace_fnos_ssl" | "sh_replace_qnap_ssl",
params?: Parameters<typeof _initPresetScript>[1] params?: Parameters<typeof _initPresetScript>[1]
) => { ) => {
switch (key) { switch (key) {
case "sh_replace_synologydsm_ssl": case "sh_replace_synologydsm_ssl":
return `# *** 需要 root 权限 *** return `# *** 需要 root 权限 ***
# HTTPS
# https://github.com/catchdave/ssl-certs/blob/main/replace_synology_ssl_certs.sh # https://github.com/catchdave/ssl-certs/blob/main/replace_synology_ssl_certs.sh
# #
@ -129,6 +130,7 @@ info "Completed"
case "sh_replace_fnos_ssl": case "sh_replace_fnos_ssl":
return `# *** 需要 root 权限 *** return `# *** 需要 root 权限 ***
# HTTPS
# https://github.com/lfgyx/fnos_certificate_update/blob/main/src/update_cert.sh # https://github.com/lfgyx/fnos_certificate_update/blob/main/src/update_cert.sh
# #
@ -145,9 +147,9 @@ $domain = "<your-domain-name>" # 域名
cp -rf "$tmpFullchainPath" "$fnFullchainPath" cp -rf "$tmpFullchainPath" "$fnFullchainPath"
cp -rf "$tmpCertPath" "$fnCertPath" cp -rf "$tmpCertPath" "$fnCertPath"
cp -rf "$tmpKeyPath" "$fnKeyPath" cp -rf "$tmpKeyPath" "$fnKeyPath"
chmod 755 "$fnFullchainPath"
chmod 755 "$fnCertPath" chmod 755 "$fnCertPath"
chmod 755 "$fnKeyPath" chmod 755 "$fnKeyPath"
chmod 755 "$fnFullchainPath"
# #
NEW_EXPIRY_DATE=$(openssl x509 -enddate -noout -in "$fnCertPath" | sed "s/^.*=\\(.*\\)$/\\1/") NEW_EXPIRY_DATE=$(openssl x509 -enddate -noout -in "$fnCertPath" | sed "s/^.*=\\(.*\\)$/\\1/")
@ -159,6 +161,28 @@ systemctl restart webdav.service
systemctl restart smbftpd.service systemctl restart smbftpd.service
systemctl restart trim_nginx.service systemctl restart trim_nginx.service
`.trim(); `.trim();
case "sh_replace_qnap_ssl":
return `# *** 需要 root 权限 ***
# HTTPS
#
$tmpFullchainPath = "${params?.certPath || "<your-fullchain-cert-path>"}" #
$tmpKeyPath = "${params?.keyPath || "<your-key-path>"}" #
#
cp -rf "$tmpFullchainPath" /etc/stunnel/backup.cert
cp -rf "$tmpKeyPath" /etc/stunnel/backup.key
cat /etc/stunnel/backup.key > /etc/stunnel/stunnel.pem
cat /etc/stunnel/backup.cert >> /etc/stunnel/stunnel.pem
chmod 600 /etc/stunnel/backup.cert
chmod 600 /etc/stunnel/backup.key
chmod 600 /etc/stunnel/stunnel.pem
#
/etc/init.d/stunnel.sh restart
/etc/init.d/reverse_proxy.sh reload
`.trim();
} }
return _initPresetScript(key as Parameters<typeof _initPresetScript>[0], params); return _initPresetScript(key as Parameters<typeof _initPresetScript>[0], params);
@ -286,6 +310,7 @@ const DeployNodeConfigFormSSHConfig = ({ form: formInst, formName, disabled, ini
case "sh_replace_synologydsm_ssl": case "sh_replace_synologydsm_ssl":
case "sh_replace_fnos_ssl": case "sh_replace_fnos_ssl":
case "sh_replace_qnap_ssl":
{ {
const presetScriptParams = { const presetScriptParams = {
certPath: formInst.getFieldValue("certPath"), certPath: formInst.getFieldValue("certPath"),
@ -461,13 +486,19 @@ const DeployNodeConfigFormSSHConfig = ({ form: formInst, formName, disabled, ini
<div className="text-right"> <div className="text-right">
<Dropdown <Dropdown
menu={{ menu={{
items: ["sh_reload_nginx", "sh_replace_synologydsm_ssl", "sh_replace_fnos_ssl", "ps_binding_iis", "ps_binding_netsh", "ps_binding_rdp"].map( items: [
(key) => ({ "sh_reload_nginx",
"sh_replace_synologydsm_ssl",
"sh_replace_fnos_ssl",
"sh_replace_qnap_ssl",
"ps_binding_iis",
"ps_binding_netsh",
"ps_binding_rdp",
].map((key) => ({
key, key,
label: t(`workflow_node.deploy.form.ssh_preset_scripts.option.${key}.label`), label: t(`workflow_node.deploy.form.ssh_preset_scripts.option.${key}.label`),
onClick: () => handlePresetPostScriptClick(key), onClick: () => handlePresetPostScriptClick(key),
}) })),
),
}} }}
trigger={["click"]} trigger={["click"]}
> >

View File

@ -626,6 +626,7 @@
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_reload_nginx.label": "POSIX Bash - Reload nginx", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_reload_nginx.label": "POSIX Bash - Reload nginx",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_synologydsm_ssl.label": "POSIX Bash - Replace SynologyDSM SSL certificate", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_synologydsm_ssl.label": "POSIX Bash - Replace SynologyDSM SSL certificate",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_fnos_ssl.label": "POSIX Bash - Replace fnOS SSL certificate", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_fnos_ssl.label": "POSIX Bash - Replace fnOS SSL certificate",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_qnap_ssl.label": "POSIX Bash - Replace QNAP SSL certificate",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_iis.label": "PowerShell - Binding IIS", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_iis.label": "PowerShell - Binding IIS",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_netsh.label": "PowerShell - Binding netsh", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_netsh.label": "PowerShell - Binding netsh",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_rdp.label": "PowerShell - Binding RDP", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_rdp.label": "PowerShell - Binding RDP",

View File

@ -625,6 +625,7 @@
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_reload_nginx.label": "POSIX Bash - 重启 nginx 进程", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_reload_nginx.label": "POSIX Bash - 重启 nginx 进程",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_synologydsm_ssl.label": "POSIX Bash - 替换群晖 DSM 证书", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_synologydsm_ssl.label": "POSIX Bash - 替换群晖 DSM 证书",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_fnos_ssl.label": "POSIX Bash - 替换飞牛 fnOS 证书", "workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_fnos_ssl.label": "POSIX Bash - 替换飞牛 fnOS 证书",
"workflow_node.deploy.form.ssh_preset_scripts.option.sh_replace_qnap_ssl.label": "POSIX Bash - 替换威联通 QNAP 证书",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_iis.label": "PowerShell - 导入并绑定到 IIS", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_iis.label": "PowerShell - 导入并绑定到 IIS",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_netsh.label": "PowerShell - 导入并绑定到 netsh", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_netsh.label": "PowerShell - 导入并绑定到 netsh",
"workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_rdp.label": "PowerShell - 导入并绑定到 RDP", "workflow_node.deploy.form.ssh_preset_scripts.option.ps_binding_rdp.label": "PowerShell - 导入并绑定到 RDP",