mirror of https://github.com/Aidaho12/haproxy-wi
v2.5.4.4
Meet version 2.5.4.4! Improved reading of the config and output of errors!pull/19/head
parent
26793bc197
commit
c270d5d144
|
@ -2,7 +2,6 @@
|
|||
import html
|
||||
import cgi
|
||||
import os
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import funct
|
||||
import sql
|
||||
import http
|
||||
|
@ -31,11 +30,8 @@ output_from_parsed_template = template.render(title = "Add",
|
|||
conf_add = form.getvalue('conf'))
|
||||
print(output_from_parsed_template)
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
cert_path = config.get('haproxy', 'cert_path')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cert_path = funct.get_config_var('haproxy', 'cert_path')
|
||||
|
||||
if form.getvalue('mode') is not None:
|
||||
serv = form.getvalue('serv')
|
||||
|
|
|
@ -30,8 +30,6 @@ try:
|
|||
servers = [('haproxy-wi.error.log','error.log'), ('haproxy-wi.access.log','access.log')]
|
||||
except:
|
||||
pass
|
||||
|
||||
#print(sql.get_dick_permit())
|
||||
|
||||
output_from_parsed_template = template.render(h2 = 1,
|
||||
autorefresh = 1,
|
||||
|
|
|
@ -3,15 +3,16 @@ import html
|
|||
import cgi
|
||||
import os
|
||||
import http.cookies
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('config.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
config_read = ""
|
||||
|
@ -28,12 +29,8 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
log_path = config.get('main', 'log_path')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if serv is not None:
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
|
|
@ -4,17 +4,19 @@ import cgi
|
|||
import os, http.cookies
|
||||
import funct
|
||||
import sql
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('configver.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
configver = form.getvalue('configver')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
config_read = ""
|
||||
configver = ""
|
||||
stderr = ""
|
||||
aftersave = ""
|
||||
error = ""
|
||||
|
@ -27,14 +29,6 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
configver = form.getvalue('configver')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
def get_files():
|
||||
import glob
|
||||
file = set()
|
||||
|
|
|
@ -3,23 +3,19 @@ import cgi
|
|||
import html
|
||||
import os
|
||||
import sys
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import funct
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
mysql_enable = config.get('mysql', 'enable')
|
||||
fullpath = config.get('main', 'fullpath')
|
||||
mysql_enable = funct.get_config_var('mysql', 'enable')
|
||||
|
||||
if mysql_enable == '1':
|
||||
mysql_user = config.get('mysql', 'mysql_user')
|
||||
mysql_password = config.get('mysql', 'mysql_password')
|
||||
mysql_db = config.get('mysql', 'mysql_db')
|
||||
mysql_host = config.get('mysql', 'mysql_host')
|
||||
mysql_user = funct.get_config_var('mysql', 'mysql_user')
|
||||
mysql_password = funct.get_config_var('mysql', 'mysql_password')
|
||||
mysql_db = funct.get_config_var('mysql', 'mysql_db')
|
||||
mysql_host = funct.get_config_var('mysql', 'mysql_host')
|
||||
from mysql.connector import errorcode
|
||||
import mysql.connector as sqltool
|
||||
else:
|
||||
fullpath = funct.get_config_var('main', 'fullpath')
|
||||
db = fullpath+"/app/haproxy-wi.db"
|
||||
import sqlite3 as sqltool
|
||||
|
||||
|
|
|
@ -3,15 +3,15 @@ import html, http.cookies
|
|||
import cgi
|
||||
import os
|
||||
import funct, sql
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import glob
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('delver.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
stderr = ""
|
||||
|
@ -26,13 +26,10 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
Select = form.getvalue('del')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
def get_files():
|
||||
import glob
|
||||
|
|
61
app/funct.py
61
app/funct.py
|
@ -8,29 +8,25 @@ from datetime import datetime
|
|||
from pytz import timezone
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
fullpath = config.get('main', 'fullpath')
|
||||
time_zone = config.get('main', 'time_zone')
|
||||
proxy = config.get('main', 'proxy')
|
||||
ssh_keys = config.get('ssh', 'ssh_keys')
|
||||
haproxy_configs_server = config.get('configs', 'haproxy_configs_server')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')
|
||||
tmp_config_path = config.get('haproxy', 'tmp_config_path')
|
||||
restart_command = config.get('haproxy', 'restart_command')
|
||||
|
||||
def check_config():
|
||||
for section in [ 'main', 'configs', 'ssh', 'logs', 'haproxy' ]:
|
||||
if not config.has_section(section):
|
||||
print('<center><div class="alert alert-danger">Check config file, no %s section</div>' % section)
|
||||
|
||||
def get_config_var(sec, var):
|
||||
try:
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
except:
|
||||
print('<center><div class="alert alert-danger">Check the config file, whether it exists and the path. Must be in: app/haproxy-webintarface.config</div>')
|
||||
|
||||
try:
|
||||
var = config.get(sec, var)
|
||||
return var
|
||||
except:
|
||||
print('<center><div class="alert alert-danger">Check the config file. Presence section %s and parameter %s</div>' % (sec, var))
|
||||
|
||||
def get_data(type):
|
||||
now_utc = datetime.now(timezone(time_zone))
|
||||
now_utc = datetime.now(timezone(get_config_var('main', 'time_zone')))
|
||||
if type == 'config':
|
||||
fmt = "%Y-%m-%d.%H:%M:%S"
|
||||
if type == 'logs':
|
||||
|
@ -40,13 +36,13 @@ def get_data(type):
|
|||
def logging(serv, action):
|
||||
import sql
|
||||
dateFormat = "%b %d %H:%M:%S"
|
||||
now_utc = datetime.now(timezone(time_zone))
|
||||
now_utc = datetime.now(timezone(get_config_var('main', 'time_zone')))
|
||||
IP = cgi.escape(os.environ["REMOTE_ADDR"])
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_uuid = cookie.get('uuid')
|
||||
login = sql.get_user_name_by_uuid(user_uuid.value)
|
||||
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
|
||||
log_path = config.get('main', 'log_path')
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
|
||||
try:
|
||||
log = open(log_path + "/config_edit-"+get_data('logs')+".log", "a")
|
||||
|
@ -56,12 +52,13 @@ def logging(serv, action):
|
|||
print('<center><div class="alert alert-danger">Can\'t read write log. Please chech log_path in config</div></center>')
|
||||
pass
|
||||
|
||||
if config.get('telegram', 'enable') == "1": telegram_send_mess(mess)
|
||||
if get_config_var('telegram', 'enable') == "1": telegram_send_mess(mess)
|
||||
|
||||
def telegram_send_mess(mess):
|
||||
import telegram
|
||||
token_bot = config.get('telegram', 'token')
|
||||
channel_name = config.get('telegram', 'channel_name')
|
||||
token_bot = get_config_var('telegram', 'token')
|
||||
channel_name = get_config_var('telegram', 'channel_name')
|
||||
proxy = get_config_var('main', 'proxy')
|
||||
|
||||
if proxy is not None:
|
||||
pp = telegram.utils.request.Request(proxy_url=proxy)
|
||||
|
@ -130,7 +127,7 @@ def ssh_connect(serv, **kwargs):
|
|||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
if ssh_enable == 1:
|
||||
k = paramiko.RSAKey.from_private_key_file(ssh_keys)
|
||||
k = paramiko.RSAKey.from_private_key_file(get_config_var('ssh', 'ssh_keys'))
|
||||
ssh.connect(hostname = serv, username = ssh_user_name, pkey = k )
|
||||
else:
|
||||
ssh.connect(hostname = serv, username = ssh_user_name, password = sql.select_ssh_password())
|
||||
|
@ -188,7 +185,7 @@ def get_config(serv, cfg, **kwargs):
|
|||
if kwargs.get("keepalived"):
|
||||
config_path = "/etc/keepalived/keepalived.conf"
|
||||
else:
|
||||
config_path = haproxy_config_path
|
||||
config_path = get_config_var('haproxy', 'haproxy_config_path')
|
||||
|
||||
ssh = ssh_connect(serv)
|
||||
try:
|
||||
|
@ -246,6 +243,8 @@ def show_config(cfg):
|
|||
|
||||
def install_haproxy(serv):
|
||||
script = "install_haproxy.sh"
|
||||
tmp_config_path = get_config_var('haproxy', 'tmp_config_path')
|
||||
proxy = get_config_var('main', 'proxy')
|
||||
os.system("cp scripts/%s ." % script)
|
||||
if proxy is not None:
|
||||
proxy_serv = proxy
|
||||
|
@ -274,7 +273,7 @@ def upload(serv, path, file, **kwargs):
|
|||
print('<div class="alert alert-danger">Upload fail: %s</div>' % e)
|
||||
|
||||
def upload_and_restart(serv, cfg, **kwargs):
|
||||
tmp_file = tmp_config_path + "/" + get_data('config') + ".cfg"
|
||||
tmp_file = get_config_var('haproxy', 'tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||
error = ""
|
||||
|
||||
try:
|
||||
|
@ -297,11 +296,11 @@ def upload_and_restart(serv, cfg, **kwargs):
|
|||
commands = [ "sudo mv -f " + tmp_file + " /etc/keepalived/keepalived.conf", "sudo systemctl restart keepalived" ]
|
||||
else:
|
||||
if kwargs.get("just_save") == "save":
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + haproxy_config_path ]
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + get_config_var('haproxy', 'haproxy_config_path') ]
|
||||
else:
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + haproxy_config_path + " && sudo " + restart_command ]
|
||||
commands = [ "sudo /sbin/haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + get_config_var('haproxy', 'haproxy_config_path') + " && sudo " + get_config_var('haproxy', 'restart_command') ]
|
||||
try:
|
||||
if config.get('haproxy', 'firewall_enable') == "1":
|
||||
if get_config_var('haproxy', 'firewall_enable') == "1":
|
||||
commands.extend(open_port_firewalld(cfg))
|
||||
except:
|
||||
return 'Please check the config for the presence of the parameter - "firewall_enable". Mast be: "0" or "1". Firewalld configure not working now'
|
||||
|
@ -332,7 +331,7 @@ def open_port_firewalld(cfg):
|
|||
return firewalld_commands
|
||||
|
||||
def check_haproxy_config(serv):
|
||||
commands = [ "/sbin/haproxy -q -c -f %s" % haproxy_config_path ]
|
||||
commands = [ "/sbin/haproxy -q -c -f %s" % get_config_var('haproxy', 'haproxy_config_path') ]
|
||||
ssh = ssh_connect(serv)
|
||||
for command in commands:
|
||||
stdin , stdout, stderr = ssh.exec_command(command)
|
||||
|
|
|
@ -3,13 +3,14 @@ import html, http.cookies
|
|||
import cgi
|
||||
import os
|
||||
import funct, sql
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('ha.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
||||
|
|
|
@ -3,14 +3,13 @@ import html, http.cookies
|
|||
import cgi
|
||||
import os
|
||||
import funct, sql
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('ihap.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
form = cgi.FieldStorage()
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
|
|
|
@ -3,17 +3,20 @@ import html
|
|||
import cgi
|
||||
import os
|
||||
import http.cookies
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('config.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
kp_save_configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
config_read = ""
|
||||
cfg = ""
|
||||
stderr = ""
|
||||
|
@ -28,13 +31,6 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
log_path = config.get('main', 'log_path')
|
||||
kp_save_configs_dir = config.get('configs', 'kp_save_configs_dir')
|
||||
|
||||
if serv is not None:
|
||||
cfg = kp_save_configs_dir+ serv + '-' + funct.get_data('config') + '.conf'
|
||||
|
||||
|
|
|
@ -8,13 +8,6 @@ import subprocess
|
|||
import funct
|
||||
import sql
|
||||
import ovw
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
|
||||
config.read(path_config)
|
||||
funct.check_config()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
req = form.getvalue('req')
|
||||
|
@ -31,7 +24,7 @@ if form.getvalue('getcert') is not None and serv is not None:
|
|||
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
|
||||
|
||||
if form.getvalue('ssh_cert'):
|
||||
ssh_keys = config.get('ssh', 'ssh_keys')
|
||||
ssh_keys = funct.get_config_var('ssh', 'ssh_keys')
|
||||
|
||||
try:
|
||||
with open(ssh_keys, "w") as conf:
|
||||
|
@ -46,8 +39,8 @@ if form.getvalue('ssh_cert'):
|
|||
pass
|
||||
|
||||
if serv and form.getvalue('ssl_cert'):
|
||||
cert_local_dir = config.get('main', 'cert_local_dir')
|
||||
cert_path = config.get('haproxy', 'cert_path')
|
||||
cert_local_dir = funct.get_config_var('main', 'cert_local_dir')
|
||||
cert_path = funct.get_config_var('haproxy', 'cert_path')
|
||||
|
||||
if form.getvalue('ssl_name') is None:
|
||||
print('<div class="alert alert-danger">Please enter desired name</div>')
|
||||
|
@ -121,10 +114,10 @@ if form.getvalue('action'):
|
|||
import requests
|
||||
from requests_toolbelt.utils import dump
|
||||
|
||||
haproxy_user = config.get('haproxy', 'stats_user')
|
||||
haproxy_pass = config.get('haproxy', 'stats_password')
|
||||
stats_port = config.get('haproxy', 'stats_port')
|
||||
stats_page = config.get('haproxy', 'stats_page')
|
||||
haproxy_user = funct.get_config_var('haproxy', 'stats_user')
|
||||
haproxy_pass = funct.get_config_var('haproxy', 'stats_password')
|
||||
stats_port = funct.get_config_var('haproxy', 'stats_port')
|
||||
stats_page = funct.get_config_var('haproxy', 'stats_page')
|
||||
|
||||
postdata = {
|
||||
'action' : form.getvalue('action'),
|
||||
|
@ -145,10 +138,10 @@ if serv is not None and act == "stats":
|
|||
import requests
|
||||
from requests_toolbelt.utils import dump
|
||||
|
||||
haproxy_user = config.get('haproxy', 'stats_user')
|
||||
haproxy_pass = config.get('haproxy', 'stats_password')
|
||||
stats_port = config.get('haproxy', 'stats_port')
|
||||
stats_page = config.get('haproxy', 'stats_page')
|
||||
haproxy_user = funct.get_config_var('haproxy', 'stats_user')
|
||||
haproxy_pass = funct.get_config_var('haproxy', 'stats_password')
|
||||
stats_port = funct.get_config_var('haproxy', 'stats_port')
|
||||
stats_page = funct.get_config_var('haproxy', 'stats_page')
|
||||
try:
|
||||
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
|
||||
except requests.exceptions.ConnectTimeout:
|
||||
|
@ -177,14 +170,14 @@ if serv is not None and form.getvalue('rows') is not None:
|
|||
grep_act = ''
|
||||
grep = ''
|
||||
|
||||
syslog_server_enable = config.get('logs', 'syslog_server_enable')
|
||||
syslog_server_enable = funct.get_config_var('logs', 'syslog_server_enable')
|
||||
if syslog_server_enable is None or syslog_server_enable == "0":
|
||||
local_path_logs = config.get('logs', 'local_path_logs')
|
||||
local_path_logs = funct.get_config_var('logs', 'local_path_logs')
|
||||
syslog_server = serv
|
||||
commands = [ 'sudo tail -%s %s %s %s' % (rows, local_path_logs, grep_act, grep) ]
|
||||
else:
|
||||
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
|
||||
syslog_server = config.get('logs', 'syslog_server')
|
||||
syslog_server = funct.get_config_var('logs', 'syslog_server')
|
||||
print('<div id="logs">')
|
||||
funct.ssh_command(syslog_server, commands, show_log="1")
|
||||
print('</div>')
|
||||
|
@ -211,8 +204,8 @@ if serv is not None and act == "showMap":
|
|||
ovw.get_map(serv)
|
||||
|
||||
if form.getvalue('servaction') is not None:
|
||||
server_state_file = config.get('haproxy', 'server_state_file')
|
||||
haproxy_sock = config.get('haproxy', 'haproxy_sock')
|
||||
server_state_file = funct.get_config_var('haproxy', 'server_state_file')
|
||||
haproxy_sock = funct.get_config_var('haproxy', 'haproxy_sock')
|
||||
enable = form.getvalue('servaction')
|
||||
backend = form.getvalue('servbackend')
|
||||
|
||||
|
@ -241,7 +234,7 @@ if serv is not None and act == "configShow":
|
|||
import os
|
||||
from datetime import datetime
|
||||
from pytz import timezone
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if form.getvalue('configver') is None:
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
@ -272,10 +265,7 @@ if serv is not None and act == "configShow":
|
|||
|
||||
if form.getvalue('viewlogs') is not None:
|
||||
viewlog = form.getvalue('viewlogs')
|
||||
try:
|
||||
log_path = config.get('main', 'log_path')
|
||||
except:
|
||||
print('<div class="alert alert-warning">Please check the config for the presence of the parameter - "log_path". </div>')
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
|
||||
try:
|
||||
log = open(log_path + viewlog, "r",encoding='utf-8', errors='ignore')
|
||||
|
@ -298,7 +288,7 @@ if form.getvalue('master'):
|
|||
interface = form.getvalue('interface')
|
||||
vrrpip = form.getvalue('vrrpip')
|
||||
hap = form.getvalue('hap')
|
||||
tmp_config_path = config.get('haproxy', 'tmp_config_path')
|
||||
tmp_config_path = funct.get_config_var('haproxy', 'tmp_config_path')
|
||||
script = "install_keepalived.sh"
|
||||
|
||||
if hap == "1":
|
||||
|
@ -325,7 +315,7 @@ if form.getvalue('masteradd'):
|
|||
interface = form.getvalue('interfaceadd')
|
||||
vrrpip = form.getvalue('vrrpipadd')
|
||||
kp = form.getvalue('kp')
|
||||
tmp_config_path = config.get('haproxy', 'tmp_config_path')
|
||||
tmp_config_path = funct.get_config_var('haproxy', 'tmp_config_path')
|
||||
script = "add_vrrp.sh"
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
|
23
app/ovw.py
23
app/ovw.py
|
@ -1,20 +1,14 @@
|
|||
import funct
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import os
|
||||
import cgi
|
||||
import sql
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
time_zone = config.get('main', 'time_zone')
|
||||
cgi_path = config.get('main', 'cgi_path')
|
||||
fullpath = config.get('main', 'fullpath')
|
||||
stats_port= config.get('haproxy', 'stats_port')
|
||||
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')
|
||||
status_command = config.get('haproxy', 'status_command')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
cgi_path = funct.get_config_var('main', 'cgi_path')
|
||||
fullpath = funct.get_config_var('main', 'fullpath')
|
||||
stats_port= funct.get_config_var('haproxy', 'stats_port')
|
||||
haproxy_config_path = funct.get_config_var('haproxy', 'haproxy_config_path')
|
||||
status_command = funct.get_config_var('haproxy', 'status_command')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
form = cgi.FieldStorage()
|
||||
|
||||
def get_overview():
|
||||
|
@ -160,7 +154,7 @@ def show_compare_configs(serv):
|
|||
import glob
|
||||
left = form.getvalue('left')
|
||||
right = form.getvalue('right')
|
||||
haproxy_configs_server = config.get('configs', 'haproxy_configs_server')
|
||||
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
|
||||
|
||||
print('<form action="diff.py#diff" method="get">')
|
||||
print('<center><h3><span style="padding: 20px;">Choose left</span><span style="padding: 110px;">Choose right</span></h3>')
|
||||
|
@ -201,8 +195,7 @@ def show_compare_configs(serv):
|
|||
def comapre_show():
|
||||
left = form.getvalue('left')
|
||||
right = form.getvalue('right')
|
||||
haproxy_configs_server = config.get('configs', 'haproxy_configs_server')
|
||||
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||||
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
|
||||
commands = [ 'diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right) ]
|
||||
|
||||
funct.ssh_command(haproxy_configs_server, commands, compare="1")
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
if [[ $1 != "" ]]
|
||||
then
|
||||
sudo export http_proxy="$1"
|
||||
sudo export https_proxy="$1"
|
||||
export http_proxy="$1"
|
||||
export https_proxy="$1"
|
||||
echo "Exporting proxy"
|
||||
fi
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ from configparser import ConfigParser, ExtendedInterpolation
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('viewsettings.html')
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
@ -31,8 +33,6 @@ for section_name in config.sections():
|
|||
for name, value in config.items(section_name):
|
||||
config_items_section_name[section_name][name] = value
|
||||
|
||||
|
||||
|
||||
output_from_parsed_template = template.render(h2 = 1, title = "Admin area: View settings",
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user,
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-"
|
||||
import cgi
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import create_db
|
||||
import funct
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
mysql_enable = config.get('mysql', 'enable')
|
||||
mysql_enable = funct.get_config_var('mysql', 'enable')
|
||||
|
||||
if mysql_enable == '1':
|
||||
from mysql.connector import errorcode
|
||||
|
|
|
@ -98,7 +98,11 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">HAproxy-WI v2.5.4.3</div>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v2.5.4.4
|
||||
<br>
|
||||
<a href="https://www.patreon.com/haproxy_wi" title="Donate" style="color: #fff; margin-left: 40px;">Patreon</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
|
|
@ -31,17 +31,16 @@
|
|||
await sleep(2000);
|
||||
|
||||
$("form").submit(function() {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "options.py",
|
||||
dataType: "text",
|
||||
data: $(this).serialize(),
|
||||
success: function( data ) {
|
||||
//$("#ajax").html(data);
|
||||
showStats();
|
||||
}
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "options.py",
|
||||
dataType: "text",
|
||||
data: $(this).serialize(),
|
||||
success: function( data ) {
|
||||
showStats();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-"
|
||||
import create_db
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
import funct
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
mysql_enable = config.get('mysql', 'enable')
|
||||
mysql_enable = funct.get_config_var('mysql', 'enable')
|
||||
|
||||
if mysql_enable == '1':
|
||||
from mysql.connector import errorcode
|
||||
|
|
|
@ -6,27 +6,19 @@ import funct
|
|||
import sql
|
||||
import glob
|
||||
import datetime
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('viewlogs.html')
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
try:
|
||||
if config.get('main', 'log_path'):
|
||||
log_path = config.get('main', 'log_path')
|
||||
time_storage = config.getint('logs', 'log_time_storage')
|
||||
except:
|
||||
print('<center><div class="alert alert-danger">Can not find "log_path" and "log_time_storage" parametrs. Check into config</div>')
|
||||
|
||||
|
||||
funct.check_login()
|
||||
funct.page_for_admin()
|
||||
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
time_storage = funct.get_config_var('logs', 'log_time_storage')
|
||||
time_storage = int(time_storage)
|
||||
|
||||
try:
|
||||
time_storage_hours = time_storage * 24
|
||||
for dirpath, dirnames, filenames in os.walk(log_path):
|
||||
|
@ -36,7 +28,7 @@ try:
|
|||
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
|
||||
os.remove(curpath)
|
||||
except:
|
||||
print('<center><div class="alert alert-danger" style="margin: 0; margin-bottom: 10px;">Can\'t delete old logs file. <br> Please check "log_time_storage" in config and <br>exist directory </div>')
|
||||
print('<center><div class="alert alert-danger" style="margin: 0; margin-bottom: 10px;">Can\'t delete old logs file. <br> Please check "log_time_storage" in config and <br>exist directory </div></center>')
|
||||
pass
|
||||
|
||||
try:
|
||||
|
|
|
@ -321,7 +321,7 @@ pre {
|
|||
.menu {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
min-height: calc(100vh - 70px);
|
||||
min-height: calc(100vh - 95px);
|
||||
}
|
||||
.menu ul li{
|
||||
padding: 3px;
|
||||
|
|
Loading…
Reference in New Issue