MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / install_tomcat

Method install_tomcat

class/projectModel/javaModel.py:353–401  ·  view source on GitHub ↗

@name 安装tomcat版本 @author lkq<2021-08-27> @param get @param get.version 安装|卸载的版本 @param get.type install ==安装 uninstall ==卸载 @return string

(self, get)

Source from the content-addressed store, hash-verified

351 return tmp
352
353 def install_tomcat(self, get):
354 ''&#x27;
355 @name 安装tomcat版本
356 @author lkq<2021-08-27>
357 @param get<dict_obj>
358 @param get.version 安装|卸载的版本
359 @param get.type install ==安装 uninstall ==卸载
360 @return string
361 ''&#x27;
362 tmp_file = '/tmp/panelShell2.pl'
363 if not os.path.exists(tmp_file):
364 public.ExecShell("touch /tmp/panelShell2.pl")
365 else:
366 public.ExecShell("echo ""> /tmp/panelShell2.pl")
367 version = str(get.version)
368 os_ver = self.get_os_version(None)
369 if 'type' not in get:
370 return public.returnMsg(False, '参数错误!')
371 type_list = ['install', 'uninstall']
372 if not get.type in type_list:
373 return public.returnMsg(False, '安装卸载只能是install或者uninstall!')
374 if version == "7":
375 if os_ver == 'Ubuntu':
376 return public.returnMsg(False, '操作系统不支持!')
377 download_url = self.test_download_url()
378 if get.type != 'install' and os.path.exists("/tmp/1.sh"):
379 public.ExecShell("bash /tmp/1.sh %s %s >>%s" % (get.type, version, tmp_file))
380 else:
381 if download_url is None:
382 error = '<br>错误:连接宝塔官网异常,请按照以下方法排除问题后重试:<br>解决方法:<a target="_blank" class="btlink" href="https://www.bt.cn/bbs/thread-87257-1-1.html">https://www.bt.cn/bbs/thread-87257-1-1.html</a><br>'
383 raise public.PanelError(error)
384 # return public.returnMsg(False, '网络链接错误<br>请尝试检查网络配置或更换节点')
385 public.ExecShell(
386 "rm -rf /tmp/1.sh && /usr/local/curl/bin/curl -o /tmp/1.sh %s/install/src/webserver/shell/new_jdk.sh && bash /tmp/1.sh %s %s >>%s" % (
387 download_url, get.type, version, tmp_file)
388 )
389
390 # self.collect_msg("tomcat-{}".format(version), log_path=tmp_file)
391 tomcat_status = self.get_tomcat_version(None)
392 if get.type == 'install':
393 if tomcat_status['tomcat' + version]['status']:
394 return public.returnMsg(True, '安装成功!')
395 else:
396 return public.returnMsg(False, '安装失败!')
397 else:
398 if not tomcat_status['tomcat' + version]['status']:
399 return public.returnMsg(True, '卸载成功!')
400 else:
401 return public.returnMsg(False, '卸载失败!')
402
403 @staticmethod
404 def test_download_url():

Callers

nothing calls this directly

Calls 6

get_os_versionMethod · 0.95
test_download_urlMethod · 0.95
get_tomcat_versionMethod · 0.95
ExecShellMethod · 0.80
returnMsgMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected