Pārlūkot izejas kodu

发布的服务需要修改权限

wuweihao 5 gadi atpakaļ
vecāks
revīzija
3048101e50

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 6 - 40
src/main/java/com/fd/constant/Command.java


+ 2 - 52
src/main/java/com/fd/server/impl/CmdServerImpl.java

@@ -124,58 +124,6 @@ public class CmdServerImpl implements CmdServer {
 
     }
 
-//    @Override
-//    public R exeCmdUnzip(String commandStr) {
-//        log.info("run exeCmdUnzip");
-//        Integer isCmd = null; // 命令运行结果 1:失败, 0:成功
-//        try {
-//            String[] cmd = new String[]{"/bin/sh", "-c", commandStr};
-//            Process ps = Runtime.getRuntime().exec(cmd);
-//
-////            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
-////            BufferedReader errorBuf = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
-////
-////            StringBuffer sb = new StringBuffer();
-////            StringBuffer errorStr = new StringBuffer();
-//
-//            // error : 坑, 控制台信息是从errorBuf这里出来的
-////            String errorLine;
-////            log.info("run 111111");
-////            while ((errorLine = errorBuf.readLine()) != null) {
-////                log.info("run 2222222");
-////                errorStr.append(errorLine).append("\n");
-////            }
-////            log.info("run 33333333");
-////            log.info("error result: {}", errorStr.toString());
-////
-////            // success ,没有获取到信息
-////            String line;
-////            while ((line = br.readLine()) != null) {
-////                log.info("run 44444444");
-//////                log.info("=====  br.readLine: ======== {}", br.readLine());
-////                //执行结果加上回车
-////                sb.append(line).append("\n");
-////            }
-//
-////            log.info("result: {}", sb.toString());
-//
-//            // 结束命令行
-//            isCmd = ps.waitFor();
-//            log.info("run 5555555");
-//            // 关闭流
-////            br.close();
-////            errorBuf.close();
-//
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//
-//        if (isCmd == 0) {
-//            return new R(200, MsgCode.SUCCESS);
-//        } else {
-//            return new R(200, MsgCode.E50005);
-//        }
-//    }
 
     @Override
     public Integer exeCmdInt(String cmd) {
@@ -413,6 +361,8 @@ public class CmdServerImpl implements CmdServer {
         return isCmd;
     }
 
+
+
     // 匹配数字
     private boolean numRegex(String str) {
         String reg = "\\d";

+ 13 - 0
src/main/java/com/fd/server/impl/VectorServerImpl.java

@@ -3,6 +3,7 @@ package com.fd.server.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fd.constant.Command;
 import com.fd.constant.MsgCode;
 import com.fd.constant.TypeCode;
 import com.fd.dto.ConfigJsonDto;
@@ -11,6 +12,7 @@ import com.fd.entity.FileEntity;
 import com.fd.entity.OutputFileEntity;
 import com.fd.repository.FileRepository;
 import com.fd.repository.OutputFileRepository;
+import com.fd.server.CmdServer;
 import com.fd.server.VectorServer;
 import com.fd.util.FileUtils;
 import com.fd.util.R;
@@ -60,6 +62,9 @@ public class VectorServerImpl implements VectorServer {
     @Autowired
     private OutputFileRepository outputFileRepository;
 
+    @Autowired
+    private CmdServer cmdServer;
+
 
     @Override
     public R moveFileToServer(Long fileId, ConfigJsonDto param) {
@@ -76,6 +81,14 @@ public class VectorServerImpl implements VectorServer {
             // 修改前端的config.json 文件
             writeJsonFile(param, entity.getDirectory());
 
+            //修改linux 文件权限
+            String cmd = Command.CMD_CHOMD_755;
+            String slice = MOVE_FILE_TO_SERVER + entity.getDirectory();
+            cmd = cmd.replace("@path", slice);
+            log.info("cmd: {}", cmd);
+            cmdServer.exeCmdInt(cmd);
+
+
             entity.setStatus(8);
             entity.setUpdateTime(new Date());
             outputFileRepository.save(entity);