mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-04 12:58:24 +08:00
feat(fix) 在线升级执行脚本、脚本模版等兼容 debian
This commit is contained in:
parent
37731c12c1
commit
b2cba06872
@ -14,6 +14,7 @@
|
|||||||
3. 【server】在线构建 ssh 发布选择授权目录切换不生效问题(感谢@天天)
|
3. 【server】在线构建 ssh 发布选择授权目录切换不生效问题(感谢@天天)
|
||||||
4. 【server】在线构建本地构建命令不能换行问题(感谢@华仔)
|
4. 【server】在线构建本地构建命令不能换行问题(感谢@华仔)
|
||||||
5. 【server】日志弹窗新增行号
|
5. 【server】日志弹窗新增行号
|
||||||
|
6. 【server】在线升级执行脚本、脚本模版等兼容 `debian` (感谢@wxyShine [Gitee issues I4UQBD](https://gitee.com/dromara/Jpom/issues/I4UQBD) )
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import cn.hutool.core.io.IoUtil;
|
|||||||
import cn.hutool.core.io.LineHandler;
|
import cn.hutool.core.io.LineHandler;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.system.SystemUtil;
|
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||||
import io.jpom.model.data.DslYmlDto;
|
import io.jpom.model.data.DslYmlDto;
|
||||||
@ -75,9 +74,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable {
|
|||||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||||
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
||||||
command.add(0, script);
|
command.add(0, script);
|
||||||
if (SystemUtil.getOsInfo().isLinux() || SystemUtil.getOsInfo().isMac()) {
|
command.add(0, CommandUtil.EXECUTE_PREFIX);
|
||||||
command.add(0, CommandUtil.SUFFIX);
|
|
||||||
}
|
|
||||||
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
||||||
if (environment != null) {
|
if (environment != null) {
|
||||||
processBuilder.environment().putAll(environment);
|
processBuilder.environment().putAll(environment);
|
||||||
|
@ -30,7 +30,6 @@ import cn.hutool.core.io.LineHandler;
|
|||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.system.SystemUtil;
|
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.JsonMessage;
|
import cn.jiangzeyin.common.JsonMessage;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@ -72,9 +71,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
|
|||||||
processBuilder = new ProcessBuilder();
|
processBuilder = new ProcessBuilder();
|
||||||
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
||||||
command.add(0, script);
|
command.add(0, script);
|
||||||
if (SystemUtil.getOsInfo().isLinux() || SystemUtil.getOsInfo().isMac()) {
|
command.add(0, CommandUtil.EXECUTE_PREFIX);
|
||||||
command.add(0, CommandUtil.SUFFIX);
|
|
||||||
}
|
|
||||||
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
||||||
processBuilder.redirectErrorStream(true);
|
processBuilder.redirectErrorStream(true);
|
||||||
processBuilder.command(command);
|
processBuilder.command(command);
|
||||||
|
@ -196,9 +196,7 @@ public class JpomApplication extends ApplicationBuilder {
|
|||||||
// Waiting for method caller,For example, the interface response
|
// Waiting for method caller,For example, the interface response
|
||||||
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
||||||
try {
|
try {
|
||||||
String command = SystemUtil.getOsInfo().isWindows() ? StrUtil.EMPTY : CommandUtil.SUFFIX;
|
String command = CommandUtil.EXECUTE_PREFIX + StrUtil.SPACE + FileUtil.getAbsolutePath(scriptFile) + " restart upgrade";
|
||||||
|
|
||||||
command += " " + FileUtil.getAbsolutePath(scriptFile) + " restart upgrade";
|
|
||||||
if (SystemUtil.getOsInfo().isWindows()) {
|
if (SystemUtil.getOsInfo().isWindows()) {
|
||||||
CommandUtil.execSystemCommand(command, scriptFile.getParentFile());
|
CommandUtil.execSystemCommand(command, scriptFile.getParentFile());
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,7 +23,10 @@
|
|||||||
package io.jpom.util;
|
package io.jpom.util;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.util.*;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.RuntimeUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.system.SystemUtil;
|
import cn.hutool.system.SystemUtil;
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import io.jpom.system.ExtConfigBean;
|
import io.jpom.system.ExtConfigBean;
|
||||||
@ -50,6 +53,10 @@ public class CommandUtil {
|
|||||||
* 文件后缀
|
* 文件后缀
|
||||||
*/
|
*/
|
||||||
public static final String SUFFIX;
|
public static final String SUFFIX;
|
||||||
|
/**
|
||||||
|
* 执行前缀
|
||||||
|
*/
|
||||||
|
public static final String EXECUTE_PREFIX;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (SystemUtil.getOsInfo().isLinux()) {
|
if (SystemUtil.getOsInfo().isLinux()) {
|
||||||
@ -63,13 +70,13 @@ public class CommandUtil {
|
|||||||
COMMAND.add("cmd");
|
COMMAND.add("cmd");
|
||||||
COMMAND.add("/c");
|
COMMAND.add("/c");
|
||||||
}
|
}
|
||||||
/**
|
//
|
||||||
* 文件后缀
|
|
||||||
*/
|
|
||||||
if (SystemUtil.getOsInfo().isWindows()) {
|
if (SystemUtil.getOsInfo().isWindows()) {
|
||||||
SUFFIX = "bat";
|
SUFFIX = "bat";
|
||||||
|
EXECUTE_PREFIX = StrUtil.EMPTY;
|
||||||
} else {
|
} else {
|
||||||
SUFFIX = "sh";
|
SUFFIX = "sh";
|
||||||
|
EXECUTE_PREFIX = "bash";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ import cn.hutool.crypto.SecureUtil;
|
|||||||
import cn.hutool.extra.ssh.JschUtil;
|
import cn.hutool.extra.ssh.JschUtil;
|
||||||
import cn.hutool.extra.ssh.Sftp;
|
import cn.hutool.extra.ssh.Sftp;
|
||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
import cn.hutool.system.SystemUtil;
|
|
||||||
import cn.jiangzeyin.common.JsonMessage;
|
import cn.jiangzeyin.common.JsonMessage;
|
||||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@ -336,8 +335,8 @@ public class ReleaseManage implements Runnable {
|
|||||||
File commandFile = FileUtil.file(tempPath, "build", this.buildExtraModule.getId() + StrUtil.DOT + CommandUtil.SUFFIX);
|
File commandFile = FileUtil.file(tempPath, "build", this.buildExtraModule.getId() + StrUtil.DOT + CommandUtil.SUFFIX);
|
||||||
FileUtil.writeUtf8String(stringBuilder.toString(), commandFile);
|
FileUtil.writeUtf8String(stringBuilder.toString(), commandFile);
|
||||||
//
|
//
|
||||||
command = SystemUtil.getOsInfo().isWindows() ? StrUtil.EMPTY : CommandUtil.SUFFIX;
|
// command = SystemUtil.getOsInfo().isWindows() ? StrUtil.EMPTY : CommandUtil.SUFFIX;
|
||||||
command += " " + FileUtil.getAbsolutePath(commandFile);
|
command = CommandUtil.EXECUTE_PREFIX + StrUtil.SPACE + FileUtil.getAbsolutePath(commandFile);
|
||||||
String result = CommandUtil.execSystemCommand(command);
|
String result = CommandUtil.execSystemCommand(command);
|
||||||
logRecorder.info(result);
|
logRecorder.info(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -30,7 +30,6 @@ import cn.hutool.core.io.LineHandler;
|
|||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.system.SystemUtil;
|
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.JsonMessage;
|
import cn.jiangzeyin.common.JsonMessage;
|
||||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||||
@ -78,9 +77,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
|
|||||||
processBuilder = new ProcessBuilder();
|
processBuilder = new ProcessBuilder();
|
||||||
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
|
||||||
command.add(0, script);
|
command.add(0, script);
|
||||||
if (SystemUtil.getOsInfo().isLinux() || SystemUtil.getOsInfo().isMac()) {
|
command.add(0, CommandUtil.EXECUTE_PREFIX);
|
||||||
command.add(0, CommandUtil.SUFFIX);
|
|
||||||
}
|
|
||||||
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
|
||||||
processBuilder.redirectErrorStream(true);
|
processBuilder.redirectErrorStream(true);
|
||||||
processBuilder.command(command);
|
processBuilder.command(command);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="full-content">
|
<div class="full-content">
|
||||||
<!-- 数据表格 -->
|
<!-- 数据表格 -->
|
||||||
<a-table :data-source="list" :columns="columns" @change="changePage" :pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false" bordered rowKey="id">
|
<a-table :data-source="list" size="middle" :columns="columns" @change="changePage" :pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false" bordered rowKey="id">
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-input v-model="listQuery['%name%']" placeholder="名称" @pressEnter="loadData" allowClear class="search-input-item" />
|
<a-input v-model="listQuery['%name%']" placeholder="名称" @pressEnter="loadData" allowClear class="search-input-item" />
|
||||||
@ -46,9 +46,9 @@
|
|||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<template slot="operation" slot-scope="text, record">
|
<template slot="operation" slot-scope="text, record">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button type="primary" @click="handleExec(record)">执行</a-button>
|
<a-button size="small" type="primary" @click="handleExec(record)">执行</a-button>
|
||||||
<a-button type="primary" @click="handleEdit(record)">编辑</a-button>
|
<a-button size="small" type="primary" @click="handleEdit(record)">编辑</a-button>
|
||||||
<a-button type="danger" @click="handleDelete(record)">删除</a-button>
|
<a-button size="small" type="danger" @click="handleDelete(record)">删除</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
@ -137,7 +137,7 @@ export default {
|
|||||||
{ title: "修改时间", dataIndex: "modifyTimeMillis", sorter: true, width: 170, ellipsis: true, scopedSlots: { customRender: "modifyTimeMillis" } },
|
{ title: "修改时间", dataIndex: "modifyTimeMillis", sorter: true, width: 170, ellipsis: true, scopedSlots: { customRender: "modifyTimeMillis" } },
|
||||||
{ title: "修改人", dataIndex: "modifyUser", ellipsis: true, scopedSlots: { customRender: "modifyUser" }, width: 120 },
|
{ title: "修改人", dataIndex: "modifyUser", ellipsis: true, scopedSlots: { customRender: "modifyUser" }, width: 120 },
|
||||||
{ title: "最后操作人", dataIndex: "lastRunUser", ellipsis: true, scopedSlots: { customRender: "lastRunUser" } },
|
{ title: "最后操作人", dataIndex: "lastRunUser", ellipsis: true, scopedSlots: { customRender: "lastRunUser" } },
|
||||||
{ title: "操作", dataIndex: "operation", scopedSlots: { customRender: "operation" }, width: 260 },
|
{ title: "操作", dataIndex: "operation", scopedSlots: { customRender: "operation" }, width: 180 },
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: "Please input Script name", trigger: "blur" }],
|
name: [{ required: true, message: "Please input Script name", trigger: "blur" }],
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<a-table
|
<a-table
|
||||||
:data-source="commandList"
|
:data-source="commandList"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
size="middle"
|
||||||
bordered
|
bordered
|
||||||
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
|
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
|
||||||
@change="changePage"
|
@change="changePage"
|
||||||
@ -43,9 +44,9 @@
|
|||||||
|
|
||||||
<template slot="operation" slot-scope="text, record">
|
<template slot="operation" slot-scope="text, record">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button type="primary" @click="handleEdit(record)">编辑</a-button>
|
<a-button size="small" type="primary" @click="handleEdit(record)">编辑</a-button>
|
||||||
<a-button type="primary" @click="handleExecute(record)">执行</a-button>
|
<a-button size="small" type="primary" @click="handleExecute(record)">执行</a-button>
|
||||||
<a-button type="danger" @click="handleDelete(record)">删除</a-button>
|
<a-button size="small" type="danger" @click="handleDelete(record)">删除</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
@ -204,7 +205,7 @@ export default {
|
|||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
scopedSlots: { customRender: "modifyUser" },
|
scopedSlots: { customRender: "modifyUser" },
|
||||||
},
|
},
|
||||||
{ title: "操作", dataIndex: "operation", scopedSlots: { customRender: "operation" }, width: 250 },
|
{ title: "操作", dataIndex: "operation", scopedSlots: { customRender: "operation" }, width: 180 },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<a-table
|
<a-table
|
||||||
:data-source="list"
|
:data-source="list"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
size="middle"
|
||||||
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
|
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
|
||||||
@change="changePage"
|
@change="changePage"
|
||||||
bordered
|
bordered
|
||||||
@ -42,7 +43,7 @@
|
|||||||
<div v-if="sshAgentInfo[record.id]">
|
<div v-if="sshAgentInfo[record.id]">
|
||||||
<div v-if="sshAgentInfo[record.id].javaVersion">
|
<div v-if="sshAgentInfo[record.id].javaVersion">
|
||||||
<a-tooltip v-if="sshAgentInfo[record.id].nodeId" placement="topLeft" :title="`节点名称:${sshAgentInfo[record.id].nodeName}`">
|
<a-tooltip v-if="sshAgentInfo[record.id].nodeId" placement="topLeft" :title="`节点名称:${sshAgentInfo[record.id].nodeName}`">
|
||||||
<a-button style="width: 90px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis" type="" @click="toNode(sshAgentInfo[record.id].nodeId)">
|
<a-button size="small" style="width: 90px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis" type="" @click="toNode(sshAgentInfo[record.id].nodeId)">
|
||||||
{{ sshAgentInfo[record.id].nodeName }}
|
{{ sshAgentInfo[record.id].nodeName }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
@ -54,7 +55,7 @@
|
|||||||
placement="topLeft"
|
placement="topLeft"
|
||||||
:title="`${sshAgentInfo[record.id].pid > 0 ? 'ssh 中已经运行了插件端进程ID:' + sshAgentInfo[record.id].pid : '点击快速安装插件端,java :' + sshAgentInfo[record.id].javaVersion}`"
|
:title="`${sshAgentInfo[record.id].pid > 0 ? 'ssh 中已经运行了插件端进程ID:' + sshAgentInfo[record.id].pid : '点击快速安装插件端,java :' + sshAgentInfo[record.id].javaVersion}`"
|
||||||
>
|
>
|
||||||
<a-button type="primary" @click="install(record)" :disabled="sshAgentInfo[record.id].pid > 0">安装节点</a-button>
|
<a-button size="small" type="primary" @click="install(record)" :disabled="sshAgentInfo[record.id].pid > 0">安装节点</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div v-else><a-tag>没有Java环境</a-tag></div>
|
<div v-else><a-tag>没有Java环境</a-tag></div>
|
||||||
@ -63,9 +64,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<template slot="operation" slot-scope="text, record">
|
<template slot="operation" slot-scope="text, record">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button type="primary" @click="handleTerminal(record)">终端</a-button>
|
<a-button size="small" type="primary" @click="handleTerminal(record)">终端</a-button>
|
||||||
<a-tooltip placement="topLeft" title="如果按钮不可用,请去 ssh 编辑中添加允许管理的授权文件夹">
|
<a-tooltip placement="topLeft" title="如果按钮不可用,请去 ssh 编辑中添加允许管理的授权文件夹">
|
||||||
<a-button type="primary" :disabled="!record.fileDirs" @click="handleFile(record)">文件</a-button>
|
<a-button size="small" type="primary" :disabled="!record.fileDirs" @click="handleFile(record)">文件</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-dropdown>
|
<a-dropdown>
|
||||||
<a class="ant-dropdown-link" @click="(e) => e.preventDefault()">
|
<a class="ant-dropdown-link" @click="(e) => e.preventDefault()">
|
||||||
@ -412,8 +413,8 @@ export default {
|
|||||||
title: "操作",
|
title: "操作",
|
||||||
dataIndex: "operation",
|
dataIndex: "operation",
|
||||||
scopedSlots: { customRender: "operation" },
|
scopedSlots: { customRender: "operation" },
|
||||||
width: 230,
|
width: 180,
|
||||||
fixed: "right",
|
align: "center",
|
||||||
// ellipsis: true,
|
// ellipsis: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user