Skip to content

Commit

Permalink
Merge pull request #60 from dromara/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
lijiahangmax authored Sep 27, 2024
2 parents 3918d36 + ef57040 commit 7015468
Show file tree
Hide file tree
Showing 32 changed files with 251 additions and 164 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center"><img src="https://bjuimg.obs.cn-north-4.myhuaweicloud.com/images/2024/9/11/11e7e78e-2af0-4c68-9811-db8a4c4400f4.png" alt="logo" width="520" /></div>
<p style="margin-top: 12px" align="center"><b>一款高颜值、现代化的智能运维&轻量堡垒机平台。</b></p>
<p style="margin-top: 12px" align="center"><b>一款高颜值、现代化的自动化运维&轻量堡垒机平台。</b></p>
<p align="center">
<a target="_blank"
style="text-decoration: none !important;"
Expand Down Expand Up @@ -40,7 +40,7 @@

------------------------------

**`orion-visor`** 提供一站式系统自动化运维解决方案
**`orion-visor`** 提供一站式自动化运维解决方案

* **资产管理**:支持对资产进行分组,实现对主机、密钥和身份的统一管理和授权。
* **在线终端**:提供在线终端 SSH 服务,支持快捷命令、自定义快捷键和主题风格。
Expand Down
6 changes: 3 additions & 3 deletions docker-compose-testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
service:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.7
privileged: true
ports:
- 1081:80
Expand Down Expand Up @@ -32,7 +32,7 @@ services:
- mysql
- redis
mysql:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.7
privileged: true
ports:
- 3307:3306
Expand All @@ -52,7 +52,7 @@ services:
retries: 10
start_period: 3s
redis:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.7
privileged: true
ports:
- 6380:6379
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
service:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.7
privileged: true
ports:
- ${SERVICE_PORT:-1081}:80
Expand Down Expand Up @@ -32,7 +32,7 @@ services:
- mysql
- redis
mysql:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.7
privileged: true
ports:
- 3307:3306
Expand All @@ -52,7 +52,7 @@ services:
retries: 15
start_period: 3s
redis:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.7
privileged: true
ports:
- 6380:6379
Expand All @@ -68,7 +68,7 @@ services:
retries: 15
start_period: 3s
adminer:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:2.1.6
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:2.1.7
ports:
- 8081:8080
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion docker/adminer/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
version=2.1.6
version=2.1.7
docker build -t orion-visor-adminer:${version} .
docker tag orion-visor-adminer:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:${version}
2 changes: 1 addition & 1 deletion docker/mysql/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.1.6
version=2.1.7
cp -r ../../sql ./sql
docker build -t orion-visor-mysql:${version} .
rm -rf ./sql
Expand Down
2 changes: 1 addition & 1 deletion docker/push.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.1.6
version=2.1.7
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:${version}
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:${version}
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
Expand Down
2 changes: 1 addition & 1 deletion docker/redis/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
version=2.1.6
version=2.1.7
docker build -t orion-visor-redis:${version} .
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
2 changes: 1 addition & 1 deletion docker/service/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.1.6
version=2.1.7
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
mv ../../orion-visor-ui/dist ./dist
docker build -t orion-visor-service:${version} .
Expand Down
2 changes: 1 addition & 1 deletion orion-visor-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<url>https://github.com/dromara/orion-visor</url>

<properties>
<revision>2.1.6</revision>
<revision>2.1.7</revision>
<spring.boot.version>2.7.17</spring.boot.version>
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface AppConst extends OrionConst {
/**
* 同 ${orion.version} 迭代时候需要手动更改
*/
String VERSION = "2.1.6";
String VERSION = "2.1.7";

/**
* 同 ${spring.application.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface ExtraFieldConst extends FieldConst {

String USERNAME = "username";

String HOME = "home";

String STATUS_NAME = "statusName";

String KEY_NAME = "keyName";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.orion.visor.framework.common.utils;

import com.orion.lang.utils.Objects1;
import com.orion.lang.utils.Systems;
import com.orion.lang.utils.io.Files1;
import com.orion.visor.framework.common.constant.AppConst;
import com.orion.visor.framework.common.constant.Const;

Expand All @@ -24,9 +26,25 @@ private PathUtils() {
* @return 用户目录
*/
public static String getHomePath(boolean isWindows, String username) {
return getHomePath(isWindows, username, false);
}

/**
* 获取用户根目录
*
* @param isWindows isWindows
* @param username 用户名
* @param prependSeparator 是否在头部添加分隔符
* @return 用户目录
*/
public static String getHomePath(boolean isWindows, String username, boolean prependSeparator) {
if (isWindows) {
// windows
return "C:/Users/" + username;
if (prependSeparator) {
return "/C:/Users/" + username;
} else {
return "C:/Users/" + username;
}
} else {
// linux
if (Const.ROOT.equals(username)) {
Expand Down Expand Up @@ -66,4 +84,34 @@ public static String buildAppPath(boolean isWindows, String username, Object...
return path.toString();
}

/**
* 头部添加分隔符
*
* @param path path
* @return path
*/
public static String prependSeparator(String path) {
if (path.startsWith("/")) {
return path;
}
return "/" + path;
}

/**
* 获取 orion path
*
* @param path path
* @return path
*/
public static String getOrionPath(String path) {
path = Systems.HOME_DIR
+ Files1.SEPARATOR
+ AppConst.ORION
+ Files1.SEPARATOR
+ AppConst.APP_NAME
+ Files1.SEPARATOR
+ path;
return Files1.getPath(path);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public interface HostConvert {

List<HostVO> toList(List<HostDO> domain);

List<HostBaseVO> toBaseList(List<HostDO> domain);

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UploadTaskOperatorType extends InitializingOperatorTypes {
@Override
public OperatorType[] types() {
return new OperatorType[]{
new OperatorType(M, UPLOAD, "批量上传文件 <sb>${count}</sb>个 (${name})"),
new OperatorType(M, UPLOAD, "批量上传文件 <sb>${count}</sb> 个 (${name})"),
new OperatorType(M, CANCEL, "取消上传文件 <sb>${name}</sb>"),
new OperatorType(H, DELETE, "删除上传记录 <sb>${count}</sb>条"),
new OperatorType(H, CLEAR, "清理上传记录 <sb>${count}</sb>条"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class UploadTaskFileDO extends BaseDO {
@TableField("file_path")
private String filePath;

@Schema(description = "实际文件路径")
@TableField("real_file_path")
private String realFilePath;

@Schema(description = "文件大小")
@TableField("file_size")
private Long fileSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class UploadTaskFileVO implements Serializable {
@Schema(description = "文件路径")
private String filePath;

@Schema(description = "实际文件路径")
private String realFilePath;

@Schema(description = "文件大小")
private Long fileSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,24 @@ public static HostSshOsTypeEnum of(String type) {
return LINUX;
}

/**
* 是否为 linux 系统
*
* @param type type
* @return isLinux
*/
public static boolean isLinux(String type) {
return LINUX.name().equals(type);
}

/**
* 是否为 windows 系统
*
* @param type type
* @return isWindows
*/
public static boolean isWindows(String type) {
return WINDOWS.name().equals(type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.orion.spring.SpringHolder;
import com.orion.visor.framework.common.constant.ErrorMessage;
import com.orion.visor.framework.common.file.FileClient;
import com.orion.visor.framework.common.utils.PathUtils;
import com.orion.visor.module.asset.dao.ExecHostLogDAO;
import com.orion.visor.module.asset.entity.domain.ExecHostLogDO;
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
Expand Down Expand Up @@ -159,11 +160,8 @@ protected void uploadScriptFile() {
// 打开 sftp
sftpExecutor = sessionStore.getSftpExecutor(execHostCommand.getFileNameCharset());
sftpExecutor.connect();
// 必须要以 / 开头
String scriptPath = execHostCommand.getScriptPath();
if (!scriptPath.startsWith("/")) {
scriptPath = "/" + scriptPath;
}
// 文件上传必须要以 / 开头
String scriptPath = PathUtils.prependSeparator(execHostCommand.getScriptPath());
// 创建文件
sftpExecutor.touch(scriptPath);
// 写入命令
Expand Down Expand Up @@ -225,29 +223,33 @@ private void updateStatus(ExecHostStatusEnum status, Exception ex) {
Long id = execHostCommand.getHostLogId();
String statusName = status.name();
log.info("BaseExecCommandHandler.updateStatus start id: {}, status: {}", id, statusName);
updateRecord.setId(id);
updateRecord.setStatus(statusName);
if (ExecHostStatusEnum.RUNNING.equals(status)) {
// 运行中
updateRecord.setStartTime(new Date());
} else if (ExecHostStatusEnum.COMPLETED.equals(status)) {
// 完成
updateRecord.setFinishTime(new Date());
updateRecord.setExitCode(executor.getExitCode());
this.exitCode = executor.getExitCode();
} else if (ExecHostStatusEnum.FAILED.equals(status)) {
// 失败
updateRecord.setFinishTime(new Date());
updateRecord.setErrorMessage(this.getErrorMessage(ex));
} else if (ExecHostStatusEnum.TIMEOUT.equals(status)) {
// 超时
updateRecord.setFinishTime(new Date());
} else if (ExecHostStatusEnum.INTERRUPTED.equals(status)) {
// 中断
updateRecord.setFinishTime(new Date());
try {
updateRecord.setId(id);
updateRecord.setStatus(statusName);
if (ExecHostStatusEnum.RUNNING.equals(status)) {
// 运行中
updateRecord.setStartTime(new Date());
} else if (ExecHostStatusEnum.COMPLETED.equals(status)) {
// 完成
updateRecord.setFinishTime(new Date());
updateRecord.setExitCode(executor.getExitCode());
this.exitCode = executor.getExitCode();
} else if (ExecHostStatusEnum.FAILED.equals(status)) {
// 失败
updateRecord.setFinishTime(new Date());
updateRecord.setErrorMessage(this.getErrorMessage(ex));
} else if (ExecHostStatusEnum.TIMEOUT.equals(status)) {
// 超时
updateRecord.setFinishTime(new Date());
} else if (ExecHostStatusEnum.INTERRUPTED.equals(status)) {
// 中断
updateRecord.setFinishTime(new Date());
}
int effect = execHostLogDAO.updateById(updateRecord);
log.info("BaseExecCommandHandler.updateStatus finish id: {}, effect: {}", id, effect);
} catch (Exception e) {
log.error("BaseExecCommandHandler.updateStatus error id: {}", id, e);
}
int effect = execHostLogDAO.updateById(updateRecord);
log.info("BaseExecCommandHandler.updateStatus finish id: {}, effect: {}", id, effect);
}

@Override
Expand Down
Loading

0 comments on commit 7015468

Please sign in to comment.