mirror of https://github.com/Aidaho12/haproxy-wi
parent
811255ba0b
commit
61dc21c822
|
@ -662,7 +662,7 @@ def update_db_v_7_3_1():
|
|||
|
||||
def update_ver():
|
||||
try:
|
||||
Version.update(version='7.3.1.0').execute()
|
||||
Version.update(version='7.3.2.0').execute()
|
||||
except Exception:
|
||||
print('Cannot update version')
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ def delete_s3_backups(backup_id: int) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def insert_new_git(server_id, service_id, repo, branch, period, cred, description):
|
||||
def insert_new_git(server_id, service_id, repo, branch, period, cred, description) -> None:
|
||||
try:
|
||||
GitSetting.insert(
|
||||
server_id=server_id, service_id=service_id, repo=repo, branch=branch, period=period,
|
||||
|
@ -72,9 +72,6 @@ def insert_new_git(server_id, service_id, repo, branch, period, cred, descriptio
|
|||
).execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def delete_git(git_id):
|
||||
|
|
|
@ -51,7 +51,7 @@ def return_ssh_keys_path(server_ip: str, **kwargs) -> dict:
|
|||
ssh_port = [str(server[10]) for server in server_sql.select_servers(server=server_ip)]
|
||||
ssh_settings.setdefault('port', ssh_port[0])
|
||||
except Exception as e:
|
||||
raise Exception(f'error: Cannot get SSH settings: {e}')
|
||||
raise Exception(f'error: Cannot get SSH port: {e}')
|
||||
|
||||
return ssh_settings
|
||||
|
||||
|
|
|
@ -9,65 +9,80 @@ import app.modules.db.server as server_sql
|
|||
import app.modules.db.service as service_sql
|
||||
import app.modules.server.ssh as ssh_mod
|
||||
import app.modules.server.server as server_mod
|
||||
import app.modules.common.common as common
|
||||
import app.modules.roxywi.common as roxywi_common
|
||||
import app.modules.service.installation as installation_mod
|
||||
|
||||
|
||||
def backup(serv, rpath, time, backup_type, rserver, cred, deljob, update, description) -> str:
|
||||
script = 'backup.sh'
|
||||
ssh_settings = ssh_mod.return_ssh_keys_path(rserver, id=cred)
|
||||
full_path = '/var/www/haproxy-wi/app'
|
||||
def delete_backup(serv: str, backup_id: int) -> None:
|
||||
if backup_sql.check_exists_backup(serv):
|
||||
raise Exception(f'Backup job for {serv} already exists')
|
||||
|
||||
if deljob:
|
||||
backup_sql.delete_backups(backup_id)
|
||||
roxywi_common.logging('backup ', f' a backup job for server {serv} has been deleted', roxywi=1, login=1)
|
||||
|
||||
|
||||
def backup(json_data) -> str:
|
||||
cred = int(json_data['cred'])
|
||||
server = common.is_ip_or_dns(json_data['server'])
|
||||
rserver = common.is_ip_or_dns(json_data['rserver'])
|
||||
ssh_settings = ssh_mod.return_ssh_keys_path(rserver, id=cred)
|
||||
update_id = ''
|
||||
description = ''
|
||||
if 'del_id' in json_data:
|
||||
time = ''
|
||||
rpath = ''
|
||||
backup_type = ''
|
||||
elif update:
|
||||
deljob = ''
|
||||
del_id = int(json_data['del_id'])
|
||||
else:
|
||||
deljob = ''
|
||||
if backup_sql.check_exists_backup(serv):
|
||||
return f'warning: Backup job for {serv} already exists'
|
||||
del_id = ''
|
||||
rpath = common.checkAjaxInput(json_data['rpath'])
|
||||
backup_type = common.checkAjaxInput(json_data['type'])
|
||||
time = common.checkAjaxInput(json_data['time'])
|
||||
description = common.checkAjaxInput(json_data['description'])
|
||||
if backup_sql.check_exists_backup(server):
|
||||
return f'warning: Backup job for {server} already exists'
|
||||
|
||||
os.system(f"cp {full_path}/scripts/{script} {full_path}/{script}")
|
||||
if 'update_id' in json_data:
|
||||
update_id = int(json_data['update_id'])
|
||||
|
||||
commands = [
|
||||
f"chmod +x {full_path}/{script} && {full_path}/{script} HOST={rserver} SERVER={serv} TYPE={backup_type} SSH_PORT={ssh_settings['port']} "
|
||||
f"TIME={time} RPATH={rpath} DELJOB={deljob} USER={ssh_settings['user']} KEY={ssh_settings['key']}"
|
||||
]
|
||||
|
||||
output, error = server_mod.subprocess_execute(commands[0])
|
||||
inv = {"server": {"hosts": {}}}
|
||||
server_ips = []
|
||||
inv['server']['hosts'][server] = {
|
||||
'HOST': rserver,
|
||||
"SERVER": server,
|
||||
"TYPE": backup_type,
|
||||
"TIME": time,
|
||||
"RPATH": rpath,
|
||||
"DELJOB": del_id,
|
||||
"USER": ssh_settings['user'],
|
||||
"KEY": ssh_settings['key']
|
||||
}
|
||||
server_ips.append(server)
|
||||
|
||||
try:
|
||||
os.remove(f'{full_path}/{script}')
|
||||
except Exception:
|
||||
pass
|
||||
installation_mod.run_ansible(inv, server_ips, 'backup')
|
||||
except Exception as e:
|
||||
raise Exception(f'error: {e}')
|
||||
|
||||
for line in output:
|
||||
if any(s in line for s in ("Traceback", "FAILED")):
|
||||
try:
|
||||
return f'error: {line}'
|
||||
except Exception:
|
||||
return f'error: {output}'
|
||||
else:
|
||||
if not deljob and not update:
|
||||
if backup_sql.insert_backup_job(serv, rserver, rpath, backup_type, time, cred, description):
|
||||
roxywi_common.logging('backup ', f' a new backup job for server {serv} has been created', roxywi=1,
|
||||
login=1)
|
||||
return render_template(
|
||||
'ajax/new_backup.html', backups=backup_sql.select_backups(server=serv, rserver=rserver), sshs=cred_sql.select_ssh()
|
||||
)
|
||||
if not del_id and not update_id:
|
||||
if backup_sql.insert_backup_job(server, rserver, rpath, backup_type, time, cred, description):
|
||||
roxywi_common.logging('backup ', f' a new backup job for server {server} has been created', roxywi=1,
|
||||
login=1)
|
||||
return render_template(
|
||||
'ajax/new_backup.html', backups=backup_sql.select_backups(server=server, rserver=rserver), sshs=cred_sql.select_ssh()
|
||||
)
|
||||
|
||||
else:
|
||||
raise Exception('error: Cannot add the job into DB')
|
||||
elif deljob:
|
||||
backup_sql.delete_backups(deljob)
|
||||
roxywi_common.logging('backup ', f' a backup job for server {serv} has been deleted', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
elif update:
|
||||
backup_sql.update_backup(serv, rserver, rpath, backup_type, time, cred, description, update)
|
||||
roxywi_common.logging('backup ', f' a backup job for server {serv} has been updated', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
else:
|
||||
raise Exception('Cannot add the job into DB')
|
||||
elif del_id:
|
||||
backup_sql.delete_backups(del_id)
|
||||
roxywi_common.logging('backup ', f' a backup job for server {server} has been deleted', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
elif update_id:
|
||||
backup_sql.update_backup(server, rserver, rpath, backup_type, time, cred, description, update_id)
|
||||
roxywi_common.logging('backup ', f' a backup job for server {server} has been updated', roxywi=1, login=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def s3_backup(server, s3_server, bucket, secret_key, access_key, time, deljob, description) -> str:
|
||||
|
@ -110,62 +125,46 @@ def s3_backup(server, s3_server, bucket, secret_key, access_key, time, deljob, d
|
|||
return 'ok'
|
||||
|
||||
|
||||
def git_backup(server_id, service_id, git_init, repo, branch, period, cred, deljob, description, backup_id) -> str:
|
||||
servers = roxywi_common.get_dick_permit()
|
||||
proxy = sql.get_setting('proxy')
|
||||
services = service_sql.select_services()
|
||||
def git_backup(server_id, service_id, git_init, repo, branch, period, cred, del_job, description, backup_id) -> str:
|
||||
server_ip = server_sql.select_server_ip_by_id(server_id)
|
||||
service_name = service_sql.select_service_name_by_id(service_id).lower()
|
||||
service_config_dir = sql.get_setting(service_name + '_dir')
|
||||
script = 'git_backup.sh'
|
||||
proxy_serv = ''
|
||||
ssh_settings = ssh_mod.return_ssh_keys_path('localhost', id=int(cred))
|
||||
full_path = '/var/www/haproxy-wi/app'
|
||||
|
||||
os.system(f"cp {full_path}/scripts/{script} {full_path}/{script}")
|
||||
|
||||
if proxy is not None and proxy != '' and proxy != 'None':
|
||||
proxy_serv = proxy
|
||||
ssh_settings = ssh_mod.return_ssh_keys_path(server_ip, id=cred)
|
||||
|
||||
if repo is None or git_init == '0':
|
||||
repo = ''
|
||||
if branch is None or branch == '0':
|
||||
branch = 'main'
|
||||
|
||||
commands = [
|
||||
f"chmod +x {full_path}/{script} && {full_path}/{script} HOST={server_ip} DELJOB={deljob} SERVICE={service_name} INIT={git_init} "
|
||||
f"SSH_PORT={ssh_settings['port']} PERIOD={period} REPO={repo} BRANCH={branch} CONFIG_DIR={service_config_dir} "
|
||||
f"PROXY={proxy_serv} USER={ssh_settings['user']} KEY={ssh_settings['key']}"
|
||||
]
|
||||
|
||||
output, error = server_mod.subprocess_execute(commands[0])
|
||||
inv = {"server": {"hosts": {}}}
|
||||
inv["server"]["hosts"][server_ip] = {
|
||||
"REPO": repo,
|
||||
"CONFIG_DIR": service_config_dir,
|
||||
"PERIOD": period,
|
||||
"INIT": git_init,
|
||||
"BRANCH": branch,
|
||||
"SERVICE": service_name,
|
||||
"DELJOB": del_job,
|
||||
"KEY": ssh_settings['key']
|
||||
}
|
||||
|
||||
try:
|
||||
os.remove(f'{full_path}/{script}')
|
||||
except Exception:
|
||||
pass
|
||||
installation_mod.run_ansible(inv, [server_ip], 'git_backup')
|
||||
except Exception as e:
|
||||
raise Exception(f'error: {e}')
|
||||
|
||||
for line in output:
|
||||
if any(s in line for s in ("Traceback", "FAILED")):
|
||||
try:
|
||||
return 'error: ' + line
|
||||
except Exception:
|
||||
return 'error: ' + output
|
||||
if not del_job:
|
||||
backup_sql.insert_new_git(server_id=server_id, service_id=service_id, repo=repo, branch=branch, period=period, cred=cred, description=description)
|
||||
kwargs = {
|
||||
"gits": backup_sql.select_gits(server_id=server_id, service_id=service_id),
|
||||
"sshs": cred_sql.select_ssh(),
|
||||
"servers": roxywi_common.get_dick_permit(),
|
||||
"services": service_sql.select_services(),
|
||||
"new_add": 1,
|
||||
"lang": roxywi_common.get_user_lang_for_flask()
|
||||
}
|
||||
roxywi_common.logging(server_ip, 'A new git job has been created', roxywi=1, login=1, keep_history=1, service=service_name)
|
||||
return render_template('ajax/new_git.html', **kwargs)
|
||||
else:
|
||||
if deljob == '0':
|
||||
if backup_sql.insert_new_git(
|
||||
server_id=server_id, service_id=service_id, repo=repo, branch=branch,
|
||||
period=period, cred=cred, description=description
|
||||
):
|
||||
gits = backup_sql.select_gits(server_id=server_id, service_id=service_id)
|
||||
sshs = cred_sql.select_ssh()
|
||||
|
||||
lang = roxywi_common.get_user_lang_for_flask()
|
||||
roxywi_common.logging(
|
||||
server_ip, ' A new git job has been created', roxywi=1, login=1, keep_history=1,
|
||||
service=service_name
|
||||
)
|
||||
return render_template('ajax/new_git.html', gits=gits, sshs=sshs, servers=servers, services=services, new_add=1, lang=lang)
|
||||
else:
|
||||
if backup_sql.delete_git(backup_id):
|
||||
return 'ok'
|
||||
if backup_sql.delete_git(backup_id):
|
||||
return 'ok'
|
||||
|
|
|
@ -204,7 +204,7 @@ def generate_service_inv(json_data: json, installed_service: str) -> object:
|
|||
return inv, server_ips
|
||||
|
||||
|
||||
def run_ansible(inv: dict, server_ips: str, ansible_role: str) -> object:
|
||||
def run_ansible(inv: dict, server_ips: list, ansible_role: str) -> object:
|
||||
inventory_path = '/var/www/haproxy-wi/app/scripts/ansible/inventory'
|
||||
inventory = f'{inventory_path}/{ansible_role}.json'
|
||||
proxy = sql.get_setting('proxy')
|
||||
|
|
|
@ -107,22 +107,33 @@ def get_slaves_for_udp_listener(cluster_id: int, vip: str) -> list:
|
|||
return servers
|
||||
|
||||
|
||||
def listener_actions(listener_id: int, action: str, group_id: int) -> str:
|
||||
if action not in ('start', 'stop', 'restart'):
|
||||
raise ValueError("error: Invalid action")
|
||||
def _return_listener_servers(listener_id: int, group_id=None):
|
||||
servers = []
|
||||
listener = udp_sql.get_listener(listener_id)
|
||||
if int(listener.group_id.group_id) != group_id:
|
||||
if group_id is not None and int(listener.group_id.group_id) != group_id:
|
||||
raise ValueError("error: Invalid group")
|
||||
if listener.cluster_id:
|
||||
get_slaves_for_udp_listener(listener.cluster_id, listener.vip)
|
||||
servers = get_slaves_for_udp_listener(listener.cluster_id, listener.vip)
|
||||
elif listener.server_id:
|
||||
server = server_sql.get_server_by_id(listener.server_id)
|
||||
servers.append(server.ip)
|
||||
if len(servers) < 1:
|
||||
raise ValueError("error: Cannot find server")
|
||||
|
||||
return servers, listener
|
||||
|
||||
|
||||
|
||||
def listener_actions(listener_id: int, action: str, group_id: int) -> str:
|
||||
if action not in ('start', 'stop', 'restart'):
|
||||
raise ValueError("error: Invalid action")
|
||||
|
||||
cmd = f'sudo systemctl {action} keepalived-udp-{listener_id}.service'
|
||||
print(cmd)
|
||||
try:
|
||||
servers, listener = _return_listener_servers(listener_id, group_id)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
for server_ip in servers:
|
||||
try:
|
||||
server_mod.ssh_command(server_ip, cmd)
|
||||
|
@ -130,3 +141,20 @@ def listener_actions(listener_id: int, action: str, group_id: int) -> str:
|
|||
except Exception as e:
|
||||
roxywi_common.handle_exceptions(e, 'Roxy-WI server', f'Cannot {action} for UDP balancer {listener.name}', roxywi=1)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def check_is_listener_active(listener_id: int) -> str:
|
||||
try:
|
||||
servers, listener = _return_listener_servers(listener_id)
|
||||
except Exception as e:
|
||||
raise Exception(e)
|
||||
statuses = []
|
||||
cmd = f'systemctl is-active keepalived-udp-{listener_id}.service'
|
||||
for server_ip in servers:
|
||||
status = server_mod.ssh_command(server_ip, cmd)
|
||||
statuses.append(status.replace('\n', '').replace('\r', ''))
|
||||
if 'inactive' in statuses and 'active' in statuses:
|
||||
return 'warning'
|
||||
elif 'inactive' in statuses and 'active' not in statuses:
|
||||
return 'error'
|
||||
return 'ok'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from flask import request, render_template, jsonify
|
||||
from flask import request, render_template, g, jsonify
|
||||
from flask_login import login_required
|
||||
|
||||
from app.routes.channel import bp
|
||||
|
@ -19,8 +19,9 @@ def before_request():
|
|||
@get_user_params()
|
||||
def channels():
|
||||
roxywi_common.check_user_group_for_flask()
|
||||
lang = g.user_params['lang']
|
||||
|
||||
return render_template('channel.html')
|
||||
return render_template('channel.html', lang=lang)
|
||||
|
||||
|
||||
@bp.route('/load')
|
||||
|
|
|
@ -296,40 +296,29 @@ def show_firewall(server_ip):
|
|||
return server_mod.show_firewalld_rules(server_ip)
|
||||
|
||||
|
||||
@bp.route('/backup')
|
||||
@bp.route('/backup', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
||||
@get_user_params()
|
||||
def load_backup():
|
||||
user_group = g.user_params['group_id']
|
||||
kwargs = {
|
||||
'sshs': cred_sql.select_ssh(group=user_group),
|
||||
'servers': roxywi_common.get_dick_permit(virt=1, disable=0, only_group=1),
|
||||
'backups': backup_sql.select_backups(),
|
||||
's3_backups': backup_sql.select_s3_backups(),
|
||||
'gits': backup_sql.select_gits(),
|
||||
'lang': g.user_params['lang'],
|
||||
'is_needed_tool': common.is_tool('ansible'),
|
||||
'user_subscription': roxywi_common.return_user_subscription(),
|
||||
}
|
||||
return render_template('include/admin_backup.html', **kwargs)
|
||||
|
||||
@bp.post('/backup/create')
|
||||
@bp.post('/backup/delete')
|
||||
@bp.post('/backup/update')
|
||||
def create_backup():
|
||||
server = common.is_ip_or_dns(request.form.get('server'))
|
||||
rpath = common.checkAjaxInput(request.form.get('rpath'))
|
||||
time = common.checkAjaxInput(request.form.get('time'))
|
||||
backup_type = common.checkAjaxInput(request.form.get('type'))
|
||||
rserver = common.checkAjaxInput(request.form.get('rserver'))
|
||||
cred = int(request.form.get('cred'))
|
||||
deljob = common.checkAjaxInput(request.form.get('deljob'))
|
||||
update = common.checkAjaxInput(request.form.get('backupupdate'))
|
||||
description = common.checkAjaxInput(request.form.get('description'))
|
||||
|
||||
try:
|
||||
return backup_mod.backup(server, rpath, time, backup_type, rserver, cred, deljob, update, description)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
if request.method == 'GET':
|
||||
user_group = g.user_params['group_id']
|
||||
kwargs = {
|
||||
'sshs': cred_sql.select_ssh(group=user_group),
|
||||
'servers': roxywi_common.get_dick_permit(virt=1, disable=0, only_group=1),
|
||||
'backups': backup_sql.select_backups(),
|
||||
's3_backups': backup_sql.select_s3_backups(),
|
||||
'gits': backup_sql.select_gits(),
|
||||
'lang': g.user_params['lang'],
|
||||
'is_needed_tool': common.is_tool('ansible'),
|
||||
'user_subscription': roxywi_common.return_user_subscription(),
|
||||
}
|
||||
return render_template('include/admin_backup.html', **kwargs)
|
||||
elif request.method in ('POST', 'PUT', 'DELETE'):
|
||||
json_data = request.get_json()
|
||||
try:
|
||||
data = backup_mod.backup(json_data)
|
||||
return jsonify({'status': 'ok', 'data': data})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, f'Cannot {request.method} backup')
|
||||
|
||||
|
||||
@bp.post('/s3backup/create')
|
||||
|
@ -350,18 +339,24 @@ def create_s3_backup():
|
|||
return str(e)
|
||||
|
||||
|
||||
@bp.post('/git/create')
|
||||
@bp.post('/git/delete')
|
||||
@bp.route('/git', methods=['DELETE', 'POST'])
|
||||
def create_git_backup():
|
||||
server_id = request.form.get('server')
|
||||
service_id = request.form.get('git_service')
|
||||
git_init = request.form.get('git_init')
|
||||
repo = request.form.get('git_repo')
|
||||
branch = request.form.get('git_branch')
|
||||
period = request.form.get('time')
|
||||
cred = request.form.get('cred')
|
||||
deljob = request.form.get('git_deljob')
|
||||
description = request.form.get('description')
|
||||
backup_id = request.form.get('git_backup')
|
||||
json_data = request.get_json()
|
||||
server_id = int(json_data['server'])
|
||||
service_id = int(json_data['service'])
|
||||
git_init = int(json_data['init'])
|
||||
repo = common.checkAjaxInput(json_data['repo'])
|
||||
branch = common.checkAjaxInput(json_data['branch'])
|
||||
period = common.checkAjaxInput(json_data['time'])
|
||||
cred = int(json_data['cred'])
|
||||
del_job = int(json_data['del_job'])
|
||||
description = common.checkAjaxInput(json_data['desc'])
|
||||
backup_id = ''
|
||||
if request.method == 'DELETE':
|
||||
backup_id = json_data['backup_id']
|
||||
|
||||
return backup_mod.git_backup(server_id, service_id, git_init, repo, branch, period, cred, deljob, description, backup_id)
|
||||
try:
|
||||
data = backup_mod.git_backup(server_id, service_id, git_init, repo, branch, period, cred, del_job, description, backup_id)
|
||||
return jsonify({'status': 'ok', 'data': data})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, f'Cannot {request.method} git backup')
|
||||
|
|
|
@ -110,3 +110,13 @@ def action_with_listener(service, listener_id, action):
|
|||
return jsonify({'status': 'done'})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e,f'Cannot {action} listener')
|
||||
|
||||
|
||||
@bp.get('/<service>/listener/<int:listener_id>/check')
|
||||
@check_services
|
||||
def check_listener(service, listener_id):
|
||||
try:
|
||||
status = udp_mod.check_is_listener_active(listener_id)
|
||||
return jsonify({'status': status})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e,f'Cannot get status')
|
||||
|
|
|
@ -69,8 +69,6 @@ def create_user():
|
|||
return jsonify({'status': 'deleted'})
|
||||
except Exception as e:
|
||||
return roxywi_common.handle_json_exceptions(e, f'Cannot delete the user {user_id}')
|
||||
else:
|
||||
abort(405)
|
||||
|
||||
|
||||
@bp.route('/ldap/<username>')
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
- hosts: backup
|
||||
- hosts: all
|
||||
become: yes
|
||||
become_method: sudo
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Set SSH port
|
||||
set_fact:
|
||||
ansible_port: "{{SSH_PORT}}"
|
||||
|
||||
- name: Creates directory
|
||||
file:
|
||||
path: "{{ RPATH }}/roxy-wi-configs-backup/configs"
|
||||
state: directory
|
||||
owner: "{{ ansible_user }}"
|
||||
when: DELJOB|length == 0
|
||||
when: not DELJOB
|
||||
|
||||
- hosts: haproxy_wi
|
||||
- hosts: localhost
|
||||
become: yes
|
||||
become_method: sudo
|
||||
gather_facts: no
|
||||
tasks:
|
||||
|
||||
- name: Creates backup jobs
|
||||
cron:
|
||||
name: "Roxy-WI Backup configs for server {{ SERVER }} {{ item }}"
|
||||
special_time: "{{ TIME }}"
|
||||
job: "rsync -arv {{ TYPE }} /var/lib/roxy-wi/configs/{{ item }}/{{ SERVER }}* {{ ansible_user }}@{{ HOST }}:{{ RPATH }}/roxy-wi-configs-backup/configs/{{ item }} -e 'ssh -i {{ KEY }} -o StrictHostKeyChecking=no' --log-file=/var/www/haproxy-wi/log/backup.log"
|
||||
when: DELJOB|length == 0
|
||||
when: not DELJOB
|
||||
with_items:
|
||||
- kp_config
|
||||
- hap_config
|
||||
|
@ -36,7 +31,7 @@
|
|||
cron:
|
||||
name: "Roxy-WI Backup configs for server {{ SERVER }} {{ item }}"
|
||||
state: absent
|
||||
when: DELJOB|length > 0
|
||||
when: DELJOB
|
||||
with_items:
|
||||
- kp_config
|
||||
- hap_config
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
- hosts: "{{ variable_host }}"
|
||||
- hosts: all
|
||||
become: yes
|
||||
become_method: sudo
|
||||
gather_facts: no
|
||||
tasks:
|
||||
|
||||
- name: Check if .git exists
|
||||
stat:
|
||||
path: "{{ CONFIG_DIR }}/.git"
|
||||
|
@ -12,7 +11,7 @@
|
|||
- name: Fail if has been installed
|
||||
fail:
|
||||
msg="Git configuration not found. Initialize git at the beginning"
|
||||
when: not register_name.stat.exists and INIT == '0' and DELJOB == '0'
|
||||
when: not register_name.stat.exists and not INIT and DELJOB
|
||||
|
||||
- name: Install git
|
||||
package:
|
||||
|
@ -21,7 +20,7 @@
|
|||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
|
||||
- name: Create home dir
|
||||
file:
|
||||
|
@ -30,7 +29,7 @@
|
|||
mode: 0700
|
||||
group: '{{ ansible_user }}'
|
||||
owner: '{{ ansible_user }}'
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
|
||||
- name: Copy ssh file
|
||||
copy:
|
||||
|
@ -40,14 +39,14 @@
|
|||
group: '{{ ansible_user }}'
|
||||
owner: '{{ ansible_user }}'
|
||||
force: no
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
|
||||
- name: Add write permisions
|
||||
- name: Add write permissions
|
||||
shell: "chmod o+wr -R {{ CONFIG_DIR }}"
|
||||
|
||||
- name: Git init
|
||||
shell: 'cd {{ CONFIG_DIR }} && git init'
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
become: no
|
||||
|
||||
- name: Git configure
|
||||
|
@ -57,16 +56,16 @@
|
|||
[user]
|
||||
name = Roxy-WI
|
||||
email = roxy-wi@.com
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
|
||||
- name: Git add remote
|
||||
shell: 'cd {{ CONFIG_DIR }} && git add --all . && git commit -m "Roxy-WI init repo" && git branch -M {{ BRANCH }} && git remote add origin {{ REPO }}'
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
become: no
|
||||
|
||||
- name: Git add push
|
||||
shell: 'cd {{ CONFIG_DIR }} && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git push -u origin {{ BRANCH }}'
|
||||
when: INIT == '1'
|
||||
when: INIT
|
||||
become: no
|
||||
|
||||
- name: Creates git job
|
||||
|
@ -74,12 +73,12 @@
|
|||
name: "Git backup {{ SERVICE }} configs"
|
||||
special_time: "{{ PERIOD }}"
|
||||
job: 'cd {{ CONFIG_DIR }} && git add --all . && git commit -m "Roxy-WI backup job at $(date)" && git push --set-upstream origin {{ BRANCH }}'
|
||||
when: DELJOB == '0'
|
||||
when: not DELJOB
|
||||
become: no
|
||||
|
||||
- name: Removes git backup job
|
||||
cron:
|
||||
name: "Git backup {{ SERVICE }} configs"
|
||||
state: absent
|
||||
when: DELJOB == '1'
|
||||
when: DELJOB
|
||||
become: no
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/bash
|
||||
for ARGUMENT in "$@"
|
||||
do
|
||||
KEY=$(echo $ARGUMENT | cut -f1 -d=)
|
||||
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
|
||||
|
||||
case "$KEY" in
|
||||
RPATH) RPATH=${VALUE} ;;
|
||||
TIME) TIME=${VALUE} ;;
|
||||
TYPE) TYPE=${VALUE} ;;
|
||||
HOST) HOST=${VALUE} ;;
|
||||
SERVER) SERVER=${VALUE} ;;
|
||||
USER) USER=${VALUE} ;;
|
||||
KEY) KEY=${VALUE} ;;
|
||||
DELJOB) DELJOB=${VALUE} ;;
|
||||
SSH_PORT) SSH_PORT=${VALUE} ;;
|
||||
*)
|
||||
esac
|
||||
done
|
||||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=/var/www/haproxy-wi/app/scripts/ansible/
|
||||
echo '[backup]' > $PWD/$HOST
|
||||
echo "$HOST ansible_port=$SSH_PORT" >> $PWD/$HOST
|
||||
echo '[haproxy_wi]' >> $PWD/$HOST
|
||||
echo 'localhost' >> $PWD/$HOST
|
||||
|
||||
if [[ $TYPE == 'synchronization' ]]; then
|
||||
TYPE='--delete'
|
||||
else
|
||||
TYPE=''
|
||||
fi
|
||||
|
||||
ansible-playbook $PWD/roles/backup.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST RPATH=$RPATH TYPE=$TYPE TIME=$TIME HOST=$HOST SERVER=$SERVER KEY=$KEY DELJOB=$DELJOB SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
echo "error: Can't create backup job"
|
||||
rm -f $PWD/$HOST
|
||||
exit 1
|
||||
fi
|
||||
rm -f $PWD/$HOST
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
for ARGUMENT in "$@"
|
||||
do
|
||||
KEY=$(echo $ARGUMENT | cut -f1 -d=)
|
||||
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
|
||||
|
||||
case "$KEY" in
|
||||
HOST) HOST=${VALUE} ;;
|
||||
DELJOB) DELJOB=${VALUE} ;;
|
||||
SERVICE) SERVICE=${VALUE} ;;
|
||||
INIT) INIT=${VALUE} ;;
|
||||
REPO) REPO=${VALUE} ;;
|
||||
BRANCH) BRANCH=${VALUE} ;;
|
||||
PERIOD) PERIOD=${VALUE} ;;
|
||||
CONFIG_DIR) CONFIG_DIR=${VALUE} ;;
|
||||
USER) USER=${VALUE} ;;
|
||||
KEY) KEY=${VALUE} ;;
|
||||
SSH_PORT) SSH_PORT=${VALUE} ;;
|
||||
PROXY) PROXY=${VALUE} ;;
|
||||
*)
|
||||
esac
|
||||
done
|
||||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=/var/www/haproxy-wi/app/scripts/ansible/
|
||||
echo "$HOST ansible_port=$SSH_PORT" >> $PWD/$HOST
|
||||
|
||||
ansible-playbook $PWD/roles/git_backup.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST DELJOB=$DELJOB SERVICE=$SERVICE INIT=$INIT REPO=$REPO BRANCH=$BRANCH PERIOD=$PERIOD CONFIG_DIR=$CONFIG_DIR PROXY=$PROXY KEY=$KEY" -i $PWD/$HOST
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
echo "error: Cannot create a git job"
|
||||
fi
|
||||
rm -f $PWD/$HOST
|
|
@ -31,17 +31,17 @@ $( function() {
|
|||
}
|
||||
}]
|
||||
});
|
||||
$( "#ssh_enable_table input" ).change(function() {
|
||||
$("#ssh_enable_table input").change(function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateSSH(id[1])
|
||||
sshKeyEnableShow(id[1])
|
||||
});
|
||||
$( "#ssh_enable_table select" ).on('selectmenuchange',function() {
|
||||
$("#ssh_enable_table select").on('selectmenuchange', function () {
|
||||
let id = $(this).attr('id').split('-');
|
||||
updateSSH(id[1])
|
||||
sshKeyEnableShow(id[1])
|
||||
});
|
||||
$('#new-ssh_enable').click(function() {
|
||||
$('#new-ssh_enable').click(function () {
|
||||
if ($('#new-ssh_enable').is(':checked')) {
|
||||
$('#ssh_pass').css('display', 'none');
|
||||
} else {
|
||||
|
|
|
@ -89,6 +89,10 @@ function addUser(dialog_id) {
|
|||
if ($('#activeuser').is(':checked')) {
|
||||
enabled = '1';
|
||||
}
|
||||
let user_group = $('#new-group').val();
|
||||
if (user_group === undefined || user_group === null) {
|
||||
user_group = $('#new-sshgroup').val();
|
||||
}
|
||||
if (valid) {
|
||||
let jsonData = {
|
||||
"username": new_username_div.val(),
|
||||
|
@ -96,7 +100,7 @@ function addUser(dialog_id) {
|
|||
"email": email_div.val(),
|
||||
"role": $('#new-role').val(),
|
||||
"enabled": enabled,
|
||||
"user_group": $('#new-group').val(),
|
||||
"user_group": user_group,
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/user",
|
||||
|
@ -157,7 +161,6 @@ function updateUser(id) {
|
|||
if ($('#activeuser-' + id).is(':checked')) {
|
||||
enabled = '1';
|
||||
}
|
||||
toastr.remove();
|
||||
let jsonData = {
|
||||
"username": $('#login-' + id).val(),
|
||||
"email": $('#email-' + id).val(),
|
||||
|
|
|
@ -138,31 +138,25 @@ function addBackup(dialog_id) {
|
|||
valid = valid && checkLength($('#backup-time'), "backup time", 1);
|
||||
valid = valid && checkLength($('#backup-credentials'), "backup credentials", 1);
|
||||
if (valid) {
|
||||
let jsonData = {
|
||||
"server": $('#backup-server').val(),
|
||||
"rserver": $('#rserver').val(),
|
||||
"rpath": $('#rpath').val(),
|
||||
"type": $('#backup-type').val(),
|
||||
"time": $('#backup-time').val(),
|
||||
"cred": $('#backup-credentials').val(),
|
||||
"description": $('#backup-description').val()
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/server/backup/create",
|
||||
data: {
|
||||
server: $('#backup-server').val(),
|
||||
rserver: $('#rserver').val(),
|
||||
rpath: $('#rpath').val(),
|
||||
type: $('#backup-type').val(),
|
||||
time: $('#backup-time').val(),
|
||||
cred: $('#backup-credentials').val(),
|
||||
description: $('#backup-description').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
url: "/app/server/backup",
|
||||
data: JSON.stringify(jsonData),
|
||||
type: "PUT",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('info: ') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.info(data);
|
||||
} else if (data.indexOf('warning: ') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.warning(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
common_ajax_action_after_success(dialog_id, 'newbackup', 'ajax-backup-table', data);
|
||||
common_ajax_action_after_success(dialog_id, 'newbackup', 'ajax-backup-table', data.data);
|
||||
$("select").selectmenu();
|
||||
}
|
||||
}
|
||||
|
@ -212,47 +206,46 @@ function addS3Backup(dialog_id) {
|
|||
}
|
||||
}
|
||||
function addGit(dialog_id) {
|
||||
let valid = true;
|
||||
toastr.clear();
|
||||
allFields = $([]).add($('#git-server')).add($('#git-service')).add($('#git-time')).add($('#git-credentials')).add($('#git-branch'))
|
||||
allFields.removeClass("ui-state-error");
|
||||
valid = valid && checkLength($('#git-server'), "Server ", 1);
|
||||
valid = valid && checkLength($('#git-service'), "Service", 1);
|
||||
valid = valid && checkLength($('#git-credentials'), "Credentials", 1);
|
||||
valid = valid && checkLength($('#git-branch'), "Branch name", 1);
|
||||
let valid = true;
|
||||
let server_div = $('#git-server');
|
||||
let service_div = $('#git-service');
|
||||
let branch_div = $('#git-branch');
|
||||
let time_div = $('#git-time');
|
||||
let cred_div = $('#git-credentials');
|
||||
let git_init = 0;
|
||||
if ($('#git-init').is(':checked')) {
|
||||
git_init = '1';
|
||||
}
|
||||
let allFields = $([]).add(server_div).add(service_div).add(time_div).add(cred_div).add(branch_div);
|
||||
allFields.removeClass("ui-state-error");
|
||||
valid = valid && checkLength(server_div, "Server ", 1);
|
||||
valid = valid && checkLength(service_div, "Service", 1);
|
||||
valid = valid && checkLength(cred_div, "Credentials", 1);
|
||||
valid = valid && checkLength(branch_div, "Branch name", 1);
|
||||
if (valid) {
|
||||
let jsonData = {
|
||||
"server": server_div.val(),
|
||||
"service": service_div.val(),
|
||||
"init": git_init,
|
||||
"repo": $('#git-repo').val(),
|
||||
"branch": branch_div.val(),
|
||||
"time": time_div.val(),
|
||||
"cred": cred_div.val(),
|
||||
"del_job": 0,
|
||||
"desc": $('#git-description').text(),
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/server/git/create",
|
||||
data: {
|
||||
server: $('#git-server').val(),
|
||||
git_service: $('#git-service').val(),
|
||||
git_init: git_init,
|
||||
git_repo: $('#git-repo').val(),
|
||||
git_branch: $('#git-branch').val(),
|
||||
time: $('#git-time').val(),
|
||||
cred: $('#git-credentials').val(),
|
||||
description: $('#git-description').val(),
|
||||
git_deljob: 0,
|
||||
token: $('#token').val()
|
||||
},
|
||||
url: "/app/server/git",
|
||||
data: JSON.stringify(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else if (data.indexOf('success: ') != '-1') {
|
||||
common_ajax_action_after_success(dialog_id, 'newgit', 'ajax-git-table', data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
common_ajax_action_after_success(dialog_id, 'newgit', 'ajax-git-table', data.data);
|
||||
$("select").selectmenu();
|
||||
} else if (data.indexOf('info: ') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.info(data);
|
||||
} else if (data.indexOf('warning: ') != '-1') {
|
||||
toastr.clear();
|
||||
toastr.warning(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -344,22 +337,22 @@ function cloneS3Backup(id) {
|
|||
}
|
||||
function removeBackup(id) {
|
||||
$("#backup-table-" + id).css("background-color", "#f2dede");
|
||||
let jsonData = {
|
||||
"del_id": id,
|
||||
"cred": $('#backup-credentials-' + id).val(),
|
||||
"server": $('#backup-server-' + id).text(),
|
||||
"rserver": $('#backup-rserver-' + id).val()
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/server/backup/delete",
|
||||
data: {
|
||||
deljob: id,
|
||||
cred: $('#backup-credentials-' + id).val(),
|
||||
server: $('#backup-server-' + id).text(),
|
||||
rserver: $('#backup-rserver-' + id).val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
url: "/app/server/backup",
|
||||
data: JSON.stringify(jsonData),
|
||||
type: "DELETE",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('ok') != '-1') {
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
$("#backup-table-" + id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -387,27 +380,28 @@ function removeS3Backup(id) {
|
|||
}
|
||||
function removeGit(id) {
|
||||
$("#git-table-" + id).css("background-color", "#f2dede");
|
||||
let jsonData = {
|
||||
"backup_id": id,
|
||||
"del_job": 1,
|
||||
"init": 0,
|
||||
"repo": 0,
|
||||
"branch": 0,
|
||||
"time": 0,
|
||||
"cred": $('#git-credentials-id-' + id).text(),
|
||||
"server": $('#git-server-id-' + id).text(),
|
||||
"service": $('#git-service-id-' + id).text(),
|
||||
"desc": '',
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/server/git/delete",
|
||||
data: {
|
||||
git_backup: id,
|
||||
git_deljob: 1,
|
||||
git_init: 0,
|
||||
repo: 0,
|
||||
branch: 0,
|
||||
time: 0,
|
||||
cred: $('#git-credentials-id-' + id).text(),
|
||||
server: $('#git-server-id-' + id).text(),
|
||||
git_service: $('#git-service-id-' + id).text(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
url: "/app/server/git",
|
||||
data: JSON.stringify(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
type: "DELETE",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('ok') != '-1') {
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
$("#git-table-" + id).remove();
|
||||
} else if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -417,24 +411,24 @@ function updateBackup(id) {
|
|||
if ($("#backup-type-" + id + " option:selected").val() == "-------" || $('#backup-rserver-' + id).val() == '' || $('#backup-rpath-' + id).val() == '') {
|
||||
toastr.error('All fields must be completed');
|
||||
} else {
|
||||
let jsonData = {
|
||||
"update_id": id,
|
||||
"server": $('#backup-server-' + id).text(),
|
||||
"rserver": $('#backup-rserver-' + id).val(),
|
||||
"rpath": $('#backup-rpath-' + id).val(),
|
||||
"type": $('#backup-type-' + id).val(),
|
||||
"time": $('#backup-time-' + id).val(),
|
||||
"cred": $('#backup-credentials-' + id).val(),
|
||||
"description": $('#backup-description-' + id).val()
|
||||
}
|
||||
$.ajax({
|
||||
url: "/app/server/backup/update",
|
||||
data: {
|
||||
backupupdate: id,
|
||||
server: $('#backup-server-' + id).text(),
|
||||
rserver: $('#backup-rserver-' + id).val(),
|
||||
rpath: $('#backup-rpath-' + id).val(),
|
||||
type: $('#backup-type-' + id).val(),
|
||||
time: $('#backup-time-' + id).val(),
|
||||
cred: $('#backup-credentials-' + id).val(),
|
||||
description: $('#backup-description-' + id).val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
url: "/app/server/backup",
|
||||
data: JSON.stringify(jsonData),
|
||||
type: "PUT",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
data = data.replace(/\s+/g, ' ');
|
||||
if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
|
||||
toastr.error(data);
|
||||
if (data.status === 'failed') {
|
||||
toastr.error(data.error);
|
||||
} else {
|
||||
toastr.clear();
|
||||
$("#backup-table-" + id).addClass("update", 1000);
|
||||
|
|
|
@ -183,6 +183,9 @@ function createUDPListenerStep2(edited, listener_id, place) {
|
|||
}, {
|
||||
text: apply_word,
|
||||
click: function () {
|
||||
if (!validateUDPListenerForm(place)) {
|
||||
return false;
|
||||
}
|
||||
jsonData = getFormData($("#create_udp_listener"));
|
||||
saveUdpListener(jsonData, $(this), listener_id, edited, 1);
|
||||
}
|
||||
|
@ -254,7 +257,6 @@ function getFormData($form) {
|
|||
let unindexed_array = $form.serializeArray();
|
||||
let indexed_array = {};
|
||||
indexed_array['servers'] = {};
|
||||
console.log(unindexed_array)
|
||||
|
||||
$.map(unindexed_array, function (n, i) {
|
||||
indexed_array[n['name']] = n['value'];
|
||||
|
@ -449,6 +451,7 @@ function ajaxActionListener(action, listener_id) {
|
|||
} else {
|
||||
toastr.success(`Listener has been ${action}ed`);
|
||||
getUDPListener(listener_id);
|
||||
checkStatus(listener_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -466,3 +469,39 @@ function createBackendServer(server='', port='', weight='1') {
|
|||
'</div>').insertBefore('.add-server');
|
||||
$.getScript(awesome);
|
||||
}
|
||||
function checkStatus(listener_id) {
|
||||
if (sessionStorage.getItem('check-service-udp') == 0) {
|
||||
return false;
|
||||
}
|
||||
NProgress.configure({showSpinner: false});
|
||||
let listener_div = $('#listener-' + listener_id);
|
||||
$.ajax({
|
||||
url: "/app/udp/listener/" + listener_id + "/check",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data) {
|
||||
try {
|
||||
if (data.indexOf('logout') != '-1') {
|
||||
sessionStorage.setItem('check-service-udp', 0);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
if (data.status === 'ok') {
|
||||
listener_div.addClass('div-server-head-up');
|
||||
listener_div.attr('title', 'All services are UP');
|
||||
listener_div.removeClass('div-server-head-down');
|
||||
listener_div.removeClass('div-server-head-unknown');
|
||||
} else if (data.status === 'failed' || data.status === 'error') {
|
||||
listener_div.removeClass('div-server-head-unknown');
|
||||
listener_div.removeClass('div-server-head-up');
|
||||
listener_div.addClass('div-server-head-down');
|
||||
listener_div.attr('title', 'All services are DOWN');
|
||||
} else if (data.status === 'warning') {
|
||||
listener_div.addClass('div-server-head-unknown');
|
||||
listener_div.removeClass('div-server-head-up');
|
||||
listener_div.removeClass('div-server-head-down');
|
||||
listener_div.attr('title', 'Not all services are UP');
|
||||
}
|
||||
}
|
||||
});
|
||||
NProgress.configure({showSpinner: true});
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if b.description != 'None' %}
|
||||
<input type="text" id="backup-description-{{b.id}}" value="{{b.description}}" class="form-control">
|
||||
<input type="text" id="backup-description-{{b.id}}" value="{{b.description.replace("'", "")}}" class="form-control">
|
||||
{% else %}
|
||||
<input type="text" id="backup-description-{{b.id}}" class="form-control">
|
||||
{% endif %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% include 'include/admin_servers.html' %}
|
||||
<script>
|
||||
$( function() {
|
||||
{% if page != "servers.py" %}
|
||||
{% if g.user_params['role'] == 1 %}
|
||||
$("#servergroup-{{ server.0}}" ).selectmenu({
|
||||
width: 100
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<a class="ui-button ui-widget ui-corner-all" title="{{lang.words.show|title()}} {{lang.words.versions}}" onclick="openVersions()">{{lang.menu_links.versions.link}}</a>
|
||||
{% endif %}
|
||||
{% if g.user_params['role'] <= 2 %}
|
||||
<a href="/app/servers#backup" class="ui-button ui-widget ui-corner-all" title="Git">Git</a>
|
||||
<a href="/app/admin#backup" class="ui-button ui-widget ui-corner-all" title="Git">Git</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
</p>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if b.description is not none %}
|
||||
{{ input('backup-description-'+b.id|string(), value=b.description) }}
|
||||
{{ input('backup-description-'+b.id|string(), value=b.description.replace("'", "")) }}
|
||||
{% else %}
|
||||
{{ input('backup-description-'+b.id|string()) }}
|
||||
{% endif %}
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
<option disabled selected>{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.role}}</option>
|
||||
{% for role in roles %}
|
||||
{% if role.name != "superAdmin" %}
|
||||
<option value="{{ role.name }}">{{ role.name }}</option>
|
||||
<option value="{{ role.role_id }}">{{ role.name }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
|
@ -39,3 +39,7 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
checkStatus('{{listener.id}}');
|
||||
setInterval(checkStatus, 15000, '{{listener.id}}');
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue