Browse Source

自动化建站脚本远程执行,服务器配置

chenlei1231 4 months ago
parent
commit
148caabba3

+ 8 - 12
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/ShellSSH2Util.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.adweb.common.util;
 import ch.ethz.ssh2.Connection;
 import ch.ethz.ssh2.Session;
 import ch.ethz.ssh2.StreamGobbler;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -15,6 +16,7 @@ import java.io.*;
  * @author liyl
  * @date 2019-08-13
  */
+@Slf4j
 public class ShellSSH2Util {
 
     /**
@@ -47,15 +49,12 @@ public class ShellSSH2Util {
                 listener.stdout(username + "@" + host + "; 登录成功");
             } else {
                 listener.stderr(username + "@" + host + "; 登录失败");
-                if (connection != null) {
-                    connection.close();
-                }
+                connection.close();
             }
         } catch (IOException e) {
             listener.stderr(username + "@" + host + "; 登录失败");
-            if (connection != null) {
-                connection.close();
-            }
+            log.error("服务器host:{},连接失败:{}", host, e.getMessage());
+            connection.close();
         }
         return connection;
     }
@@ -80,15 +79,12 @@ public class ShellSSH2Util {
                 listener.stdout(username + "@" + host + "; 登录成功");
             } else {
                 listener.stderr(username + "@" + host + "; 登录失败");
-                if (connection != null) {
-                    connection.close();
-                }
+                connection.close();
             }
         } catch (IOException e) {
             listener.stderr(username + "@" + host + "; 登录失败");
-            if (connection != null) {
-                connection.close();
-            }
+            log.error("服务器host:{},连接失败:{}", host, e.getMessage());
+            connection.close();
         }
         return connection;
     }

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/mapper/SiteUserPermissionMapper.java

@@ -1,14 +1,14 @@
 package org.jeecg.modules.adweb.site.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
+import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
 
 /**
  * @Description: 站点和用户的中间表
  * @Author: jeecg-boot
- * @Date:   2021-04-06
+ * @Date: 2021-04-06
  * @Version: V1.0
  */
-public interface SiteUserPermissionMapper extends BaseMapper<AdwebSitePermission> {
+public interface SiteUserPermissionMapper extends BaseMapper<AdwebSiteUserPermission> {
 
 }

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/SelfWebSiteService.java

@@ -112,7 +112,7 @@ public class SelfWebSiteService {
             // 执行临时服务器shell脚本,生成临时站点
             String cmd = "/opt/adweb3/shell/auto-website " + adwebSite.getCode() + " " + adwebSite.getParentCode();
 
-            shellService.exceShellByServerInfo(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
+            shellService.createShareSiteByPwd(cmd, host, port, username, password, new ShellSSH2Util.StdoutListener() {
                 @Override
                 public void stdout(String line) {
                     log.info("标准 :{}", line);

+ 7 - 101
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/SiteUserPermissionServiceImpl.java

@@ -1,21 +1,22 @@
 package org.jeecg.modules.adweb.site.service.impl;
 
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.jeecg.modules.adweb.common.util.SnowflakeIdUtil;
 import org.jeecg.modules.adweb.site.entity.AdwebSitePermission;
 import org.jeecg.modules.adweb.site.entity.AdwebSiteUserPermission;
+import org.jeecg.modules.adweb.site.mapper.SiteUserPermissionMapper;
 import org.jeecg.modules.adweb.site.service.ISitePermissionService;
 import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
-import java.util.function.Function;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**
@@ -26,7 +27,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @Slf4j
-public class SiteUserPermissionServiceImpl implements ISiteUserPermissionService {
+public class SiteUserPermissionServiceImpl extends ServiceImpl<SiteUserPermissionMapper, AdwebSiteUserPermission> implements ISiteUserPermissionService {
 
     @Resource
     private ISitePermissionService sitePermissionService;
@@ -114,7 +115,7 @@ public class SiteUserPermissionServiceImpl implements ISiteUserPermissionService
 
             queryWrapper.eq(AdwebSiteUserPermission::getUid, uid)
                     .eq(AdwebSiteUserPermission::getStatus, 1);
-            
+
             siteUserPermissionList = this.list(queryWrapper);
 
             AdwebSiteUserPermission siteUserPermission = new AdwebSiteUserPermission();
@@ -142,99 +143,4 @@ public class SiteUserPermissionServiceImpl implements ISiteUserPermissionService
             log.error("添加站点权限失败", e);
         }
     }
-
-    /**
-     * @param entityList
-     * @param batchSize
-     * @return
-     */
-    @Override
-    public boolean saveBatch(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
-        return false;
-    }
-
-    /**
-     * @param entityList
-     * @param batchSize
-     * @return
-     */
-    @Override
-    public boolean saveOrUpdateBatch(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
-        return false;
-    }
-
-    /**
-     * @param entityList
-     * @param batchSize
-     * @return
-     */
-    @Override
-    public boolean updateBatchById(Collection<AdwebSiteUserPermission> entityList, int batchSize) {
-        return false;
-    }
-
-    /**
-     * @param entity
-     * @return
-     */
-    @Override
-    public boolean saveOrUpdate(AdwebSiteUserPermission entity) {
-        return false;
-    }
-
-    /**
-     * @param queryWrapper
-     * @param throwEx
-     * @return
-     */
-    @Override
-    public AdwebSiteUserPermission getOne(Wrapper<AdwebSiteUserPermission> queryWrapper, boolean throwEx) {
-        return null;
-    }
-
-    /**
-     * @param queryWrapper
-     * @param throwEx
-     * @return
-     */
-    @Override
-    public Optional<AdwebSiteUserPermission> getOneOpt(Wrapper<AdwebSiteUserPermission> queryWrapper, boolean throwEx) {
-        return Optional.empty();
-    }
-
-    /**
-     * @param queryWrapper
-     * @return
-     */
-    @Override
-    public Map<String, Object> getMap(Wrapper<AdwebSiteUserPermission> queryWrapper) {
-        return Map.of();
-    }
-
-    /**
-     * @param queryWrapper
-     * @param mapper
-     * @param <V>
-     * @return
-     */
-    @Override
-    public <V> V getObj(Wrapper<AdwebSiteUserPermission> queryWrapper, Function<? super Object, V> mapper) {
-        return null;
-    }
-
-    /**
-     * @return
-     */
-    @Override
-    public BaseMapper<AdwebSiteUserPermission> getBaseMapper() {
-        return null;
-    }
-
-    /**
-     * @return
-     */
-    @Override
-    public Class<AdwebSiteUserPermission> getEntityClass() {
-        return null;
-    }
 }

+ 1 - 1
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -463,7 +463,7 @@ AdwebSiteConnect:
   host: 35.87.155.71
   port: 22
   username: ubuntu
-  password: adweb3.pem
+  password: adweb123@2024
   tempDomain: adweb3.topxuetang.com
   tempCname: devci2.adwebcloud.com