mirror of https://github.com/Aidaho12/haproxy-wi
parent
01aca8e3bd
commit
322dd978bb
102
app/options.py
102
app/options.py
|
@ -577,7 +577,7 @@ if act == "overviewServers":
|
||||||
out1 += r
|
out1 += r
|
||||||
out1 += "<br />"
|
out1 += "<br />"
|
||||||
else:
|
else:
|
||||||
out1 = "Can\'t connect to HAproxy"
|
out1 = "Cannot connect to HAProxy"
|
||||||
else:
|
else:
|
||||||
out1 = ''
|
out1 = ''
|
||||||
|
|
||||||
|
@ -655,9 +655,9 @@ if serv is not None and act == "stats":
|
||||||
try:
|
try:
|
||||||
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
|
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
|
||||||
except requests.exceptions.ConnectTimeout:
|
except requests.exceptions.ConnectTimeout:
|
||||||
print('error: Oops. Connection timeout occured!')
|
print('error: Oops. Connection timeout occurred!')
|
||||||
except requests.exceptions.ReadTimeout:
|
except requests.exceptions.ReadTimeout:
|
||||||
print('error: Oops. Read timeout occured')
|
print('error: Oops. Read timeout occurred')
|
||||||
except requests.exceptions.HTTPError as errh:
|
except requests.exceptions.HTTPError as errh:
|
||||||
print("error: Http Error:", errh)
|
print("error: Http Error:", errh)
|
||||||
except requests.exceptions.ConnectionError as errc:
|
except requests.exceptions.ConnectionError as errc:
|
||||||
|
@ -845,7 +845,7 @@ if form.getvalue('servaction') is not None:
|
||||||
|
|
||||||
if enable != "show":
|
if enable != "show":
|
||||||
print(
|
print(
|
||||||
'<center><h3>You %s %s on HAproxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="runtimeapi.py" title="Runtime API">Edit something else</a></h3><br />' % (enable, backend, serv, serv))
|
'<center><h3>You %s %s on HAProxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="runtimeapi.py" title="Runtime API">Edit something else</a></h3><br />' % (enable, backend, serv, serv))
|
||||||
|
|
||||||
print(funct.ssh_command(serv, command, show_log="1"))
|
print(funct.ssh_command(serv, command, show_log="1"))
|
||||||
action = 'runtimeapi.py ' + enable + ' ' + backend
|
action = 'runtimeapi.py ' + enable + ' ' + backend
|
||||||
|
@ -2772,3 +2772,97 @@ if form.getvalue('edit_aws_provider'):
|
||||||
if sql.update_aws_provider(new_name, new_key, new_secret, provider_id):
|
if sql.update_aws_provider(new_name, new_key, new_secret, provider_id):
|
||||||
print('ok')
|
print('ok')
|
||||||
funct.logging('localhost', 'Provider has been renamed. New name is ' + new_name, provisioning=1)
|
funct.logging('localhost', 'Provider has been renamed. New name is ' + new_name, provisioning=1)
|
||||||
|
|
||||||
|
if form.getvalue('loadservices') or form.getvalue('loadupdatehapwi') or form.getvalue('loadchecker'):
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
|
versions = ''
|
||||||
|
checker_ver = ''
|
||||||
|
smon_ver = ''
|
||||||
|
metrics_ver = ''
|
||||||
|
keep_ver = ''
|
||||||
|
telegrams = ''
|
||||||
|
groups = ''
|
||||||
|
page = ''
|
||||||
|
|
||||||
|
if form.getvalue('loadservices'):
|
||||||
|
template = env.get_template('ajax/load_services.html')
|
||||||
|
elif form.getvalue('loadupdatehapwi'):
|
||||||
|
versions = funct.versions()
|
||||||
|
checker_ver = funct.check_new_version(service='checker')
|
||||||
|
smon_ver = funct.check_new_version(service='smon')
|
||||||
|
metrics_ver = funct.check_new_version(service='metrics')
|
||||||
|
keep_ver = funct.check_new_version(service='keep')
|
||||||
|
template = env.get_template('ajax/load_updatehapwi.html')
|
||||||
|
elif form.getvalue('loadchecker'):
|
||||||
|
groups = sql.select_groups()
|
||||||
|
page = form.getvalue('page')
|
||||||
|
if page == 'servers.py':
|
||||||
|
user_group = funct.get_user_group(id=1)
|
||||||
|
telegrams = sql.get_user_telegram_by_group(user_group)
|
||||||
|
else:
|
||||||
|
telegrams = sql.select_telegram()
|
||||||
|
|
||||||
|
template = env.get_template('ajax/load_telegram.html')
|
||||||
|
|
||||||
|
services = []
|
||||||
|
services_name = {'checker_haproxy': 'Checker backends master service',
|
||||||
|
'keep_alive': 'Auto start service',
|
||||||
|
'metrics_haproxy': 'Metrics master service',
|
||||||
|
'prometheus': 'Prometheus service',
|
||||||
|
'grafana-server': 'Grafana service',
|
||||||
|
'smon': 'Simple monitoring network ports',
|
||||||
|
'fail2ban': 'Fail2ban service'}
|
||||||
|
for s, v in services_name.items():
|
||||||
|
cmd = "systemctl status %s |grep Act |awk '{print $2}'" % s
|
||||||
|
status, stderr = funct.subprocess_execute(cmd)
|
||||||
|
if s != 'keep_alive':
|
||||||
|
service_name = s.split('_')[0]
|
||||||
|
else:
|
||||||
|
service_name = s
|
||||||
|
cmd = "rpm --query haproxy-wi-" + service_name + "-* |awk -F\"" + service_name + "\" '{print $2}' |awk -F\".noa\" '{print $1}' |sed 's/-//1' |sed 's/-/./'"
|
||||||
|
service_ver, stderr = funct.subprocess_execute(cmd)
|
||||||
|
|
||||||
|
try:
|
||||||
|
services.append([s, status, v, service_ver[0]])
|
||||||
|
except Exception:
|
||||||
|
services.append([s, status, v, ''])
|
||||||
|
|
||||||
|
template = template.render(services=services,
|
||||||
|
versions=versions,
|
||||||
|
checker_ver=checker_ver,
|
||||||
|
smon_ver=smon_ver,
|
||||||
|
metrics_ver=metrics_ver,
|
||||||
|
keep_ver=keep_ver,
|
||||||
|
telegrams=telegrams,
|
||||||
|
groups=groups,
|
||||||
|
page=page)
|
||||||
|
print(template)
|
||||||
|
|
||||||
|
if form.getvalue('loadopenvpn'):
|
||||||
|
import platform
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
env = Environment(loader=FileSystemLoader('templates'))
|
||||||
|
template = env.get_template('ajax/load_openvpn.html')
|
||||||
|
openvpn_configs = ''
|
||||||
|
openvpn_sess = ''
|
||||||
|
openvpn = ''
|
||||||
|
|
||||||
|
try:
|
||||||
|
os_name = platform.linux_distribution()[0]
|
||||||
|
except Exception:
|
||||||
|
os_name = ''
|
||||||
|
|
||||||
|
if os_name == 'CentOS Linux' or os_name == 'Red Hat Enterprise Linux Server':
|
||||||
|
stdout, stderr = funct.subprocess_execute("rpm --query openvpn3-client")
|
||||||
|
if stdout[0] != 'package openvpn3-client is not installed' and stderr != '/bin/sh: rpm: command not found':
|
||||||
|
cmd = "sudo openvpn3 configs-list |grep -E 'ovpn|(^|[^0-9])[0-9]{4}($|[^0-9])' |grep -v net|awk -F\" \" '{print $1}'|awk 'ORS=NR%2?\" \":\"\\n\"'"
|
||||||
|
openvpn_configs, stderr = funct.subprocess_execute(cmd)
|
||||||
|
cmd = "sudo openvpn3 sessions-list|grep -E 'Config|Status'|awk -F\":\" '{print $2}'|awk 'ORS=NR%2?\" \":\"\\n\"'| sed 's/^ //g'"
|
||||||
|
openvpn_sess, stderr = funct.subprocess_execute(cmd)
|
||||||
|
openvpn = stdout[0]
|
||||||
|
|
||||||
|
template = template.render(openvpn=openvpn,
|
||||||
|
openvpn_sess=openvpn_sess,
|
||||||
|
openvpn_configs=openvpn_configs)
|
||||||
|
print(template)
|
||||||
|
|
|
@ -12,28 +12,10 @@ funct.page_for_admin(level=2)
|
||||||
try:
|
try:
|
||||||
user, user_id, role, token, servers = funct.get_users_params()
|
user, user_id, role, token, servers = funct.get_users_params()
|
||||||
ldap_enable = sql.get_setting('ldap_enable')
|
ldap_enable = sql.get_setting('ldap_enable')
|
||||||
grafana, stderr = funct.subprocess_execute("service grafana-server status |grep Active |awk '{print $1}'")
|
|
||||||
user_group = funct.get_user_group(id=1)
|
user_group = funct.get_user_group(id=1)
|
||||||
settings = sql.get_setting('', all=1)
|
settings = sql.get_setting('', all=1)
|
||||||
geoip_country_codes = sql.select_geoip_country_codes()
|
geoip_country_codes = sql.select_geoip_country_codes()
|
||||||
|
|
||||||
services = []
|
|
||||||
services_name = {'checker_haproxy': 'Checker backends master service',}
|
|
||||||
for s, v in services_name.items():
|
|
||||||
cmd = "systemctl status %s |grep Act |awk '{print $2}'" % s
|
|
||||||
status, stderr = funct.subprocess_execute(cmd)
|
|
||||||
if s != 'keep_alive':
|
|
||||||
service_name = s.split('_')[0]
|
|
||||||
else:
|
|
||||||
service_name = s
|
|
||||||
cmd = "rpm --query haproxy-wi-"+service_name+"-* |awk -F\""+service_name + "\" '{print $2}' |awk -F\".noa\" '{print $1}' |sed 's/-//1' |sed 's/-/./'"
|
|
||||||
service_ver, stderr = funct.subprocess_execute(cmd)
|
|
||||||
|
|
||||||
try:
|
|
||||||
services.append([s, status, v, service_ver[0]])
|
|
||||||
except Exception:
|
|
||||||
services.append([s, status, v, ''])
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -48,13 +30,10 @@ output_from_parsed_template = template.render(title="Servers: ",
|
||||||
masters=sql.select_servers(get_master_servers=1, uuid=user_id.value),
|
masters=sql.select_servers(get_master_servers=1, uuid=user_id.value),
|
||||||
group=user_group,
|
group=user_group,
|
||||||
sshs=sql.select_ssh(group=user_group),
|
sshs=sql.select_ssh(group=user_group),
|
||||||
telegrams=sql.get_user_telegram_by_group(user_group),
|
|
||||||
token=token,
|
token=token,
|
||||||
settings=settings,
|
settings=settings,
|
||||||
backups=sql.select_backups(),
|
backups=sql.select_backups(),
|
||||||
grafana=''.join(grafana),
|
|
||||||
page="servers.py",
|
page="servers.py",
|
||||||
geoip_country_codes=geoip_country_codes,
|
geoip_country_codes=geoip_country_codes,
|
||||||
services=services,
|
|
||||||
ldap_enable=ldap_enable)
|
ldap_enable=ldap_enable)
|
||||||
print(output_from_parsed_template)
|
print(output_from_parsed_template)
|
||||||
|
|
|
@ -75,101 +75,9 @@
|
||||||
{% include 'include/admin_ssh.html' %}
|
{% include 'include/admin_ssh.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="checker">
|
<div id="checker"></div>
|
||||||
{% include 'include/admin_telegram.html' %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="openvpn">
|
<div id="openvpn"></div>
|
||||||
{% if openvpn != '' %}
|
|
||||||
<table id="openvpn_table" class="overview">
|
|
||||||
<caption><h3>OpenVPN profiles</h3></caption>
|
|
||||||
<tr class="overviewHead">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
Profile name
|
|
||||||
</td>
|
|
||||||
<td class="padding10 first-collumn" style="width: 35%;">
|
|
||||||
Time of creation
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% for c in openvpn_configs %}
|
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{c.split('/')[-1].split('.')[0]}}">
|
|
||||||
<td class="padding10 first-collumn">
|
|
||||||
{{c.split('/')[-1]}}
|
|
||||||
</td>
|
|
||||||
<td style="width: 100%">
|
|
||||||
{{c.split('/')[0]}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="service-start" onclick="OpenVpnSess('{{c.split('/')[-1].split('.')[0]}}', 'start')" title="Start OpenVPN with profile {{c.split('/')[-1]}}"></a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="delete" onclick="confirmDeleteOpenVpnProfile('{{c.split('/')[-1].split('.')[0]}}')" title="Delete OpenVPN profile {{c.split('/')[-1]}}" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<br />
|
|
||||||
<table id="openvpn_table" class="overview">
|
|
||||||
<caption><h3>OpenVPN sessions</h3></caption>
|
|
||||||
<tr class="overviewHead">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
Session name
|
|
||||||
</td>
|
|
||||||
<td class="padding10 first-collumn" style="width: 35%;">
|
|
||||||
Status
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% for c in openvpn_sess %}
|
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }}">
|
|
||||||
<td class="padding10 first-collumn">
|
|
||||||
{{c.split(' ')[0]}}
|
|
||||||
</td>
|
|
||||||
<td style="width: 100%">
|
|
||||||
{{c.split(' ')[4]}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="service-reload" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'restart')" title="Restart OpenVPN with profile {{c.split('/')[0]}}"></a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="delete" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'disconnect')" title="Disconnect OpenVPN profile {{c.split('/')[2]}}" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<br />
|
|
||||||
<table id="openvpn_upload_table" class="overview">
|
|
||||||
<caption><h3>Uploading ovpn files</h3></caption>
|
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">Ovpn file name</td>
|
|
||||||
<td>
|
|
||||||
<span title="Ovpn file must be with an auto-login profile">Upload ovpn file (?)</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr style="width: 50%;">
|
|
||||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
|
||||||
{{ input('ovpn_upload_name', size='30') }}
|
|
||||||
</td>
|
|
||||||
<td style="padding-top: 15px;">
|
|
||||||
<textarea id="ovpn_upload_file" cols="50" rows="5"></textarea><br /><br />
|
|
||||||
<a class="ui-button ui-widget ui-corner-all" id="ovpn_upload" title="Upload ovpn file" onclick="uploadOvpn()">Upload</a>
|
|
||||||
<br /><br />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
<center>
|
|
||||||
<br />
|
|
||||||
<h3>You do not have installed OpenVPN client.
|
|
||||||
Read <a href="https://haproxy-wi.org/services.py?service=openvpn" title="OpenVPN" style="color: #5d9ceb;" target="_blank">hear</a>
|
|
||||||
how to install OpenVPN client</h3>
|
|
||||||
</center>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="settings">
|
<div id="settings">
|
||||||
{% include 'include/admin_settings.html' %}
|
{% include 'include/admin_settings.html' %}
|
||||||
|
@ -177,45 +85,18 @@
|
||||||
|
|
||||||
<div id="services">
|
<div id="services">
|
||||||
<table id="services_table" class="overview">
|
<table id="services_table" class="overview">
|
||||||
<tr class="overviewHead">
|
<thead>
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
<tr class="overviewHead">
|
||||||
Service
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
</td>
|
Service
|
||||||
<td class="padding10 first-collumn" style="width: 35%;">
|
|
||||||
Actions
|
|
||||||
</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
{% for s in services %}
|
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s.0}}">
|
|
||||||
<td class="padding10 first-collumn">
|
|
||||||
{% if s.1.0 == 'active' %}
|
|
||||||
<span title="{{s.0}} is started"><span class="serverUp server-status"></span></span>
|
|
||||||
{% else %}
|
|
||||||
{% if s.1.0 == 'inactive' or s.1.0 == 'failed' %}
|
|
||||||
<span title="{{s.0}} is stoped"><span class="serverDown server-status"></span></span>
|
|
||||||
{% else %}
|
|
||||||
<span title="{{s.0}} is not installed"><span class="serverNone server-status"></span></span>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{{s.0}}
|
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn" style="width: 35%;">
|
||||||
<a id="start-{{ s.0 }}" class="start" title="Start and enable {{s.0}} service">
|
Actions
|
||||||
<span class="service-start" onclick="confirmAjaxServiceAction('start', '{{s.0}}')"></span>
|
|
||||||
</a>
|
|
||||||
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{s.0}} service">
|
|
||||||
<span class="service-reload service-restart" onclick="confirmAjaxServiceAction('restart', '{{s.0}}')"></span>
|
|
||||||
</a>
|
|
||||||
<a id="stop-{{ s.0 }}" class="stop" title="Stop and disable {{s.0}} service">
|
|
||||||
<span class="service-stop" onclick="confirmAjaxServiceAction('stop', '{{s.0}}')"></span>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{ s.2 }}
|
|
||||||
</td>
|
</td>
|
||||||
|
<td>Description</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
</thead>
|
||||||
|
<tbody id="ajax-services-body"></tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
You can read about services <a href="https://haproxy-wi.org/services.py" title="HAProxy-WI services" target="_blank">here</a>
|
You can read about services <a href="https://haproxy-wi.org/services.py" title="HAProxy-WI services" target="_blank">here</a>
|
||||||
|
@ -223,11 +104,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="updatehapwi">
|
<div id="updatehapwi">
|
||||||
{% set current_ver = versions.0 %}
|
|
||||||
{% set new_ver = versions.1 %}
|
|
||||||
{% set current_ver_without_dots = versions.2 %}
|
|
||||||
{% set new_ver_without_dots = versions.3 %}
|
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
|
<thead>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">Service</td>
|
<td class="padding10 first-collumn" style="width: 25%;">Service</td>
|
||||||
<td>Currnet version</td>
|
<td>Currnet version</td>
|
||||||
|
@ -237,95 +115,8 @@
|
||||||
Description
|
Description
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
</thead>
|
||||||
<td class="padding10 first-collumn">
|
<tbody id="ajax-updatehapwi-body"></tbody>
|
||||||
HAProxy-WI
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<b>{{current_ver}}</b>
|
|
||||||
</td>
|
|
||||||
<td class="padding10">
|
|
||||||
<b>{{new_ver}}</b>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if new_ver_without_dots > current_ver_without_dots and new_ver != "Sorry cannot get current version" %}
|
|
||||||
<a class="ui-button ui-widget ui-corner-all" onclick="updateService('haproxy-wi')" title="Update HAProxy-WI">Update</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
The main application
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% for s in services %}
|
|
||||||
{% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' %}
|
|
||||||
<tr>
|
|
||||||
{% set is_need_update = 0 %}
|
|
||||||
{% if s.0 == 'smon' %}
|
|
||||||
{% set service_name = 'SMON' %}
|
|
||||||
{% set service_link = 'smon' %}
|
|
||||||
{% set desc_link = 'https://haproxy-wi.org/services.py?service=smon' %}
|
|
||||||
{% if s.3|float < smon_ver|float %}
|
|
||||||
{% set is_need_update = 1 %}
|
|
||||||
{% endif %}
|
|
||||||
{% elif s.0 == 'checker_haproxy' %}
|
|
||||||
{% set service_name = 'Checker' %}
|
|
||||||
{% set service_link = 'checker' %}
|
|
||||||
{% set desc_link = 'https://haproxy-wi.org/services.py?service=checker' %}
|
|
||||||
{% if s.3|float < checker_ver|float %}
|
|
||||||
{% set is_need_update = 1 %}
|
|
||||||
{% endif %}
|
|
||||||
{% elif s.0 == 'keep_alive' %}
|
|
||||||
{% set service_name = 'Auto start' %}
|
|
||||||
{% set service_link = 'auto_start' %}
|
|
||||||
{% set desc_link = 'https://haproxy-wi.org/services.py?service=auto_start' %}
|
|
||||||
{% if s.3|float < keep_ver|float %}
|
|
||||||
{% set is_need_update = 1 %}
|
|
||||||
{% endif %}
|
|
||||||
{% elif s.0 == 'metrics_haproxy' %}
|
|
||||||
{% set service_name = 'Metrics' %}
|
|
||||||
{% set service_link = 'metrics' %}
|
|
||||||
{% set desc_link = 'https://haproxy-wi.org/services.py?service=metrics' %}
|
|
||||||
{% if s.3|float < metrics_ver|float %}
|
|
||||||
{% set is_need_update = 1 %}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
<td class="padding10 first-collumn">
|
|
||||||
{{service_name}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if s.3 != '* is not installed' %}
|
|
||||||
<b>{{s.3}}</b>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td class="padding10">
|
|
||||||
<b>
|
|
||||||
{% if s.0 == 'smon' %}
|
|
||||||
{{smon_ver}}
|
|
||||||
{% elif s.0 == 'checker_haproxy' %}
|
|
||||||
{{checker_ver}}
|
|
||||||
{% elif s.0 == 'keep_alive' %}
|
|
||||||
{{keep_ver}}
|
|
||||||
{% elif s.0 == 'metrics_haproxy' %}
|
|
||||||
{{metrics_ver}}
|
|
||||||
{% endif %}
|
|
||||||
</b>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if s.3 != '* is not installed' %}
|
|
||||||
{% if is_need_update %}
|
|
||||||
<a class="ui-button ui-widget ui-corner-all" onclick="updateService('{{s.0}}')" title="Update {{service_name}}">Update</a>
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
{{service_name}} service is not installed
|
|
||||||
<a href="https://haproxy-wi.org/services.py?service={{service_link}}#installation" title="{{service_name}} installation" target="_blank" style="color: #5d9ceb;">Read about installation</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
Read more about <a href="{{desc_link}}" title="Read more about {{service_name}}" target="_blank" class="link">{{service_name}}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
</table>
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
<b style="font-size: 20px; display: block; padding-bottom: 10px;">Note:</b>
|
<b style="font-size: 20px; display: block; padding-bottom: 10px;">Note:</b>
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
{% from 'include/input_macros.html' import input, select %}
|
||||||
|
{% if openvpn != '' %}
|
||||||
|
<table id="openvpn_table" class="overview">
|
||||||
|
<caption><h3>OpenVPN profiles</h3></caption>
|
||||||
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
Profile name
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn" style="width: 35%;">
|
||||||
|
Time of creation
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% for c in openvpn_configs %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{c.split('/')[-1].split('.')[0]}}">
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{{c.split('/')[-1]}}
|
||||||
|
</td>
|
||||||
|
<td style="width: 100%">
|
||||||
|
{{c.split('/')[0]}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="service-start" onclick="OpenVpnSess('{{c.split('/')[-1].split('.')[0]}}', 'start')" title="Start OpenVPN with profile {{c.split('/')[-1]}}"></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="delete" onclick="confirmDeleteOpenVpnProfile('{{c.split('/')[-1].split('.')[0]}}')" title="Delete OpenVPN profile {{c.split('/')[-1]}}" style="cursor: pointer;"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<table id="openvpn_table" class="overview">
|
||||||
|
<caption><h3>OpenVPN sessions</h3></caption>
|
||||||
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
Session name
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn" style="width: 35%;">
|
||||||
|
Status
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% for c in openvpn_sess %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}">
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{{c.split(' ')[0]}}
|
||||||
|
</td>
|
||||||
|
<td style="width: 100%">
|
||||||
|
{{c.split(' ')[4]}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="service-reload" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'restart')" title="Restart OpenVPN with profile {{c.split('/')[0]}}"></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="delete" onclick="OpenVpnSess('{{c.split(' ')[0]}}', 'disconnect')" title="Disconnect OpenVPN profile {{c.split('/')[2]}}" style="cursor: pointer;"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<table id="openvpn_upload_table" class="overview">
|
||||||
|
<caption><h3>Uploading ovpn files</h3></caption>
|
||||||
|
<tr class="overviewHead" style="width: 50%;">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">Ovpn file name</td>
|
||||||
|
<td>
|
||||||
|
<span title="Ovpn file must be with an auto-login profile">Upload ovpn file (?)</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr style="width: 50%;">
|
||||||
|
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||||
|
{{ input('ovpn_upload_name', size='30') }}
|
||||||
|
</td>
|
||||||
|
<td style="padding-top: 15px;">
|
||||||
|
<textarea id="ovpn_upload_file" cols="50" rows="5"></textarea><br /><br />
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" id="ovpn_upload" title="Upload ovpn file" onclick="uploadOvpn()">Upload</a>
|
||||||
|
<br /><br />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<center>
|
||||||
|
<br />
|
||||||
|
<h3>You do not have installed OpenVPN client.
|
||||||
|
Read <a href="https://haproxy-wi.org/services.py?service=openvpn" title="OpenVPN" style="color: #5d9ceb;" target="_blank">hear</a>
|
||||||
|
how to install OpenVPN client</h3>
|
||||||
|
</center>
|
||||||
|
{% endif %}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{% for s in services %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s.0}}">
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{% if s.1.0 == 'active' %}
|
||||||
|
<span title="{{s.0}} is started"><span class="serverUp server-status"></span></span>
|
||||||
|
{% else %}
|
||||||
|
{% if s.1.0 == 'inactive' or s.1.0 == 'failed' %}
|
||||||
|
<span title="{{s.0}} is stoped"><span class="serverDown server-status"></span></span>
|
||||||
|
{% else %}
|
||||||
|
<span title="{{s.0}} is not installed"><span class="serverNone server-status"></span></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{{s.0}}
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
<a id="start-{{ s.0 }}" class="start" title="Start and enable {{s.0}} service">
|
||||||
|
<span class="service-start" onclick="confirmAjaxServiceAction('start', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
<a id="restart-{{ s.2 }}" class="restart" title="Restart {{s.0}} service">
|
||||||
|
<span class="service-reload service-restart" onclick="confirmAjaxServiceAction('restart', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
<a id="stop-{{ s.0 }}" class="stop" title="Stop and disable {{s.0}} service">
|
||||||
|
<span class="service-stop" onclick="confirmAjaxServiceAction('stop', '{{s.0}}')"></span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ s.2 }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
|
@ -0,0 +1,66 @@
|
||||||
|
{% from 'include/input_macros.html' import input, select %}
|
||||||
|
{% for s in services %}
|
||||||
|
{% if s.0 == 'checker_haproxy' %}
|
||||||
|
{% if s.3 != '* is not installed' and s.3 != '' %}
|
||||||
|
<table id="checker_table" class="overview">
|
||||||
|
<tr class="overviewHead" style="width: 50%;">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
<span title="Token that has given @father_bot">Token</span>
|
||||||
|
</td>
|
||||||
|
<td style="width: {% if page == "servers.py" %}100{% else %}20{% endif %}%;">Channel name</td>
|
||||||
|
{% if page != "servers.py" %}
|
||||||
|
<td style="width: 100%;">Group</td>
|
||||||
|
{% endif %}
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% for telegram in telegrams %}
|
||||||
|
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{% set id = 'telegram-token-' + telegram.0|string() %}
|
||||||
|
{{ input(id, value=telegram.1, size='30') }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% set id = 'telegram-chanel-' + telegram.0|string() %}
|
||||||
|
{{ input(id, value=telegram.2) }}
|
||||||
|
</td>
|
||||||
|
{% if page != "servers.py" %}
|
||||||
|
<td>
|
||||||
|
<select id="telegramgroup-{{telegram.0}}" name="telegramgroup-{{telegram.0}}">
|
||||||
|
<option disabled selected>Choose group</option>
|
||||||
|
{% for group in groups %}
|
||||||
|
{% if telegram.3|string() == group.0|string() %}
|
||||||
|
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
<td>
|
||||||
|
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.2}}" style="cursor: pointer;"></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="delete" onclick="confirmDeleteTelegram({{telegram.0}})" title="Delete channel {{telegram.2}}" style="cursor: pointer;"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<br /><span class="add-button" title="Add telegram channel" id="add-telegram-button">+ Add</span>
|
||||||
|
<br /><br />
|
||||||
|
<div id="ajax-telegram"></div>
|
||||||
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
|
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
|
||||||
|
and How to create and use Telegram bot in this <a href="https://haproxy-wi.org/howto.py?howto=checker" title="How to create Telegram bot and use it with HAProxy-WI" target="_blank">article</a>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<center>
|
||||||
|
<br />
|
||||||
|
<h3>You do not have installed Backends checker
|
||||||
|
Read <a href="https://haproxy-wi.org/services.py?service=checker#installation" title="Checker installation" style="color: #5d9ceb;" target="_blank">hear</a>
|
||||||
|
how to install Checker service</h3>
|
||||||
|
</center>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
|
@ -0,0 +1,93 @@
|
||||||
|
{% set current_ver = versions.0 %}
|
||||||
|
{% set new_ver = versions.1 %}
|
||||||
|
{% set current_ver_without_dots = versions.2 %}
|
||||||
|
{% set new_ver_without_dots = versions.3 %}
|
||||||
|
<tr>
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
HAProxy-WI
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>{{current_ver}}</b>
|
||||||
|
</td>
|
||||||
|
<td class="padding10">
|
||||||
|
<b>{{new_ver}}</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if new_ver_without_dots > current_ver_without_dots and new_ver != "Sorry cannot get current version" %}
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" onclick="updateService('haproxy-wi')" title="Update HAProxy-WI">Update</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
The main application
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% for s in services %}
|
||||||
|
{% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' %}
|
||||||
|
<tr>
|
||||||
|
{% set is_need_update = 0 %}
|
||||||
|
{% if s.0 == 'smon' %}
|
||||||
|
{% set service_name = 'SMON' %}
|
||||||
|
{% set service_link = 'smon' %}
|
||||||
|
{% set desc_link = 'https://haproxy-wi.org/services.py?service=smon' %}
|
||||||
|
{% if s.3|float < smon_ver|float %}
|
||||||
|
{% set is_need_update = 1 %}
|
||||||
|
{% endif %}
|
||||||
|
{% elif s.0 == 'checker_haproxy' %}
|
||||||
|
{% set service_name = 'Checker' %}
|
||||||
|
{% set service_link = 'checker' %}
|
||||||
|
{% set desc_link = 'https://haproxy-wi.org/services.py?service=checker' %}
|
||||||
|
{% if s.3|float < checker_ver|float %}
|
||||||
|
{% set is_need_update = 1 %}
|
||||||
|
{% endif %}
|
||||||
|
{% elif s.0 == 'keep_alive' %}
|
||||||
|
{% set service_name = 'Auto start' %}
|
||||||
|
{% set service_link = 'auto_start' %}
|
||||||
|
{% set desc_link = 'https://haproxy-wi.org/services.py?service=auto_start' %}
|
||||||
|
{% if s.3|float < keep_ver|float %}
|
||||||
|
{% set is_need_update = 1 %}
|
||||||
|
{% endif %}
|
||||||
|
{% elif s.0 == 'metrics_haproxy' %}
|
||||||
|
{% set service_name = 'Metrics' %}
|
||||||
|
{% set service_link = 'metrics' %}
|
||||||
|
{% set desc_link = 'https://haproxy-wi.org/services.py?service=metrics' %}
|
||||||
|
{% if s.3|float < metrics_ver|float %}
|
||||||
|
{% set is_need_update = 1 %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<td class="padding10 first-collumn">
|
||||||
|
{{service_name}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if s.3 != '* is not installed' %}
|
||||||
|
<b>{{s.3}}</b>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="padding10">
|
||||||
|
<b>
|
||||||
|
{% if s.0 == 'smon' %}
|
||||||
|
{{smon_ver}}
|
||||||
|
{% elif s.0 == 'checker_haproxy' %}
|
||||||
|
{{checker_ver}}
|
||||||
|
{% elif s.0 == 'keep_alive' %}
|
||||||
|
{{keep_ver}}
|
||||||
|
{% elif s.0 == 'metrics_haproxy' %}
|
||||||
|
{{metrics_ver}}
|
||||||
|
{% endif %}
|
||||||
|
</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if s.3 != '* is not installed' %}
|
||||||
|
{% if is_need_update %}
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" onclick="updateService('{{s.0}}')" title="Update {{service_name}}">Update</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{service_name}} service is not installed
|
||||||
|
<a href="https://haproxy-wi.org/services.py?service={{service_link}}#installation" title="{{service_name}} installation" target="_blank" style="color: #5d9ceb;">Read about installation</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Read more about <a href="{{desc_link}}" title="Read more about {{service_name}}" target="_blank" class="link">{{service_name}}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
|
@ -1,65 +0,0 @@
|
||||||
{% for s in services %}
|
|
||||||
{% if s.0 == 'checker_haproxy' %}
|
|
||||||
{% if s.3 != '* is not installed' %}
|
|
||||||
<table id="checker_table" class="overview">
|
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
<span title="Token that has given @father_bot">Token</span>
|
|
||||||
</td>
|
|
||||||
<td style="width: {% if page == "servers.py" %}100{% else %}20{% endif %}%;">Channel name</td>
|
|
||||||
{% if page != "servers.py" %}
|
|
||||||
<td style="width: 100%;">Group</td>
|
|
||||||
{% endif %}
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% for telegram in telegrams %}
|
|
||||||
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
|
||||||
<td class="padding10 first-collumn">
|
|
||||||
{% set id = 'telegram-token-' + telegram.0|string() %}
|
|
||||||
{{ input(id, value=telegram.1, size='30') }}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% set id = 'telegram-chanel-' + telegram.0|string() %}
|
|
||||||
{{ input(id, value=telegram.2) }}
|
|
||||||
</td>
|
|
||||||
{% if page != "servers.py" %}
|
|
||||||
<td>
|
|
||||||
<select id="telegramgroup-{{telegram.0}}" name="telegramgroup-{{telegram.0}}">
|
|
||||||
<option disabled selected>Choose group</option>
|
|
||||||
{% for group in groups %}
|
|
||||||
{% if telegram.3|string() == group.0|string() %}
|
|
||||||
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
{% endif %}
|
|
||||||
<td>
|
|
||||||
<a class="add" onclick="cloneTelegram({{telegram.0}})" id="clone-{{telegram.0}}" title="Clone {{telegram.2}}" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="delete" onclick="confirmDeleteTelegram({{telegram.0}})" title="Delete channel {{telegram.2}}" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<br /><span class="add-button" title="Add telegram channel" id="add-telegram-button">+ Add</span>
|
|
||||||
<br /><br />
|
|
||||||
<div id="ajax-telegram"></div>
|
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
|
||||||
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
|
|
||||||
and How to create and use Telegram bot in this <a href="https://haproxy-wi.org/howto.py?howto=checker" title="How to create Telegram bot and use it with HAProxy-WI" target="_blank">article</a>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<center>
|
|
||||||
<br />
|
|
||||||
<h3>You do not have installed Backends checker
|
|
||||||
Read <a href="https://haproxy-wi.org/services.py?service=checker#installation" title="Checker installation" style="color: #5d9ceb;" target="_blank">hear</a>
|
|
||||||
how to install Checker service</h3>
|
|
||||||
</center>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
|
@ -36,10 +36,7 @@
|
||||||
{% include 'include/servers_group_error.html' %}
|
{% include 'include/servers_group_error.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="checker">
|
<div id="checker"></div>
|
||||||
{% include 'include/admin_telegram.html' %}
|
|
||||||
{% include 'include/servers_group_error.html' %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="settings">
|
<div id="settings">
|
||||||
{% include 'include/admin_settings.html' %}
|
{% include 'include/admin_settings.html' %}
|
||||||
|
|
52
app/users.py
52
app/users.py
|
@ -3,13 +3,10 @@
|
||||||
import funct
|
import funct
|
||||||
import sql
|
import sql
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import platform
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('admin.html')
|
template = env.get_template('admin.html')
|
||||||
form = funct.form
|
form = funct.form
|
||||||
openvpn_configs = ''
|
|
||||||
openvpn_sess = ''
|
|
||||||
openvpn = ''
|
|
||||||
|
|
||||||
print('Content-type: text/html\n')
|
print('Content-type: text/html\n')
|
||||||
|
|
||||||
|
@ -23,43 +20,6 @@ try:
|
||||||
ldap_enable = sql.get_setting('ldap_enable')
|
ldap_enable = sql.get_setting('ldap_enable')
|
||||||
grafana, stderr = funct.subprocess_execute("service grafana-server status |grep Active |awk '{print $1}'")
|
grafana, stderr = funct.subprocess_execute("service grafana-server status |grep Active |awk '{print $1}'")
|
||||||
|
|
||||||
services = []
|
|
||||||
services_name = {'checker_haproxy': 'Checker backends master service',
|
|
||||||
'keep_alive': 'Auto start service',
|
|
||||||
'metrics_haproxy': 'Metrics master service',
|
|
||||||
'prometheus': 'Prometheus service',
|
|
||||||
'grafana-server': 'Grafana service',
|
|
||||||
'smon': 'Simple monitoring network ports',
|
|
||||||
'fail2ban': 'Fail2ban service'}
|
|
||||||
for s, v in services_name.items():
|
|
||||||
cmd = "systemctl status %s |grep Act |awk '{print $2}'" % s
|
|
||||||
status, stderr = funct.subprocess_execute(cmd)
|
|
||||||
if s != 'keep_alive':
|
|
||||||
service_name = s.split('_')[0]
|
|
||||||
else:
|
|
||||||
service_name = s
|
|
||||||
cmd = "rpm --query haproxy-wi-"+service_name+"-* |awk -F\""+service_name + "\" '{print $2}' |awk -F\".noa\" '{print $1}' |sed 's/-//1' |sed 's/-/./'"
|
|
||||||
service_ver, stderr = funct.subprocess_execute(cmd)
|
|
||||||
|
|
||||||
try:
|
|
||||||
services.append([s, status, v, service_ver[0]])
|
|
||||||
except Exception:
|
|
||||||
services.append([s, status, v, ''])
|
|
||||||
|
|
||||||
try:
|
|
||||||
os_name = platform.linux_distribution()[0]
|
|
||||||
except Exception:
|
|
||||||
os_name = ''
|
|
||||||
|
|
||||||
if os_name == 'CentOS Linux' or os_name == 'Red Hat Enterprise Linux Server':
|
|
||||||
stdout, stderr = funct.subprocess_execute("rpm --query openvpn3-client")
|
|
||||||
if stdout[0] != 'package openvpn3-client is not installed' and stderr != '/bin/sh: rpm: command not found':
|
|
||||||
cmd = "sudo openvpn3 configs-list |grep -E 'ovpn|(^|[^0-9])[0-9]{4}($|[^0-9])' |grep -v net|awk -F\" \" '{print $1}'|awk 'ORS=NR%2?\" \":\"\\n\"'"
|
|
||||||
openvpn_configs, stderr = funct.subprocess_execute(cmd)
|
|
||||||
cmd = "sudo openvpn3 sessions-list|grep -E 'Config|Status'|awk -F\":\" '{print $2}'|awk 'ORS=NR%2?\" \":\"\\n\"'| sed 's/^ //g'"
|
|
||||||
openvpn_sess, stderr = funct.subprocess_execute(cmd)
|
|
||||||
openvpn = stdout[0]
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -73,19 +33,9 @@ template = template.render(title="Admin area: Manage users",
|
||||||
roles=sql.select_roles(),
|
roles=sql.select_roles(),
|
||||||
masters=sql.select_servers(get_master_servers=1),
|
masters=sql.select_servers(get_master_servers=1),
|
||||||
sshs=sql.select_ssh(),
|
sshs=sql.select_ssh(),
|
||||||
telegrams=sql.select_telegram(),
|
|
||||||
token=token,
|
token=token,
|
||||||
versions=funct.versions(),
|
|
||||||
checker_ver=funct.check_new_version(service='checker'),
|
|
||||||
smon_ver=funct.check_new_version(service='smon'),
|
|
||||||
metrics_ver=funct.check_new_version(service='metrics'),
|
|
||||||
keep_ver=funct.check_new_version(service='keep'),
|
|
||||||
openvpn=openvpn,
|
|
||||||
openvpn_configs=openvpn_configs,
|
|
||||||
openvpn_sess=openvpn_sess,
|
|
||||||
settings=settings,
|
settings=settings,
|
||||||
backups=sql.select_backups(),
|
backups=sql.select_backups(),
|
||||||
services=services,
|
|
||||||
grafana=''.join(grafana),
|
grafana=''.join(grafana),
|
||||||
page="users.py",
|
page="users.py",
|
||||||
ldap_enable=ldap_enable)
|
ldap_enable=ldap_enable)
|
||||||
|
|
128
inc/users.js
128
inc/users.js
|
@ -776,7 +776,38 @@ $( function() {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
});
|
});
|
||||||
|
$("#tabs ul li").click(function() {
|
||||||
|
var activeTab = $(this).find("a").attr("href");
|
||||||
|
|
||||||
|
if (activeTab == '#services') {
|
||||||
|
loadServices();
|
||||||
|
} else if (activeTab == '#updatehapwi') {
|
||||||
|
loadupdatehapwi();
|
||||||
|
} else if (activeTab == '#checker'){
|
||||||
|
loadchecker();
|
||||||
|
} else if (activeTab == '#openvpn'){
|
||||||
|
loadopenvpn();
|
||||||
|
}
|
||||||
|
});
|
||||||
} );
|
} );
|
||||||
|
window.onload = function() {
|
||||||
|
var activeTabIdx = $('#tabs').tabs('option','active')
|
||||||
|
if (cur_url[0].split('#')[0] == 'users.py') {
|
||||||
|
if (activeTabIdx == 7) {
|
||||||
|
loadServices();
|
||||||
|
} else if (activeTabIdx == 8) {
|
||||||
|
loadupdatehapwi();
|
||||||
|
} else if (activeTabIdx == 4) {
|
||||||
|
loadchecker();
|
||||||
|
} else if (activeTabIdx == 5) {
|
||||||
|
loadopenvpn();
|
||||||
|
}
|
||||||
|
} else if (cur_url[0].split('#')[0] == 'servers.py') {
|
||||||
|
if (activeTabIdx == 3) {
|
||||||
|
loadchecker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function common_ajax_action_after_success(dialog_id, new_group, ajax_append_id, data) {
|
function common_ajax_action_after_success(dialog_id, new_group, ajax_append_id, data) {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
$("#"+ajax_append_id).append(data);
|
$("#"+ajax_append_id).append(data);
|
||||||
|
@ -842,7 +873,7 @@ function addNewSmonServer(dialog_id) {
|
||||||
$( "input[type=submit], button" ).button();
|
$( "input[type=submit], button" ).button();
|
||||||
$( "input[type=checkbox]" ).checkboxradio();
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
$( "select" ).selectmenu();
|
$( "select" ).selectmenu();
|
||||||
$.getScript('/inc/unsers.js');
|
$.getScript('/inc/users.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -1014,7 +1045,6 @@ function addCreds(dialog_id) {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
var group_name = getGroupNameById($('#new-sshgroup').val());
|
var group_name = getGroupNameById($('#new-sshgroup').val());
|
||||||
console.log(group_name)
|
|
||||||
var getId = new RegExp('ssh-table-[0-9]+');
|
var getId = new RegExp('ssh-table-[0-9]+');
|
||||||
var id = data.match(getId) + '';
|
var id = data.match(getId) + '';
|
||||||
id = id.split('-').pop();
|
id = id.split('-').pop();
|
||||||
|
@ -1043,7 +1073,6 @@ function getGroupNameById(group_id) {
|
||||||
if (data.indexOf('error:') != '-1') {
|
if (data.indexOf('error:') != '-1') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
} else {
|
} else {
|
||||||
console.log(data);
|
|
||||||
group_name = data;
|
group_name = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2005,8 +2034,13 @@ function ajaxActionServies(action, service) {
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
window.history.pushState("services", "services", cur_url[0].split("#")[0]+"#services")
|
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') {
|
||||||
location.reload()
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
window.history.pushState("services", "services", cur_url[0].split("#")[0] + "#services");
|
||||||
|
toastr.success('The ' + service + 'has been ' + action +'ed');
|
||||||
|
loadServices();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(){
|
error: function(){
|
||||||
alert(w.data_error);
|
alert(w.data_error);
|
||||||
|
@ -2025,7 +2059,6 @@ function updateService(service) {
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
console.log(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') {
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
|
@ -2060,7 +2093,8 @@ function updateService(service) {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
toastr.error(data);
|
toastr.error(data);
|
||||||
}
|
}
|
||||||
$("#ajax-update").html('')
|
$("#ajax-update").html('');
|
||||||
|
loadupdatehapwi();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -2084,7 +2118,6 @@ function confirmDeleteOpenVpnProfile(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeOpenVpnProfile(id) {
|
function removeOpenVpnProfile(id) {
|
||||||
console.log(id)
|
|
||||||
$("#"+id).css("background-color", "#f2dede");
|
$("#"+id).css("background-color", "#f2dede");
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
|
@ -2218,3 +2251,82 @@ function viewFirewallRules(id) {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
function loadServices() {
|
||||||
|
$.ajax({
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
loadservices: 1,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function (data) {
|
||||||
|
data = data.replace(/\s+/g, ' ');
|
||||||
|
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||||
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
$('#ajax-services-body').html(data);
|
||||||
|
$.getScript(awesome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
function loadupdatehapwi() {
|
||||||
|
$.ajax({
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
loadupdatehapwi: 1,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function (data) {
|
||||||
|
data = data.replace(/\s+/g, ' ');
|
||||||
|
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
||||||
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
$('#ajax-updatehapwi-body').html(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
function loadchecker() {
|
||||||
|
$.ajax({
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
loadchecker: 1,
|
||||||
|
page: cur_url[0].split('#')[0],
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function (data) {
|
||||||
|
data = data.replace(/\s+/g, ' ');
|
||||||
|
if (data.indexOf('group_error') == '-1' && data.indexOf('error:') != '-1') {
|
||||||
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
$('#checker').html(data);
|
||||||
|
$( "select" ).selectmenu();
|
||||||
|
$.getScript('/inc/users.js');
|
||||||
|
$.getScript(awesome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
function loadopenvpn() {
|
||||||
|
$.ajax({
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
loadopenvpn: 1,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function (data) {
|
||||||
|
data = data.replace(/\s+/g, ' ');
|
||||||
|
if (data.indexOf('group_error') == '-1' && data.indexOf('error:') != '-1') {
|
||||||
|
toastr.error(data);
|
||||||
|
} else {
|
||||||
|
$('#openvpn').html(data);
|
||||||
|
$.getScript(awesome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue