ssh 安装插件端新增配置脚本执行权限参数

This commit is contained in:
bwcx_jzy 2021-09-27 21:43:44 +08:00
parent 188631bb0a
commit 1e4f3f99e6
2 changed files with 27 additions and 9 deletions

View File

@ -130,16 +130,14 @@ public class SshInstallAgentController extends BaseServerController {
sshService.uploadDir(sshModel, path, outFle);
//
String shPtah = FileUtil.normalize(path + "/" + Type.Agent.name() + ".sh");
String command = StrUtil.format("sh {} start upgrade", shPtah);
String chmod = getParameter("chmod");
if (StrUtil.isEmpty(chmod)) {
chmod = StrUtil.EMPTY;
} else {
chmod = StrUtil.format("{} {} && ", chmod, shPtah);
}
String command = StrUtil.format("{}sh {} start upgrade", chmod, shPtah);
String result = sshService.exec(sshModel, command);
// 休眠10秒
/*Thread.sleep(15 * 1000);
if (StrUtil.isEmpty(nodeModel.getLoginName()) || StrUtil.isEmpty(nodeModel.getLoginPwd())) {
String error = this.getAuthorize(sshModel, nodeModel, path);
if (error != null) {
return error;
}
}*/
// 休眠 5 , 尝试 5
int waitCount = getParameterInt("waitCount", 5);
waitCount = Math.max(waitCount, 5);

View File

@ -132,6 +132,25 @@
<a-form-model-item label="安装路径" prop="path">
<a-input v-model="tempNode.path" placeholder="安装路径" />
</a-form-model-item>
<a-form-model-item label="脚本权限" prop="chmod">
<a-input v-model="tempNode.chmod" placeholder="非 root 状态下,需要给脚本文件添加权限的命令">
<a-tooltip slot="suffix">
<template slot="title">
<div> root 状态下需要给脚本文件添加权限的命令</div>
<div><br /></div>
<div>
例如
<ul>
<li>chmod 755</li>
<li>chmod u=rwx</li>
<li>chmod u+x</li>
</ul>
</div>
</template>
<a-icon type="question-circle" theme="filled" />
</a-tooltip>
</a-input>
</a-form-model-item>
<a-form-model-item label="等待次数" prop="waitCount">
<a-input v-model="tempNode.waitCount" placeholder="上传插件端后,等待插件端启动成功次数1次5秒。默认5次" />
</a-form-model-item>
@ -507,6 +526,7 @@ export default {
formData.append("nodeData", JSON.stringify({ ...this.tempNode }));
formData.append("path", this.tempNode.path);
formData.append("waitCount", this.tempNode.waitCount);
formData.append("chmod", this.tempNode.chmod);
//
installAgentNode(formData).then((res) => {
if (res.code === 200) {