@name 修复项目 @author lkq<2021-08-27> @param project_name 域名 @return string
(self, get)
| 3619 | |
| 3620 | # 修复独立项目 |
| 3621 | def fix_project(self, get): |
| 3622 | ''' |
| 3623 | @name 修复项目 |
| 3624 | @author lkq<2021-08-27> |
| 3625 | @param project_name 域名 |
| 3626 | @return string |
| 3627 | ''' |
| 3628 | if not public.is_apache_nginx(): return public.returnMsg(False, '未安装Apache或Nginx') |
| 3629 | project_info = self.get_project_find(get.project_name.strip()) |
| 3630 | if not project_info: return public.returnMsg(False, '项目不存在') |
| 3631 | project_config = project_info['project_config'] |
| 3632 | if project_config['java_type'] == 'duli': |
| 3633 | if not os.path.exists( |
| 3634 | self.__bttomcat_path + "/tomcat_bak{}/conf/server.xml".format( |
| 3635 | project_config['tomcat_version'] |
| 3636 | ) |
| 3637 | ): return public.returnMsg(False, '修复失败当前Tomcat版本未安装') |
| 3638 | tomcat_list = ["7", "8", "9"] |
| 3639 | if not project_config['tomcat_version'] in tomcat_list: return public.returnMsg(False, '请指定tomcat版本!') |
| 3640 | if self.check_port(str(project_config['port'])): |
| 3641 | return public.returnMsg(False, "%s端口被占用,修复失败" % str(project_config['port'])) |
| 3642 | # 判断是否存在 |
| 3643 | if not os.path.exists(project_info['path']): |
| 3644 | os.makedirs(project_info['path']) |
| 3645 | public.set_own(project_info['path'], 'www') |
| 3646 | # 确定目录存在。先删除目录 |
| 3647 | domain = project_info['name'] |
| 3648 | if os.path.exists(self.__site_path + domain): |
| 3649 | public.ExecShell('rm -rf ' + self.__site_path + domain) |
| 3650 | tomcat_version = project_config['tomcat_version'] |
| 3651 | # 复制项目 |
| 3652 | if not os.path.exists(self.__site_path + domain): |
| 3653 | public.ExecShell('mkdir -p %s' % self.__site_path + domain) |
| 3654 | if tomcat_version == 'tomcat7' or tomcat_version == '7': |
| 3655 | if not os.path.exists(self.__tomcat7_path_bak + '/conf/server.xml'): return public.returnMsg( |
| 3656 | False, "tomcat7的配置文件不存在,请重新安装tomcat7" |
| 3657 | ) |
| 3658 | public.ExecShell( |
| 3659 | 'cp -r %s/* %s && chown -R www:www %s' % ( |
| 3660 | self.__tomcat7_path_bak, self.__site_path + domain, self.__site_path + domain) |
| 3661 | ) |
| 3662 | if tomcat_version == 'tomcat8' or tomcat_version == '8': |
| 3663 | if not os.path.exists(self.__tomcat8_path_bak + '/conf/server.xml'): return public.returnMsg( |
| 3664 | False, "tomcat8的配置文件不存在,请重新安装tomcat8" |
| 3665 | ) |
| 3666 | public.ExecShell( |
| 3667 | 'cp -r %s/* %s && chown -R www:www %s' % ( |
| 3668 | self.__tomcat8_path_bak, self.__site_path + domain, self.__site_path + domain) |
| 3669 | ) |
| 3670 | if tomcat_version == 'tomcat9' or tomcat_version == '9': |
| 3671 | if not os.path.exists(self.__tomcat9_path_bak + '/conf/server.xml'): return public.returnMsg( |
| 3672 | False, "tomcat9的配置文件不存在,请重新安装tomcat9" |
| 3673 | ) |
| 3674 | public.ExecShell( |
| 3675 | 'cp -r %s/* %s && chown -R www:www %s' % ( |
| 3676 | self.__tomcat9_path_bak, self.__site_path + domain, self.__site_path + domain) |
| 3677 | ) |
| 3678 | # server.xml |
nothing calls this directly
no test coverage detected