✨ 使用脚本执行命令.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.orion.ops.framework.common.constant;
|
||||
|
||||
import com.orion.lang.constant.OrionConst;
|
||||
|
||||
/**
|
||||
* 项目常量
|
||||
*
|
||||
@@ -7,13 +9,15 @@ package com.orion.ops.framework.common.constant;
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/19 18:56
|
||||
*/
|
||||
public interface OrionOpsProConst {
|
||||
public interface AppConst extends OrionConst {
|
||||
|
||||
/**
|
||||
* 同 ${orion.version} 迭代时候需要手动更改
|
||||
*/
|
||||
String VERSION = "1.0.5";
|
||||
|
||||
String ORION_OPS_PRO = "orion-ops-pro";
|
||||
|
||||
String GITHUB = "https://github.com/lijiahangmax/orion-ops-pro";
|
||||
|
||||
String GITEE = "https://gitee.com/lijiahangmax/orion-ops-pro";
|
||||
@@ -35,6 +35,4 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
|
||||
|
||||
String SYSTEM_USERNAME = "system";
|
||||
|
||||
String ERROR_LOG = "error.log";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.orion.ops.framework.common.constant;
|
||||
|
||||
/**
|
||||
* 路径常量
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/4/17 10:35
|
||||
*/
|
||||
public interface PathConst {
|
||||
|
||||
String ERROR_LOG = "error.log";
|
||||
|
||||
String EXEC = "exec";
|
||||
|
||||
String SCRIPT = "script";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.orion.ops.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Objects1;
|
||||
import com.orion.ops.framework.common.constant.AppConst;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
|
||||
/**
|
||||
* 路径工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/4/17 10:28
|
||||
*/
|
||||
public class PathUtils {
|
||||
|
||||
private PathUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户根目录
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户目录
|
||||
*/
|
||||
public static String getHomePath(String username) {
|
||||
if (Const.ROOT.equals(username)) {
|
||||
return "/" + Const.ROOT;
|
||||
} else {
|
||||
return "/home/" + username;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用路径
|
||||
*
|
||||
* @param username username
|
||||
* @return path
|
||||
*/
|
||||
public static String getAppPath(String username) {
|
||||
return getHomePath(username)
|
||||
+ "/" + AppConst.ORION
|
||||
+ "/" + AppConst.ORION_OPS_PRO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建应用路径
|
||||
*
|
||||
* @param username username
|
||||
* @param paths paths
|
||||
* @return path
|
||||
*/
|
||||
public static String buildAppPath(String username, Object... paths) {
|
||||
StringBuilder path = new StringBuilder(getAppPath(username));
|
||||
for (Object o : paths) {
|
||||
path.append("/").append(Objects1.toString(o));
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user