mirror of https://github.com/Aidaho12/haproxy-wi
parent
2e331a4582
commit
8c9c995b33
|
@ -419,12 +419,34 @@ def update_db_v_42(**kwargs):
|
||||||
except sqltool.Error as e:
|
except sqltool.Error as e:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
|
if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
|
||||||
print('DB was update to 4.0.0')
|
print('Updating... go to version 4.2.3')
|
||||||
else:
|
else:
|
||||||
print("An error occurred:", e)
|
print("An error occurred:", e)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("DB was update to 4.0.0")
|
print("Updating... go to version 4.2.3")
|
||||||
|
return True
|
||||||
|
cur.close()
|
||||||
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
|
def update_db_v_4_2_3(**kwargs):
|
||||||
|
con, cur = get_cur()
|
||||||
|
sql = """
|
||||||
|
update settings set section = 'main' where param = 'firewall_enable';
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
cur.execute(sql)
|
||||||
|
con.commit()
|
||||||
|
except sqltool.Error as e:
|
||||||
|
if kwargs.get('silent') != 1:
|
||||||
|
if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
|
||||||
|
print('DB was update to 4.2.3')
|
||||||
|
else:
|
||||||
|
print("An error occurred:", e)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print("DB was update to 4.2.3")
|
||||||
return True
|
return True
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
@ -456,6 +478,7 @@ def update_all():
|
||||||
update_db_v_4()
|
update_db_v_4()
|
||||||
update_db_v_41()
|
update_db_v_41()
|
||||||
update_db_v_42()
|
update_db_v_42()
|
||||||
|
update_db_v_4_2_3()
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
@ -473,6 +496,7 @@ def update_all_silent():
|
||||||
update_db_v_4(silent=1)
|
update_db_v_4(silent=1)
|
||||||
update_db_v_41(silent=1)
|
update_db_v_41(silent=1)
|
||||||
update_db_v_42(silent=1)
|
update_db_v_42(silent=1)
|
||||||
|
update_db_v_4_2_3(silent=1)
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
|
15
app/funct.py
15
app/funct.py
|
@ -608,6 +608,8 @@ def upload_and_restart(serv, cfg, **kwargs):
|
||||||
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo systemctl reload nginx" ]
|
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo systemctl reload nginx" ]
|
||||||
else:
|
else:
|
||||||
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo systemctl restart nginx" ]
|
commands = [ "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q && sudo systemctl restart nginx" ]
|
||||||
|
if sql.get_setting('firewall_enable') == "1":
|
||||||
|
commands[0] += open_port_firewalld(cfg, serv=serv, service='nginx')
|
||||||
else:
|
else:
|
||||||
if kwargs.get("just_save") == "test":
|
if kwargs.get("just_save") == "test":
|
||||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
|
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
|
||||||
|
@ -618,7 +620,7 @@ def upload_and_restart(serv, cfg, **kwargs):
|
||||||
else:
|
else:
|
||||||
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + config_path + " && sudo systemctl restart haproxy" ]
|
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + config_path + " && sudo systemctl restart haproxy" ]
|
||||||
if sql.get_setting('firewall_enable') == "1":
|
if sql.get_setting('firewall_enable') == "1":
|
||||||
commands[0] += open_port_firewalld(cfg)
|
commands[0] += open_port_firewalld(cfg, serv=serv)
|
||||||
error += str(upload(serv, tmp_file, cfg, dir='fullpath'))
|
error += str(upload(serv, tmp_file, cfg, dir='fullpath'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -644,7 +646,7 @@ def master_slave_upload_and_restart(serv, cfg, just_save, **kwargs):
|
||||||
return error
|
return error
|
||||||
|
|
||||||
|
|
||||||
def open_port_firewalld(cfg):
|
def open_port_firewalld(cfg, serv, **kwargs):
|
||||||
try:
|
try:
|
||||||
conf = open(cfg, "r")
|
conf = open(cfg, "r")
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -654,6 +656,13 @@ def open_port_firewalld(cfg):
|
||||||
ports = ''
|
ports = ''
|
||||||
|
|
||||||
for line in conf:
|
for line in conf:
|
||||||
|
if kwargs.get('service') == 'nginx':
|
||||||
|
if "listen " in line and '#' not in line:
|
||||||
|
listen = ' '.join(line.split())
|
||||||
|
listen = listen.split(" ")[1]
|
||||||
|
listen = listen.split(";")[0]
|
||||||
|
ports += listen+' '
|
||||||
|
else:
|
||||||
if "bind" in line:
|
if "bind" in line:
|
||||||
bind = line.split(":")
|
bind = line.split(":")
|
||||||
bind[1] = bind[1].strip(' ')
|
bind[1] = bind[1].strip(' ')
|
||||||
|
@ -663,7 +672,7 @@ def open_port_firewalld(cfg):
|
||||||
ports += bind+' '
|
ports += bind+' '
|
||||||
|
|
||||||
firewalld_commands += 'sudo firewall-cmd --reload -q'
|
firewalld_commands += 'sudo firewall-cmd --reload -q'
|
||||||
logging('localhost', ' Next ports have opened: '+ports+ ' has opened ')
|
logging(serv, ' Next ports have been opened: '+ports+ ' has opened ')
|
||||||
return firewalld_commands
|
return firewalld_commands
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
yum:
|
yum:
|
||||||
name: epel-release
|
name: epel-release
|
||||||
state: latest
|
state: latest
|
||||||
when: ((ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
|
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
environment:
|
environment:
|
||||||
http_proxy: "{{PROXY}}"
|
http_proxy: "{{PROXY}}"
|
||||||
|
|
|
@ -31,11 +31,11 @@ if [ -f $HAPROXY_PATH/waf/modsecurity.conf ];then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if hash apt-get 2>/dev/null; then
|
if hash apt-get 2>/dev/null; then
|
||||||
sudo apt install libevent-dev apache2-dev libpcre3-dev libxml2-dev gcc pcre-devel -y
|
sudo apt install libevent-dev apache2-dev libpcre3-dev libxml2-dev gcc pcre-devel wget -y
|
||||||
else
|
else
|
||||||
sudo yum install -y http://rpmfind.net/linux/centos/7/os/x86_64/Packages/yajl-devel-2.0.4-4.el7.x86_64.rpm >> /dev/null
|
sudo yum install -y http://rpmfind.net/linux/centos/7/os/x86_64/Packages/yajl-devel-2.0.4-4.el7.x86_64.rpm >> /dev/null
|
||||||
sudo yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/libevent-devel-2.0.21-4.el7.x86_64.rpm >> /dev/null
|
sudo yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/libevent-devel-2.0.21-4.el7.x86_64.rpm >> /dev/null
|
||||||
sudo yum install -y httpd-devel libxml2-devel gcc curl-devel pcre-devel -y >> /dev/null
|
sudo yum install -y httpd-devel libxml2-devel gcc curl-devel pcre-devel wget -y >> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wget -O /tmp/modsecurity.tar.gz https://www.modsecurity.org/tarball/2.9.2/modsecurity-2.9.2.tar.gz >> /dev/null
|
wget -O /tmp/modsecurity.tar.gz https://www.modsecurity.org/tarball/2.9.2/modsecurity-2.9.2.tar.gz >> /dev/null
|
||||||
|
|
Loading…
Reference in New Issue