From 4bbd195fbecd2523281d414fc6124e8cd14f2f68 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Thu, 18 May 2023 23:42:54 +0300 Subject: [PATCH] v6.3.12.0 Changelog: https://roxy-wi.org/changelog#6_3_12 --- api/api_funct.py | 34 +++++++++++++++-------------- app/modules/service/installation.py | 8 +++---- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/api/api_funct.py b/api/api_funct.py index 145e426e..b7254d91 100644 --- a/api/api_funct.py +++ b/api/api_funct.py @@ -843,50 +843,52 @@ def install_keepalived(): return_to_master = int(json_loads['return_to_master']) router_id = random.randint(1, 255) data = {'status': dict()} + data['status'][master] = dict() + data['status'][slave] = dict() try: service_mod.keepalived_master_install(master, eth, eth_slave, vrrp_ip, virt_server, syn_flood, return_to_master, haproxy, nginx, router_id, 1) except Exception as e: - data['status'][master] = {'keepalived': f'error: {e}'} + data['status'][master]['keepalived'] = f'error: {e}' else: - data['status'][master] = {'keepalived': 'done'} + data['status'][master]['keepalived'] = 'done' try: service_mod.keepalived_slave_install(master, slave, eth, eth_slave, vrrp_ip, syn_flood, haproxy, nginx, router_id, 1) except Exception as e: - data['status'][slave] = {'keepalived': f'error: {e}'} + data['status'][slave]['keepalived'] = f'error: {e}' else: - data['status'][slave] = {'keepalived': 'done'} + data['status'][slave]['keepalived'] = 'done' if haproxy: try: - service_mod.install_haproxy(master) + service_mod.install_haproxy(master, 1) except Exception as e: - data['status'][master] = {'haproxy': f'error: {e}'} + data['status'][master]['haproxy'] = f'error: {e}' else: - data['status'][master] = {'haproxy': 'done'} + data['status'][master]['haproxy'] = 'done' try: - service_mod.install_haproxy(slave) + service_mod.install_haproxy(slave, 1) except Exception as e: - data['status'][slave] = {'haproxy': f'error: {e}'} + data['status'][slave]['haproxy'] = f'error: {e}' else: - data['status'][slave] = {'haproxy': 'done'} + data['status'][slave]['haproxy'] = 'done' if nginx: try: - service_mod.install_service(master, 'nginx', '0') + service_mod.install_service(master, 'nginx', '0', 1) except Exception as e: - data['status'][master] = {'nginx': f'error: {e}'} + data['status'][master]['nginx'] = f'error: {e}' else: - data['status'][master] = {'nginx': 'done'} + data['status'][master]['nginx'] = 'done' try: - service_mod.install_service(slave, 'nginx', '0') + service_mod.install_service(slave, 'nginx', '0', 1) except Exception as e: - data['status'][slave] = {'nginx': f'error: {e}'} + data['status'][slave]['nginx'] = f'error: {e}' else: - data['status'][slave] = {'nginx': 'done'} + data['status'][slave]['nginx'] = 'done' return dict(data) diff --git a/app/modules/service/installation.py b/app/modules/service/installation.py index 52ca7306..c4998683 100644 --- a/app/modules/service/installation.py +++ b/app/modules/service/installation.py @@ -36,7 +36,7 @@ def show_installation_output(error: str, output: str, service: str, rc=0, api=0) return True -def install_haproxy(server_ip: str, **kwargs): +def install_haproxy(server_ip: str, api=0, **kwargs): script = "install_haproxy.sh" hap_sock_p = str(sql.get_setting('haproxy_sock_port')) stats_port = str(sql.get_setting('stats_port')) @@ -78,7 +78,7 @@ def install_haproxy(server_ip: str, **kwargs): return_out = server_mod.subprocess_execute_with_rc(commands[0]) - if show_installation_output(return_out['error'], return_out['output'], service, rc=return_out['rc']): + if show_installation_output(return_out['error'], return_out['output'], service, rc=return_out['rc'], api=api): try: sql.update_haproxy(server_ip) except Exception as e: @@ -157,7 +157,7 @@ def waf_nginx_install(server_ip: str): os.remove(script) -def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None: +def install_service(server_ip: str, service: str, docker: str, api=0, **kwargs) -> None: script = f"install_{service}.sh" stats_user = sql.get_setting(f'{service}_stats_user') stats_password = sql.get_setting(f'{service}_stats_password') @@ -203,7 +203,7 @@ def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None return_out = server_mod.subprocess_execute_with_rc(commands[0]) - if show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc']): + if show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc'], api=api): if service == 'nginx': try: sql.update_nginx(server_ip)