mirror of https://github.com/Aidaho12/haproxy-wi
parent
33d2131b9a
commit
28db64211e
133
app/create_db.py
133
app/create_db.py
|
@ -693,133 +693,6 @@ def update_db_v_4_3_0():
|
|||
print("An error occurred:", e)
|
||||
|
||||
|
||||
def update_db_v_5_3_0():
|
||||
groups = ''
|
||||
query = Groups.select()
|
||||
|
||||
try:
|
||||
query_res = query.execute()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
else:
|
||||
groups = query_res
|
||||
|
||||
for g in groups:
|
||||
try:
|
||||
data_source = [
|
||||
{'param': 'nginx_container_name', 'value': 'nginx', 'section': 'nginx',
|
||||
'desc': 'Docker container name for NGINX service', 'group': g.group_id},
|
||||
{'param': 'haproxy_container_name', 'value': 'haproxy', 'section': 'haproxy',
|
||||
'desc': 'Docker container name for HAProxy service', 'group': g.group_id},
|
||||
{'param': 'maxmind_key', 'value': '', 'section': 'haproxy',
|
||||
'desc': 'License key for downloading GeoIP DB. You can create it on maxmind.com',
|
||||
'group': g.group_id},
|
||||
{'param': 'apache_path_logs', 'value': '/var/log/httpd/', 'section': 'apache',
|
||||
'desc': 'The path for Apache logs', 'group': g.group_id},
|
||||
{'param': 'apache_stats_user', 'value': 'admin', 'section': 'apache',
|
||||
'desc': 'Username for accessing Apache stats page', 'group': g.group_id},
|
||||
{'param': 'apache_stats_password', 'value': 'password', 'section': 'apache',
|
||||
'desc': 'Password for Apache stats webpage', 'group': g.group_id},
|
||||
{'param': 'apache_stats_port', 'value': '8087', 'section': 'apache', 'desc': 'Stats port for webpage Apache',
|
||||
'group': g.group_id},
|
||||
{'param': 'apache_stats_page', 'value': 'stats', 'section': 'apache', 'desc': 'URI Stats for webpage Apache',
|
||||
'group': g.group_id},
|
||||
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
||||
'desc': 'Path to the Apache directory with config files', 'group': g.group_id},
|
||||
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
||||
'desc': 'Path to the main Apache configuration file', 'group': g.group_id},
|
||||
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
||||
'desc': 'Docker container name for Apache service', 'group': g.group_id},
|
||||
{'param': 'keepalived_config_path', 'value': '/etc/keepalived/keepalived.conf', 'section': 'keepalived',
|
||||
'desc': 'Path to the main Keepalived configuration file', 'group': g.group_id},
|
||||
{'param': 'keepalived_path_logs', 'value': '/var/log/keepalived/', 'section': 'keepalived',
|
||||
'desc': 'The path for Keepalived logs', 'group': g.group_id},
|
||||
]
|
||||
|
||||
try:
|
||||
Setting.insert_many(data_source).on_conflict_ignore().execute()
|
||||
except Exception as e:
|
||||
if str(e) == 'columns param, group are not unique':
|
||||
pass
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
except Exception as e:
|
||||
if (
|
||||
str(e) == 'columns param, group are not unique'
|
||||
or str(e) == '(1062, "Duplicate entry \'nginx_container_name\' for key \'param\'")'
|
||||
or str(e) == 'UNIQUE constraint failed: settings.param, settings.group'
|
||||
):
|
||||
pass
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
|
||||
|
||||
def update_db_v_5_3_1():
|
||||
cursor = conn.cursor()
|
||||
sql = """
|
||||
ALTER TABLE `servers` ADD COLUMN keepalived_active INTEGER NOT NULL DEFAULT 0;
|
||||
"""
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
if e.args[0] == 'duplicate column name: keepalived_active' or str(e) == '(1060, "Duplicate column name \'keepalived_active\'")':
|
||||
print('Updating... DB has been updated to version 5.3.1')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 5.3.1")
|
||||
|
||||
|
||||
def update_db_v_5_3_2_2():
|
||||
cursor = conn.cursor()
|
||||
sql = """
|
||||
ALTER TABLE `servers` ADD COLUMN keepalived_alert INTEGER NOT NULL DEFAULT 0;
|
||||
"""
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
if e.args[0] == 'duplicate column name: keepalived_alert' or str(e) == '(1060, "Duplicate column name \'keepalived_alert\'")':
|
||||
print('Updating... DB has been updated to version 5.3.2')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 5.3.2")
|
||||
|
||||
|
||||
def update_db_v_5_4_2():
|
||||
cursor = conn.cursor()
|
||||
sql = """ALTER TABLE `smon` ADD COLUMN slack_channel_id integer DEFAULT '0';"""
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
if str(e) == 'duplicate column name: slack_channel_id' or str(e) == '(1060, "Duplicate column name \'slack_channel_id\'")':
|
||||
print('Updating... DB has been updated to version 5.4.2')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 5.4.2")
|
||||
|
||||
|
||||
def update_db_v_5_4_3():
|
||||
query = Setting.update(param='nginx_path_logs', value='/var/log/nginx/').where(Setting.param == 'nginx_path_error_logs')
|
||||
try:
|
||||
query.execute()
|
||||
except Exception as e:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 5.4.3")
|
||||
|
||||
|
||||
def update_db_v_5_4_3_1():
|
||||
query = Setting.update(value='/etc/nginx/').where(Setting.param == 'nginx_dir')
|
||||
try:
|
||||
query.execute()
|
||||
except Exception as e:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 5.4.3-1")
|
||||
|
||||
|
||||
def update_db_v_6_0():
|
||||
cursor = conn.cursor()
|
||||
sql = list()
|
||||
|
@ -975,12 +848,6 @@ def update_all():
|
|||
if check_ver() is None:
|
||||
update_db_v_3_4_5_22()
|
||||
update_db_v_4_3_0()
|
||||
update_db_v_5_3_0()
|
||||
update_db_v_5_3_1()
|
||||
update_db_v_5_3_2_2()
|
||||
update_db_v_5_4_2()
|
||||
update_db_v_5_4_3()
|
||||
update_db_v_5_4_3_1()
|
||||
update_db_v_6_0()
|
||||
update_db_v_6_0_1()
|
||||
update_db_v_6_1_0()
|
||||
|
|
|
@ -91,6 +91,23 @@
|
|||
});
|
||||
return intro;
|
||||
}
|
||||
|
||||
function introHints() {
|
||||
let intro = introJs();
|
||||
intro.setOptions({
|
||||
hints: [
|
||||
{ hint: 'A new way for Groups and Roles. Try it!', element: '#user-group-role-th' },
|
||||
]
|
||||
});
|
||||
intro.onhintclose(function() {
|
||||
localStorage.setItem('introHintAdminRoles', 1);
|
||||
});
|
||||
return intro;
|
||||
}
|
||||
setTimeout(() => { var intro_temp = Intro(); startIntro(intro_temp); }, 3000);
|
||||
if (!localStorage.getItem('introHintAdminRoles')) {
|
||||
setTimeout(() => {
|
||||
var intro_temp = introHints();
|
||||
intro_temp.addHints();
|
||||
}, 1000);
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue