diff --git a/README.md b/README.md index e9fd6d79..78ff8334 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ Edit $HOME_HAPROXY-WI/app/haproxy-wi.cfg with your env Login https://haproxy-wi-server/users.py, and add: users, groups and servers. Default: admin/admin -![alt text](image/haproxy-wi-admin-area.jpeg "Admin area") +![alt text](image/haproxy-wi-admin-area.png "Admin area") For Runtime API, Metrics and Alerting enable state file and stat socket on HAproxt servers and need install socat on all haproxy servers, and configre HAProxy: ``` diff --git a/app/create_db.py b/app/create_db.py index 9038e2ab..840ec235 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -161,6 +161,7 @@ def update_db_v_31(**kwargs): sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address syslog server');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Time of storage of logs of user activity, in days');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('restart_command', 'systemctl restart haproxy', 'haproxy', 'Command for restart HAproxy service');") + sql.append("INSERT INTO settings (param, value, section, `desc`) values('reload_command', 'systemctl reload haproxy', 'haproxy', 'Command for reload HAproxy service');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('status_command', 'systemctl status haproxy', 'haproxy', 'Command for status check HAproxy service');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_user', 'admin', 'haproxy', 'Username for Stats web page HAproxy');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_password', 'password', 'haproxy', 'Password for Stats web page HAproxy');") @@ -337,7 +338,7 @@ def update_db_v_3_4_1(**kwargs): except sqltool.Error as e: if kwargs.get('silent') != 1: if e.args[0] == 'duplicate column name: activeuser' or e == " 1060 (42S21): Duplicate column name 'activeuser' ": - print('Updating... go to version 3.4.5.2') + print('Updating... go to version 3.4.9.5') else: print("An error occurred:", e) return False @@ -398,9 +399,28 @@ def update_db_v_3_4_7(**kwargs): con.close() +def update_db_v_3_4_9_5(**kwargs): + con, cur = get_cur() + sql = """INSERT INTO settings (param, value, section, `desc`) values('reload_command', 'systemctl reload haproxy', 'haproxy', 'Command for reload HAproxy service'); """ + try: + cur.execute(sql) + con.commit() + except sqltool.Error as e: + if kwargs.get('silent') != 1: + if e.args[0] == 'duplicate column name: param' or e == "1060 (42S21): Duplicate column name 'param' ": + print('DB was update to 3.4.9.5') + else: + print("DB was update to 3.4.9.5") + return False + else: + return True + cur.close() + con.close() + + def update_ver(**kwargs): con, cur = get_cur() - sql = """update version set version = '3.4.9.4'; """ + sql = """update version set version = '3.4.9.5'; """ try: cur.execute(sql) con.commit() @@ -451,6 +471,7 @@ def update_all(): if funct.check_ver() is None: update_db_v_3_4_5_22() update_db_v_3_4_7() + update_db_v_3_4_9_5() update_to_hash() update_ver() @@ -469,6 +490,7 @@ def update_all_silent(): if funct.check_ver() is None: update_db_v_3_4_5_22() update_db_v_3_4_7(silent=1) + update_db_v_3_4_9_5(silent=1) update_to_hash() update_ver() diff --git a/app/funct.py b/app/funct.py index cd7e0c53..ef30c5bc 100644 --- a/app/funct.py +++ b/app/funct.py @@ -434,6 +434,8 @@ def upload_and_restart(serv, cfg, **kwargs): commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ] elif kwargs.get("just_save") == "save": commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ] + elif kwargs.get("just_save") == "reload": + commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('reload_command') ] else: commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ] if sql.get_setting('firewall_enable') == "1": diff --git a/app/hapservers.py b/app/hapservers.py index 3d315e4e..42defb2d 100644 --- a/app/hapservers.py +++ b/app/hapservers.py @@ -7,7 +7,7 @@ env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('hapservers.html') print('Content-type: text/html\n') - +funct.check_login() try: cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) @@ -42,7 +42,7 @@ for s in servers: servers_with_status.append(out1) servers_with_status1.append(servers_with_status) -# print(servers_with_status1) + template = template.render(h2 = 1, autorefresh = 1, diff --git a/app/templates/add.html b/app/templates/add.html index 94ff7f65..b058ead0 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -44,7 +44,8 @@ Create SSL Listen