Pavel Loginov 2021-08-24 16:12:52 +06:00
parent 40fa9c06ef
commit 342913a9f9
11 changed files with 50 additions and 39 deletions

View File

@ -122,8 +122,8 @@ def logging(serv, action, **kwargs):
login = '' login = ''
try: try:
subprocess_execute('sudo chown apache:apache -R' + log_path) os.system('sudo chown apache:apache -R ' + log_path)
except: except Exception as e:
pass pass
if kwargs.get('alerting') == 1: if kwargs.get('alerting') == 1:
@ -587,17 +587,22 @@ def show_installation_output(error, output, service):
if error and "WARNING" not in error: if error and "WARNING" not in error:
logging('localhost', error, haproxywi=1) logging('localhost', error, haproxywi=1)
print('error: '+error) print('error: '+error)
return False
else: else:
for l in output: for l in output:
if "Traceback" in l or "FAILED" in l: if "UNREACHABLE" in l:
print(l + '<br />')
if "Traceback" in l or "FAILED" in l or "error" in l:
try: try:
print(l) print(l)
break break
return False
except Exception: except Exception:
print(output) print(output)
break break
else: else:
print('success: ' + service + ' has been installed') print('success: ' + service + ' has been installed')
return True
def install_haproxy(serv, **kwargs): def install_haproxy(serv, **kwargs):
@ -644,10 +649,11 @@ def install_haproxy(serv, **kwargs):
service = server_for_installing + ' HAProxy' service = server_for_installing + ' HAProxy'
else: else:
service = ' HAProxy' service = ' HAProxy'
show_installation_output(error, output, service)
if show_installation_output(error, output, service):
sql.update_haproxy(serv)
os.system("rm -f %s" % script) os.system("rm -f %s" % script)
sql.update_haproxy(serv)
def waf_install(serv): def waf_install(serv):
@ -718,10 +724,10 @@ def install_nginx(serv, **kwargs):
service = server_for_installing + ' Nginx' service = server_for_installing + ' Nginx'
else: else:
service = ' Nginx' service = ' Nginx'
show_installation_output(error, output, service) if show_installation_output(error, output, service):
sql.update_nginx(serv)
os.system("rm -f %s" % script) os.system("rm -f %s" % script)
sql.update_nginx(serv)
def update_haproxy_wi(service): def update_haproxy_wi(service):

View File

@ -1058,15 +1058,14 @@ if form.getvalue('master'):
output, error = funct.subprocess_execute(commands[0]) output, error = funct.subprocess_execute(commands[0])
funct.show_installation_output(error, output, 'master Keepalived') if funct.show_installation_output(error, output, 'master Keepalived'):
sql.update_keepalived(master)
sql.update_keepalived(master) if virt_server != '0':
group_id = sql.get_group_id_by_server_ip(master)
if virt_server is not None: cred_id = sql.get_cred_id_by_server_ip(master)
group_id = sql.get_group_id_by_server_ip(master) hostname = sql.get_hostname_by_server_ip(master)
cred_id = sql.get_cred_id_by_server_ip(master) sql.add_server(hostname+'-VIP', IP, group_id, '1', '1', '0', cred_id, ssh_port, 'VRRP IP for '+master, haproxy, nginx, '0')
hostname = sql.get_hostname_by_server_ip(master)
sql.add_server(hostname+'-VIP', IP, group_id, '1', '1', '0', cred_id, ssh_port, 'VRRP IP for '+master, haproxy, nginx, '0')
if form.getvalue('master_slave'): if form.getvalue('master_slave'):
master = form.getvalue('master_slave') master = form.getvalue('master_slave')

View File

@ -82,7 +82,7 @@
{% else %} {% else %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have installed OpenVPN client. <h3>You have not installed OpenVPN client.
Read <a href="https://roxy-wi.org/services.py?service=openvpn" title="OpenVPN" style="color: #5d9ceb;" target="_blank">hear</a> Read <a href="https://roxy-wi.org/services.py?service=openvpn" title="OpenVPN" style="color: #5d9ceb;" target="_blank">hear</a>
how to install OpenVPN client</h3> how to install OpenVPN client</h3>
</div> </div>

View File

@ -115,7 +115,7 @@
{% else %} {% else %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have installed Backends checker <h3>You have not installed Backends checker
Read <a href="https://roxy-wi.org/services.py?service=checker#installation" title="Checker installation" style="color: #5d9ceb;" target="_blank">hear</a> Read <a href="https://roxy-wi.org/services.py?service=checker#installation" title="Checker installation" style="color: #5d9ceb;" target="_blank">hear</a>
how to install Checker service</h3> how to install Checker service</h3>
</div> </div>

View File

@ -3,7 +3,7 @@
<table class="overview" id="ajax-users"> <table class="overview" id="ajax-users">
<thead> <thead>
<tr class="overviewHead"> <tr class="overviewHead">
<th class="padding10 first-collumn">Login name</th> <th class="padding10 first-collumn">Login</th>
<th style="width: 10%">Password</th> <th style="width: 10%">Password</th>
<th style="width: 10%">Active</th> <th style="width: 10%">Active</th>
<th style="width: 20%">Email</th> <th style="width: 20%">Email</th>
@ -52,7 +52,7 @@
</td> </td>
<td> <td>
<select id="role-{{user.user_id}}" name="role-{{user.user_id}}"> <select id="role-{{user.user_id}}" name="role-{{user.user_id}}">
<option disabled selected>Choose role</option> <option disabled selected>Select a role</option>
{% for r in roles %} {% for r in roles %}
{% if page == "servers.py" %} {% if page == "servers.py" %}
{% if r.name != "superAdmin" %} {% if r.name != "superAdmin" %}

View File

@ -19,7 +19,7 @@
{% if services == '0' %} {% if services == '0' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have installed Metrics service. <h3>You have not installed Metrics service.
Read <a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" style="color: #5d9ceb;" target="_blank">hear</a> Read <a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" style="color: #5d9ceb;" target="_blank">hear</a>
how to install Metrics service</h3> how to install Metrics service</h3>
</div> </div>

View File

@ -30,7 +30,7 @@
{% elif port_scanner_stderr != '' %} {% elif port_scanner_stderr != '' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have installed Port scanner service. Read <a href="https://roxy-wi.org/services.py?service=port_scanner" <h3>You have not installed Port scanner service. Read <a href="https://roxy-wi.org/services.py?service=port_scanner"
title="Port scanner" target="_blank">here</a> how to install Port scanner service</h3> title="Port scanner" target="_blank">here</a> how to install Port scanner service</h3>
</div> </div>
{% else %} {% else %}

View File

@ -16,7 +16,7 @@
{% if not is_terraform %} {% if not is_terraform %}
<center> <center>
<br /> <br />
<h3>You do not have installed Terraform. Read <a href="https://www.terraform.io/downloads.html" <h3>You have not installed Terraform. Read <a href="https://www.terraform.io/downloads.html"
title="Download Terraform" target="_blank">here</a> how to install Terraform</h3> title="Download Terraform" target="_blank">here</a> how to install Terraform</h3>
</center> </center>
{% else %} {% else %}

View File

@ -8,7 +8,7 @@
{% if smon_error != '' %} {% if smon_error != '' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have installed SMON service. Read <a href="https://roxy-wi.org/services.py?service=smon" <h3>You have not installed SMON service. Read <a href="https://roxy-wi.org/services.py?service=smon"
title="Simple monitoring network ports with alerting via Telegram and WEB panel" target="_blank">here</a> how to install SMON service</h3> title="Simple monitoring network ports with alerting via Telegram and WEB panel" target="_blank">here</a> how to install SMON service</h3>
</div> </div>
{% elif smon_status.0 == 'failed' %} {% elif smon_status.0 == 'failed' %}
@ -19,21 +19,21 @@
{% elif smon|length == 0 and action != 'add' and action != 'history' and action != 'checker_history' %} {% elif smon|length == 0 and action != 'add' and action != 'history' and action != 'checker_history' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>You do not have added servers in SMON service. Create you first server <a href="smon.py?action=add" title="Roxy-WI SMON" target="_blank">here</a> before use</h3> <h3>You do not have added servers in SMON service. Create your first server <a href="smon.py?action=add" title="Roxy-WI SMON" target="_blank">here</a> before use</h3>
<br /> <br />
<iframe width="860" height="515" src="https://www.youtube.com/embed/bJtRJeHG5B0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="860" height="515" src="https://www.youtube.com/embed/bJtRJeHG5B0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div> </div>
{% elif smon|length == 0 and action != 'add' and action == 'history' %} {% elif smon|length == 0 and action != 'add' and action == 'history' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3>There are not any events yet. Check if there are any checks added <a href="smon.py?action=add" title="Roxy-WI SMON" target="_blank">here</a></h3> <h3>No events added yet. Click here <a href="smon.py?action=add" title="Roxy-WI SMON" target="_blank">here</a> to see if new check have been added</h3>
<br /> <br />
</div> </div>
{% elif smon|length == 0 and action != 'add' and action == 'checker_history' %} {% elif smon|length == 0 and action != 'add' and action == 'checker_history' %}
<div style="text-align: center;"> <div style="text-align: center;">
<br /> <br />
<h3> <h3>
There are not any events yet. Check if there are any Checker are enabled on the "<a href="hapservers.py" title="HAProxy Overview">HAProxy Overview</a>" No events added yet. Check if there are any Checker are enabled on the "<a href="hapservers.py" title="HAProxy Overview">HAProxy Overview</a>"
or on "<a href="hapservers.py?service=nginx" title="Nginx Overview">Nginx Overview</a>" pages or on "<a href="hapservers.py?service=nginx" title="Nginx Overview">Nginx Overview</a>" pages
</h3> </h3>
<br /> <br />

View File

@ -101,7 +101,7 @@ function add_master_addr(kp) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1') { if (data.indexOf('error:') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, '#creating-master-add', '#wait-mess-add', '#creating-error-add'); showProvisioningError(data, '#creating-master-add', '#wait-mess-add', '#creating-error-add');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning('#creating-master-add', 'master Keepalived', '#creating-warning-add', '#wait_mess-add'); showProvisioningWarning('#creating-master-add', 'master Keepalived', '#creating-warning-add', '#wait_mess-add');
@ -125,7 +125,7 @@ function add_slave_addr(kp) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1') { if (data.indexOf('error:') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, '#creating-slave-add', '#wait-mess-add', '#creating-error-add'); showProvisioningError(data, '#creating-slave-add', '#wait-mess-add', '#creating-error-add');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning('#creating-slave-add', 'master Keepalived', '#creating-warning-add', '#wait_mess-add'); showProvisioningWarning('#creating-slave-add', 'master Keepalived', '#creating-warning-add', '#wait_mess-add');
@ -163,7 +163,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, '#creating-master', '#wait-mess', '#creating-error'); showProvisioningError(data, '#creating-master', '#wait-mess', '#creating-error');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning(step_id, 'master Keepalived', '#creating-warning', '#wait_mess'); showProvisioningWarning(step_id, 'master Keepalived', '#creating-warning', '#wait_mess');
@ -205,7 +205,7 @@ function create_slave_keepalived(hap, nginx, syn_flood) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, '#creating-slave', '#wait-mess', '#creating-error'); showProvisioningError(data, '#creating-slave', '#wait-mess', '#creating-error');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning(step_id, 'slave Keepalived', '#creating-warning', '#wait_mess'); showProvisioningWarning(step_id, 'slave Keepalived', '#creating-warning', '#wait_mess');
@ -249,7 +249,7 @@ function create_keep_alived_hap(nginx, server) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, step_id, '#wait-mess', '#creating-error'); showProvisioningError(data, step_id, '#wait-mess', '#creating-error');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning(step_id, install_step, '#creating-warning', '#wait_mess'); showProvisioningWarning(step_id, install_step, '#creating-warning', '#wait_mess');
@ -285,7 +285,7 @@ function create_keep_alived_nginx(server) {
type: "POST", type: "POST",
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
showProvisioningError(data, step_id, '#wait-mess', '#creating-error'); showProvisioningError(data, step_id, '#wait-mess', '#creating-error');
} else if (data == '' ){ } else if (data == '' ){
showProvisioningWarning(step_id, install_step, '#creating-warning', '#wait_mess'); showProvisioningWarning(step_id, install_step, '#creating-warning', '#wait_mess');

View File

@ -77,7 +77,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajax").html('') $("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.error(data); toastr.error(data);
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
toastr.remove(); toastr.remove();
@ -111,7 +111,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajax").html('') $("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.clear(); toastr.clear();
toastr.error(data); toastr.error(data);
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
@ -141,7 +141,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajaxmon").html(''); $("#ajaxmon").html('');
if (data.indexOf('FAILED') != '-1') { if (data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.clear(); toastr.clear();
toastr.error(data);; toastr.error(data);;
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
@ -170,7 +170,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajaxmon").html(''); $("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.clear(); toastr.clear();
toastr.error(data); toastr.error(data);
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
@ -202,7 +202,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajaxmon").html(''); $("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.error(data); toastr.error(data);
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
toastr.clear(); toastr.clear();
@ -233,7 +233,7 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/\s+/g,' '); data = data.replace(/\s+/g,' ');
$("#ajaxmon").html(''); $("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') { if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') || data.indexOf('UNREACHABLE') != '-1') {
toastr.error(data); toastr.error(data);
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
toastr.clear(); toastr.clear();
@ -1525,16 +1525,22 @@ function updateUser(id) {
toastr.remove(); toastr.remove();
cur_url[0] = cur_url[0].split('#')[0] cur_url[0] = cur_url[0].split('#')[0]
var usergroup = Cookies.get('group'); var usergroup = Cookies.get('group');
var role = $('#role-'+id).val();
var activeuser = 0; var activeuser = 0;
if ($('#activeuser-'+id).is(':checked')) { if ($('#activeuser-'+id).is(':checked')) {
activeuser = '1'; activeuser = '1';
} }
if (role == null){
toastr.warning('Please edit this user only on the Admin area');
return false;
}
toastr.remove();
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {
updateuser: $('#login-'+id).val(), updateuser: $('#login-'+id).val(),
email: $('#email-'+id).val(), email: $('#email-'+id).val(),
role: $('#role-'+id).val(), role: role,
usergroup: usergroup, usergroup: usergroup,
activeuser: activeuser, activeuser: activeuser,
id: id, id: id,