diff --git a/README.md b/README.md
index e6b61ea..1eb6263 100644
--- a/README.md
+++ b/README.md
@@ -13,10 +13,11 @@ A simple web interface(user-frendly web GUI) for managing Haproxy servers. Leave
7. Add sections: listen, frontend, backend from web interface
8. Editing configs
9. Rollback to previous versions of the config
-10. Comparing versions of configs
-11. Users roles: admin, editor, viewer
-12. Server groups
-13. Telegram notification
+10. Master/slave servers
+11. Comparing versions of configs
+12. Users roles: admin, editor, viewer
+13. Server groups
+14. Telegram notification
# Install
@@ -32,7 +33,7 @@ $ chmod +x haproxy-wi/cgi-bin/*.py
For Apache do virtualhost with cgi-bin. Like this:
```
-
+
ServerName haproxy-wi
ErrorLog /var/log/httpd/haproxy-wi.error.log
CustomLog /var/log/httpd/haproxy-wi.access.log combined
@@ -80,6 +81,12 @@ For Runtime API enable state file on HAproxt servers and need install socat on a
```
![alt text](image/haproxy-wi-logs.jpeg "View logs page")
+# Update DB
+```
+$ cd /var/www/haproxy-wi/cgi-bin
+$ ./update_db.py
+```
+
# Further development and support
Offer your ideas and wishes, ask questions. All this is [welcomed](https://github.com/Aidaho12/haproxy-wi/issues)
diff --git a/cgi-bin/config.py b/cgi-bin/config.py
index f49867b..40c511a 100644
--- a/cgi-bin/config.py
+++ b/cgi-bin/config.py
@@ -5,6 +5,7 @@ import os
import http.cookies
from configparser import ConfigParser, ExtendedInterpolation
import funct
+import sql
form = cgi.FieldStorage()
serv = form.getvalue('serv')
@@ -61,6 +62,11 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
print("
New config was saved as: %s
" % cfg)
+ MASTERS = sql.is_master(serv)
+ for master in MASTERS:
+ if master[0] != None:
+ funct.upload_and_restart(master[0], cfg, just_save=save)
+
funct.upload_and_restart(serv, cfg, just_save=save)
os.system("/bin/diff -ub %s %s >> %s/config_edit-%s.log" % (oldcfg, cfg, log_path, funct.get_data('logs')))
diff --git a/cgi-bin/configver.py b/cgi-bin/configver.py
index dfe73ae..10fa579 100644
--- a/cgi-bin/configver.py
+++ b/cgi-bin/configver.py
@@ -3,6 +3,7 @@ import html
import cgi
import os
import funct
+import sql
from configparser import ConfigParser, ExtendedInterpolation
form = cgi.FieldStorage()
@@ -79,6 +80,11 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
print("
Uploaded old config ver: %s
" % configver)
+ MASTERS = sql.is_master(serv)
+ for master in MASTERS:
+ if master[0] != None:
+ funct.upload_and_restart(master[0], configver, just_save=save)
+
funct.upload_and_restart(serv, configver, just_save=save)
print('Go to view stats ' % serv)
diff --git a/cgi-bin/create_db.py b/cgi-bin/create_db.py
index bd93273..53f5a67 100644
--- a/cgi-bin/create_db.py
+++ b/cgi-bin/create_db.py
@@ -167,8 +167,8 @@ def update_db_v_2_0_1_1():
try:
cur.execute(sql)
except sqltool.Error as e:
- if e.args[0] == 'duplicate column name: enable':
- print('Already updated. No run more. Thx =^.^=')
+ if e.args[0] == 'duplicate column name: enable' or e == "1060 (42S21): Duplicate column name 'enable' ":
+ print('Updating... go to version 2.0.5')
return False
else:
print("An error occurred:", e)
@@ -179,9 +179,30 @@ def update_db_v_2_0_1_1():
cur.close()
con.close()
+def update_db_v_2_0_5():
+ con, cur = get_cur()
+ sql = """
+ ALTER TABLE `servers` ADD COLUMN master INTEGER NOT NULL DEFAULT 0;
+ """
+ try:
+ cur.execute(sql)
+ except sqltool.Error as e:
+ if e.args[0] == 'duplicate column name: master':
+ print('Already updated. No run more. Thx =^.^=')
+ return False
+ else:
+ print("An error occurred:", e)
+ return False
+ else:
+ print("DB was update to 2.0.5")
+ return True
+ cur.close()
+ con.close()
+
def update_all():
update_db_v_2_0_1()
update_db_v_2_0_1_1()
+ update_db_v_2_0_5()
#if check_db():
# create_table()
diff --git a/cgi-bin/funct.py b/cgi-bin/funct.py
index d86bfe3..0d61dbe 100644
--- a/cgi-bin/funct.py
+++ b/cgi-bin/funct.py
@@ -194,7 +194,7 @@ def links():
'')
print(''
''
- '