mirror of https://github.com/Aidaho12/haproxy-wi
parent
7c899092cc
commit
1cb12d12e6
|
@ -6,6 +6,7 @@ import modules.db.sql as sql
|
||||||
import modules.server.ssh as mod_ssh
|
import modules.server.ssh as mod_ssh
|
||||||
import modules.common.common as common
|
import modules.common.common as common
|
||||||
import modules.roxywi.auth as roxywi_auth
|
import modules.roxywi.auth as roxywi_auth
|
||||||
|
import modules.roxywi.logs as roxywi_logs
|
||||||
import modules.roxywi.common as roxywi_common
|
import modules.roxywi.common as roxywi_common
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,8 +36,6 @@ def ssh_command(server_ip: str, commands: list, **kwargs):
|
||||||
if kwargs.get('raw'):
|
if kwargs.get('raw'):
|
||||||
return stdout.readlines()
|
return stdout.readlines()
|
||||||
elif kwargs.get("show_log") == "1":
|
elif kwargs.get("show_log") == "1":
|
||||||
import modules.roxywi.logs as roxywi_logs
|
|
||||||
|
|
||||||
return roxywi_logs.show_log(stdout, grep=kwargs.get("grep"))
|
return roxywi_logs.show_log(stdout, grep=kwargs.get("grep"))
|
||||||
elif kwargs.get('return_err') == 1:
|
elif kwargs.get('return_err') == 1:
|
||||||
return stderr.read().decode(encoding='UTF-8')
|
return stderr.read().decode(encoding='UTF-8')
|
||||||
|
@ -44,6 +43,7 @@ def ssh_command(server_ip: str, commands: list, **kwargs):
|
||||||
return stdout.read().decode(encoding='UTF-8')
|
return stdout.read().decode(encoding='UTF-8')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection. Probably sudo with password {e}', roxywi=1)
|
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection. Probably sudo with password {e}', roxywi=1)
|
||||||
|
raise Exception(f'error: Cannot run SSH: {e}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection: {e}', roxywi=1)
|
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection: {e}', roxywi=1)
|
||||||
raise Exception(f'error: Cannot run SSH: {e}')
|
raise Exception(f'error: Cannot run SSH: {e}')
|
||||||
|
|
|
@ -229,7 +229,7 @@ def get_stat_page(server_ip: str, service: str) -> str:
|
||||||
return data.decode('utf-8')
|
return data.decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def show_service_version(server_ip: str, service: str) -> None:
|
def show_service_version(server_ip: str, service: str) -> str:
|
||||||
if service == 'haproxy':
|
if service == 'haproxy':
|
||||||
return check_haproxy_version(server_ip)
|
return check_haproxy_version(server_ip)
|
||||||
|
|
||||||
|
@ -248,4 +248,8 @@ def show_service_version(server_ip: str, service: str) -> None:
|
||||||
cmd = [f'docker exec -it {container_name} /usr/sbin/{service_name} -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
|
cmd = [f'docker exec -it {container_name} /usr/sbin/{service_name} -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
|
||||||
else:
|
else:
|
||||||
cmd = [f'sudo /usr/sbin/{service_name} -v|head -1|awk -F":" \'{{print $2}}\'']
|
cmd = [f'sudo /usr/sbin/{service_name} -v|head -1|awk -F":" \'{{print $2}}\'']
|
||||||
return server_mod.ssh_command(server_ip, cmd)
|
|
||||||
|
try:
|
||||||
|
return server_mod.ssh_command(server_ip, cmd, timeout=5)
|
||||||
|
except Exception as e:
|
||||||
|
return f'{e}'
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
---
|
---
|
||||||
#- name: Set SSH port
|
|
||||||
# set_fact:
|
|
||||||
# ansible_port: "{{SSH_PORT}}"
|
|
||||||
|
|
||||||
- name: check if HAProxy is installed
|
- name: check if HAProxy is installed
|
||||||
package_facts:
|
package_facts:
|
||||||
manager: "auto"
|
manager: "auto"
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
- name: Include Service-OS-specific variables.
|
- name: Include Service-OS-specific variables.
|
||||||
include_vars: "{{ service }}-{{ ansible_os_family }}.yml"
|
include_vars: "{{ service }}-{{ ansible_os_family }}.yml"
|
||||||
|
|
||||||
- name: Set SSH port
|
|
||||||
set_fact:
|
|
||||||
ansible_port: "{{SSH_PORT}}"
|
|
||||||
|
|
||||||
- name: "Ensure group {{ service_group }} exists"
|
- name: "Ensure group {{ service_group }} exists"
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ service_group }}"
|
name: "{{ service_group }}"
|
||||||
|
|
|
@ -2895,7 +2895,10 @@ function showServiceVersion(service) {
|
||||||
// type: "POST",
|
// type: "POST",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
data = data.replace(/^\s+|\s+$/g, '');
|
data = data.replace(/^\s+|\s+$/g, '');
|
||||||
if (data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
|
if (data.indexOf('error: ') != '-1') {
|
||||||
|
toastr.warning(data);
|
||||||
|
$('#cur_' + service + '_ver').text('');
|
||||||
|
} else if(data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
|
||||||
$('#cur_' + service + '_ver').text(service + ' has not installed');
|
$('#cur_' + service + '_ver').text(service + ' has not installed');
|
||||||
$('#' + service + '_install').text('Install');
|
$('#' + service + '_install').text('Install');
|
||||||
$('#' + service + '_install').attr('title', 'Install');
|
$('#' + service + '_install').attr('title', 'Install');
|
||||||
|
|
Loading…
Reference in New Issue