mirror of https://github.com/certd/certd
perf: ssh配置增加脚本类型设置,bash还是sh
parent
f41f7eb2ad
commit
ae41c6038b
|
@ -64,6 +64,22 @@ export class SshAccess extends BaseAccess {
|
|||
})
|
||||
passphrase!: string;
|
||||
|
||||
@AccessInput({
|
||||
title: "脚本类型",
|
||||
helper: "bash 、sh 、fish",
|
||||
component: {
|
||||
name: "a-select",
|
||||
vModel: "value",
|
||||
options: [
|
||||
{ value: "default", label: "默认" },
|
||||
{ value: "sh", label: "sh" },
|
||||
{ value: "bash", label: "bash" },
|
||||
{ value: "fish", label: "fish(不支持set -e)" },
|
||||
],
|
||||
},
|
||||
})
|
||||
scriptType: string;
|
||||
|
||||
@AccessInput({
|
||||
title: "伪终端",
|
||||
helper: "如果登录报错:all authentication methods failed,可以尝试开启伪终端模式进行keyboard-interactive方式登录\n开启后对日志输出有一定的影响",
|
||||
|
|
|
@ -543,8 +543,16 @@ export class SshClient {
|
|||
}
|
||||
}
|
||||
|
||||
if (isLinux && options.stopOnError !== false) {
|
||||
script = "set -e\n" + script;
|
||||
if (isLinux) {
|
||||
if (options.connectConf.scriptType == "bash") {
|
||||
script = "#!/usr/bin/env bash \n" + script;
|
||||
} else if (options.connectConf.scriptType == "sh") {
|
||||
script = "#!/bin/sh\n" + script;
|
||||
}
|
||||
|
||||
if (options.connectConf.scriptType != "fish" && options.stopOnError !== false) {
|
||||
script = "set -e\n" + script;
|
||||
}
|
||||
}
|
||||
|
||||
return await conn.exec(script as string, { throwOnStdErr });
|
||||
|
|
Loading…
Reference in New Issue