Changelog: https://roxy-wi.org/changelog#6_3_3
pull/355/head
Pavel Loginov 2 years ago
parent 6ec8df1ee5
commit ec87633690

@ -966,7 +966,7 @@ def update_db_v_6_2_1():
def update_ver():
try:
Version.update(version='6.3.2.0').execute()
Version.update(version='6.3.3.0').execute()
except Exception:
print('Cannot update version')

@ -2106,6 +2106,7 @@ def select_service_table_metrics(service: str, group_id: int):
def update_setting(param: str, val: str, user_group: int) -> bool:
print(val)
query = Setting.update(value=val).where((Setting.param == param) & (Setting.group == user_group))
try:
query.execute()
@ -2315,7 +2316,7 @@ def select_nginx(serv):
return query_res
def update_nginx(serv):
def update_nginx(serv: str) -> bool:
query = Server.update(nginx=1).where(Server.ip == serv)
try:
query.execute()
@ -2325,6 +2326,16 @@ def update_nginx(serv):
return False
def update_apache(serv: str) -> bool:
query = Server.update(apache=1).where(Server.ip == serv)
try:
query.execute()
return True
except Exception as e:
out_error(e)
return False
def select_haproxy(serv):
try:
query_res = Server.get(Server.ip == serv).haproxy

@ -1,22 +1,22 @@
from datetime import datetime, timedelta
from pytz import timezone
from configparser import ConfigParser, ExtendedInterpolation
import configparser
class GetConfigVar:
def __init__(self):
self.path_config = "/etc/roxy-wi/roxy-wi.cfg"
self.config = ConfigParser(interpolation=ExtendedInterpolation())
self.config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
self.config.read(self.path_config)
def get_config_var(self, sec, var):
try:
return self.config.get(sec, var)
except configparser.Error as e:
print(f'error: in the config file: {self.path_config}: {e}')
except Exception as e:
print('Content-type: text/html\n')
print(
f'<center><div class="alert alert-danger">Check the config file. Presence section {sec} and parameter {var}</div>')
print(f'Check the config file. Presence section {sec} and parameter {var}')
print(e)
return

@ -6,6 +6,7 @@ from jinja2 import Environment, FileSystemLoader
import modules.db.sql as sql
import modules.common.common as common
import modules.roxywi.logs as roxy_logs
import modules.roxywi.common as roxywi_common
import modules.server.server as server_mod
import modules.service.common as service_common
@ -195,3 +196,76 @@ def show_apache_bytes(server_ip: str) -> None:
print(template)
else:
print('error: cannot connect to Apache stat page')
def show_services_overview() -> None:
import psutil
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ajax/show_services_ovw.html')
user_params = roxywi_common.get_users_params()
grafana = 0
metrics_worker = 0
checker_worker = 0
servers_group = []
host = os.environ.get('HTTP_HOST', '')
user_group = roxywi_common.get_user_group(id=1)
if (user_params['role'] == 2 or user_params['role'] == 3) and int(user_group) != 1:
for s in user_params['servers']:
servers_group.append(s[2])
is_checker_worker = len(sql.select_all_alerts(group=user_group))
is_metrics_worker = len(sql.select_servers_metrics_for_master(group=user_group))
for pids in psutil.pids():
if pids < 300:
continue
try:
pid = psutil.Process(pids)
cmdline_out = pid.cmdline()
if len(cmdline_out) > 2:
if 'checker_' in cmdline_out[1]:
if len(servers_group) > 0:
if cmdline_out[2] in servers_group:
checker_worker += 1
else:
checker_worker += 1
elif 'metrics_' in cmdline_out[1]:
if len(servers_group) > 0:
if cmdline_out[2] in servers_group:
metrics_worker += 1
else:
metrics_worker += 1
if len(servers_group) == 0:
if 'grafana' in cmdline_out[1]:
grafana += 1
except psutil.NoSuchProcess:
pass
cmd = "systemctl is-active roxy-wi-metrics"
metrics_master, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-checker"
checker_master, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-keep_alive"
keep_alive, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-smon"
smon, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-portscanner"
port_scanner, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-socket"
socket, stderr = server_mod.subprocess_execute(cmd)
rendered_template = template.render(
role=user_params['role'], metrics_master=''.join(metrics_master), metrics_worker=metrics_worker,
checker_master=''.join(checker_master), checker_worker=checker_worker, keep_alive=''.join(keep_alive),
smon=''.join(smon), port_scanner=''.join(port_scanner), grafana=grafana, socket=''.join(socket),
is_checker_worker=is_checker_worker, is_metrics_worker=is_metrics_worker, host=host,
roxy_wi_log_id=roxy_logs.roxy_wi_log(log_id=1, file="roxy-wi-"),
metrics_log_id=roxy_logs.roxy_wi_log(log_id=1, file="metrics"),
checker_log_id=roxy_logs.roxy_wi_log(log_id=1, file="checker"),
keep_alive_log_id=roxy_logs.roxy_wi_log(log_id=1, file="keep_alive"),
socket_log_id=roxy_logs.roxy_wi_log(log_id=1, file="socket"), error=stderr
)
print(rendered_template)

@ -282,3 +282,30 @@ def get_stat_page(server_ip: str, service: str) -> None:
print(template)
else:
print(data.decode('utf-8'))
def show_service_version(server_ip: str, service: str) -> None:
if service not in ('nginx', 'apache', 'haproxy'):
print('warning: wrong service')
return None
if service == 'haproxy':
print(check_haproxy_version(server_ip))
return None
server_id = sql.select_server_id_by_ip(server_ip)
service_name = service
is_dockerized = sql.select_service_setting(server_id, service, 'dockerized')
if service == 'apache':
service_name = get_correct_apache_service_name(None, server_id)
if is_dockerized == '1':
container_name = sql.get_setting(f'{service}_container_name')
if service == 'apache':
cmd = [f'docker exec -it {container_name} /usr/local/apache2/bin/httpd -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
else:
cmd = [f'docker exec -it {container_name} /usr/sbin/{service_name} -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
else:
cmd = [f'sudo /usr/sbin/{service_name} -v|head -1|awk -F":" \'{{print $2}}\'']
print(server_mod.ssh_command(server_ip, cmd))

@ -138,18 +138,17 @@ def waf_nginx_install(server_ip: str):
os.remove(script)
def install_nginx(server_ip: str, **kwargs):
script = "install_nginx.sh"
stats_user = sql.get_setting('nginx_stats_user')
stats_password = sql.get_setting('nginx_stats_password')
stats_port = str(sql.get_setting('nginx_stats_port'))
stats_page = sql.get_setting('nginx_stats_page')
config_path = sql.get_setting('nginx_config_path')
nginx_dir = sql.get_setting('nginx_dir')
def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None:
script = f"install_{service}.sh"
stats_user = sql.get_setting(f'{service}_stats_user')
stats_password = sql.get_setting(f'{service}_stats_password')
stats_port = str(sql.get_setting(f'{service}_stats_port'))
stats_page = sql.get_setting(f'{service}_stats_page')
config_path = sql.get_setting(f'{service}_config_path')
service_dir = sql.get_setting(f'{service}_dir')
server_for_installing = kwargs.get('server')
proxy = sql.get_setting('proxy')
docker = kwargs.get('docker')
container_name = sql.get_setting('nginx_container_name')
container_name = sql.get_setting(f'{service}_container_name')
proxy_serv = ''
ssh_settings = return_ssh_keys_path(server_ip)
@ -163,22 +162,27 @@ def install_nginx(server_ip: str, **kwargs):
commands = [
f"chmod +x {script} && ./{script} PROXY={proxy_serv} STATS_USER={stats_user} STATS_PASS='{stats_password}' "
f"SSH_PORT={ssh_settings['port']} CONFIG_PATH={config_path} CONT_NAME={container_name} STAT_PORT={stats_port} "
f"STAT_PAGE={stats_page} SYN_FLOOD={syn_flood_protect} DOCKER={docker} nginx_dir={nginx_dir} HOST={server_ip} "
f"STAT_PAGE={stats_page} SYN_FLOOD={syn_flood_protect} DOCKER={docker} service_dir={service_dir} HOST={server_ip} "
f"USER={ssh_settings['user']} PASS='{ssh_settings['password']}' KEY={ssh_settings['key']}"
]
output, error = server_mod.subprocess_execute(commands[0])
if server_for_installing:
service = server_for_installing + ' Nginx'
service_name = f'{server_for_installing} {service.title()}'
else:
service = ' Nginx'
if show_installation_output(error, output, service):
sql.update_nginx(server_ip)
service_name = service.title
if show_installation_output(error, output, service_name):
if service == 'nginx':
sql.update_nginx(server_ip)
elif service == 'apache':
sql.update_apache(server_ip)
if docker == '1':
server_id = sql.select_server_id_by_ip(server_ip)
sql.insert_or_update_service_setting(server_id, 'nginx', 'dockerized', '1')
sql.insert_or_update_service_setting(server_id, 'nginx', 'restart', '1')
sql.insert_or_update_service_setting(server_id, service, 'dockerized', '1')
sql.insert_or_update_service_setting(server_id, service, 'restart', '1')
os.remove(script)

@ -276,6 +276,11 @@ if act == "overviewServers":
service_common.overview_service(serv, server_id, name, service)
if act == "overviewServices":
import modules.roxywi.overview as roxy_overview
roxy_overview.show_services_overview()
if form.getvalue('action'):
import modules.service.haproxy as service_haproxy
@ -552,8 +557,15 @@ if form.getvalue('git_backup'):
print('Ok')
os.remove(script)
if form.getvalue('install_nginx'):
service_mod.install_nginx(form.getvalue('install_nginx'), docker=form.getvalue('docker'))
if form.getvalue('install_service'):
server_ip = common.is_ip_or_dns(form.getvalue('install_service'))
service = common.checkAjaxInput(form.getvalue('service'))
docker = common.checkAjaxInput(form.getvalue('docker'))
if service in ('nginx', 'apache'):
service_mod.install_service(server_ip, service, docker)
else:
print('warning: wrong service')
if form.getvalue('haproxyaddserv'):
service_mod.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'),
@ -758,16 +770,11 @@ if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'),
if form.getvalue('get_hap_v'):
print(service_common.check_haproxy_version(serv))
if form.getvalue('get_nginx_v'):
server_id = sql.select_server_id_by_ip(serv)
is_dockerized = sql.select_service_setting(server_id, 'nginx', 'dockerized')
if form.getvalue('get_service_v'):
service = common.checkAjaxInput(form.getvalue('get_service_v'))
server_ip = common.is_ip_or_dns(serv)
if is_dockerized == '1':
container_name = sql.get_setting('nginx_container_name')
cmd = [f"docker exec -it {container_name} /usr/sbin/nginx -v 2>&1|awk '{{print $3}}'"]
else:
cmd = ['sudo /usr/sbin/nginx -v']
print(server_mod.ssh_command(serv, cmd))
service_common.show_service_version(server_ip, service)
if form.getvalue('get_keepalived_v'):
cmd = ["sudo /usr/sbin/keepalived -v 2>&1|head -1|awk '{print $2}'"]

@ -3,28 +3,18 @@
import os
import sys
import psutil
from jinja2 import Environment, FileSystemLoader
import modules.db.sql as sql
import modules.roxywi.logs as roxy_logs
import modules.roxywi.auth as roxywi_auth
import modules.roxywi.common as roxywi_common
import modules.server.server as server_mod
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ovw.html')
print('Content-type: text/html\n')
grafana = 0
metrics_worker = 0
checker_worker = 0
is_checker_worker = 0
is_metrics_worker = 0
servers_group = []
host = os.environ.get('HTTP_HOST', '')
user_params = roxywi_common.get_users_params()
try:
@ -35,76 +25,13 @@ except Exception as e:
try:
groups = sql.select_groups()
user_group = roxywi_common.get_user_group(id=1)
if (user_params['role'] == 2 or user_params['role'] == 3) and int(user_group) != 1:
for s in user_params['servers']:
servers_group.append(s[2])
is_checker_worker = len(sql.select_all_alerts(group=user_group))
is_metrics_worker = len(sql.select_servers_metrics_for_master(group=user_group))
for pids in psutil.pids():
if pids < 300:
continue
try:
pid = psutil.Process(pids)
cmdline_out = pid.cmdline()
if len(cmdline_out) > 2:
if 'checker_' in cmdline_out[1]:
if len(servers_group) > 0:
if cmdline_out[2] in servers_group:
checker_worker += 1
else:
checker_worker += 1
elif 'metrics_' in cmdline_out[1]:
if len(servers_group) > 0:
if cmdline_out[2] in servers_group:
metrics_worker += 1
else:
metrics_worker += 1
if len(servers_group) == 0:
if 'grafana' in cmdline_out[1]:
grafana += 1
except psutil.NoSuchProcess:
pass
cmd = "systemctl is-active roxy-wi-metrics"
metrics_master, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-checker"
checker_master, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-keep_alive"
keep_alive, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-smon"
smon, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-portscanner"
port_scanner, stderr = server_mod.subprocess_execute(cmd)
cmd = "systemctl is-active roxy-wi-socket"
socket, stderr = server_mod.subprocess_execute(cmd)
except Exception as e:
groups = ''
roles = ''
metrics_master = ''
checker_master = ''
keep_alive = ''
smon = ''
socket = ''
stderr = ''
print(e)
rendered_template = template.render(
h2=1, autorefresh=1, title="Overview", role=user_params['role'], user=user_params['user'], groups=groups,
roles=sql.select_roles(), metrics_master=''.join(metrics_master), metrics_worker=metrics_worker,
checker_master=''.join(checker_master), checker_worker=checker_worker, keep_alive=''.join(keep_alive),
smon=''.join(smon), port_scanner=''.join(port_scanner), grafana=grafana, socket=''.join(socket),
roxy_wi_log_id=roxy_logs.roxy_wi_log(log_id=1, file="roxy-wi-"),
metrics_log_id=roxy_logs.roxy_wi_log(log_id=1, file="metrics"),
checker_log_id=roxy_logs.roxy_wi_log(log_id=1, file="checker"),
keep_alive_log_id=roxy_logs.roxy_wi_log(log_id=1, file="keep_alive"),
socket_log_id=roxy_logs.roxy_wi_log(log_id=1, file="socket"), error=stderr,
roxy_wi_log=roxy_logs.roxy_wi_log(), servers=user_params['servers'], is_checker_worker=is_checker_worker,
is_metrics_worker=is_metrics_worker, host=host, user_services=user_params['user_services'],
token=user_params['token'], guide_me=1
roles=sql.select_roles(), servers=user_params['servers'], user_services=user_params['user_services'],
roxy_wi_log=roxy_logs.roxy_wi_log(), token=user_params['token'], guide_me=1
)
print(rendered_template)

@ -0,0 +1,50 @@
---
- name: Install common role
hosts: "{{ variable_host }}"
become: yes
become_method: sudo
gather_facts: yes
roles:
- role: service_common
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
tags:
- system
- docker
- name: Install docker
hosts: "{{ variable_host }}"
become: yes
gather_facts: yes
roles:
- role: docker
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
- role: service_docker
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
vars:
image_name: httpd
cont_etc_dir: "/usr/local/apache2"
tags:
- docker
- name: Install system role
hosts: "{{ variable_host }}"
become: yes
become_method: sudo
tasks:
- name: Add syn_flood tasks
include: haproxy/tasks/syn_flood.yml
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)
roles:
- role: apache
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
tags:
- system

@ -5,7 +5,7 @@
become_method: sudo
gather_facts: yes
roles:
- role: nginx_common
- role: service_common
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
@ -23,10 +23,13 @@
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
- role: nginx_docker
- role: service_docker
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
vars:
image_name: nginx
cont_etc_dir: "/etc/nginx"
tags:
- docker
@ -59,5 +62,5 @@
become: yes
tasks:
- name: Set
shell: "chown nginx:nginx -R {{ nginx_dir }}"
shell: "chown nginx:nginx -R {{ service_dir }}"

@ -1,53 +0,0 @@
---
- name: Ensuring nginx directories exist
file:
path: "/etc/nginx"
state: "directory"
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: "0770"
become: true
ignore_errors: yes
- name: Ensuring conf.d directories exist
file:
path: "{{ nginx_dir }}"
state: "directory"
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: "0770"
become: true
ignore_errors: yes
- name: Ensuring sites-enabled directories exist
file:
path: "/etc/nginx/sites-enabled"
state: "directory"
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: "0770"
become: true
ignore_errors: yes
- name: Ensuring log directories exist
file:
path: "/var/log/nginx/"
state: "directory"
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: "0770"
become: true
ignore_errors: yes
- name: Create Nginx
docker_container:
name: "{{ CONT_NAME }}"
image: "nginx"
recreate: yes
network_mode: host
volumes:
- "/etc/nginx/:/etc/nginx/:rw"
- "/tmp:/tmp:ro"
- "/var/log:/var/log:rw"
vars:
ansible_python_interpreter: /usr/bin/python3

@ -1,19 +1,22 @@
---
- name: Include Service-OS-specific variables.
include_vars: "{{ service }}-{{ ansible_os_family }}.yml"
- name: Set SSH port
set_fact:
ansible_port: "{{SSH_PORT}}"
- name: Ensure group "nginx" exists
- name: "Ensure group {{ service_group }} exists"
ansible.builtin.group:
name: nginx
name: "{{ service_group }}"
state: present
- name: Add NGINX User
- name: Add {{ service_group }} User
ansible.builtin.user:
name: nginx
group: nginx
name: "{{ service_user }}"
group: "{{ service_group }}"
- name: check if Nginx is installed
- name: "check if {{ service_group }} is installed"
package_facts:
manager: "auto"
@ -21,21 +24,17 @@
service_facts:
- name: Creates directory
- name: Creates directorys
file:
path: "{{nginx_dir}}"
path: "{{ item.path }}"
state: directory
mode: o=rx
owner: nginx
group: nginx
when: "'nginx' not in ansible_facts.packages"
- name: Creates directory
file:
path: "{{nginx_dir}}/conf.d"
state: directory
when: "'nginx' not in ansible_facts.packages"
owner: "{{ service_user }}"
group: "{{ service_group }}"
with_items:
- { path: "{{ service_dir }}"}
- { path: "{{ service_dir }}/conf.d"}
when: service not in ansible_facts.packages
- name: Set passlib version
@ -63,40 +62,30 @@
name: "{{passlib_ver}}"
state: present
when:
- "'nginx' not in ansible_facts.packages"
- service not in ansible_facts.packages
- ansible_facts['distribution_major_version'] != '9'
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
- name: Copy Nginx configuration in place
template:
src: default.conf.j2
dest: "{{nginx_dir}}/conf.d/default.conf"
mode: 0644
force: no
when: "'nginx' not in ansible_facts.packages"
ignore_errors: yes
- name: Copying over nginx.conf
template:
src: nginx.conf.j2
dest: "{{nginx_dir}}/nginx.conf"
mode: "0666"
force: no
remote_src: true
template: src={{item.src}} dest={{item.dest}} mode="0666" force="no"
with_items:
- { src: 'mime.types.j2', dest: '{{ service_dir }}/mime.types' }
- { src: 'nginx.conf.j2', dest: '{{CONFIG_PATH}}' }
- { src: '{{ service }}_default.conf.j2', dest: '{{ service_dir }}/conf.d/default.conf' }
become: true
ignore_errors: yes
when: service == "nginx"
- name: Copying over mime.types
- name: Copy status page configuration in place
template:
src: mime.types.j2
dest: "{{nginx_dir}}/mime.types"
mode: "0666"
src: "{{ service }}_status.conf.j2"
dest: "{{ service_dir }}/conf.d/status_page.conf"
mode: 0644
force: no
remote_src: true
become: true
when:
- service not in ansible_facts.packages
ignore_errors: yes
- name: Open stat port for firewalld
@ -124,10 +113,9 @@
- htpasswd:
path: "{{nginx_dir}}/status_page_passwdfile"
path: "{{ service_dir }}/status_page_passwdfile"
name: "{{STATS_USER}}"
password: "{{STATS_PASS}}"
when: "'nginx' not in ansible_facts.packages"
- name: test to see if selinux is running

@ -0,0 +1,10 @@
Listen {{ STAT_PORT }}
<VirtualHost *:{{ STAT_PORT }}>
<Location /{{ STAT_PAGE }}>
SetHandler server-status
AuthType basic
AuthName "Apache status"
AuthUserFile {{ service_dir }}/status_page_passwdfile
Require valid-user
</Location>
</VirtualHost>

@ -1,14 +1,3 @@
server {
listen {{STAT_PORT}} ;
server_name localhost;
location /{{STAT_PAGE}} {
stub_status;
auth_basic "Resticted Area";
auth_basic_user_file /etc/nginx/status_page_passwdfile;
}
}
server {
listen 80;
server_name localhost;

@ -0,0 +1,10 @@
server {
listen {{STAT_PORT}} ;
server_name localhost;
location /{{STAT_PAGE}} {
stub_status;
auth_basic "Resticted Area";
auth_basic_user_file /etc/nginx/status_page_passwdfile;
}
}

@ -0,0 +1,3 @@
---
service_user: httpd
service_group: httpd

@ -0,0 +1,3 @@
---
service_user: apache2
service_group: apache2

@ -0,0 +1,3 @@
---
service_user: httpd
service_group: httpd

@ -0,0 +1,3 @@
---
service_user: apache2
service_group: apache2

@ -0,0 +1,3 @@
---
service_user: nginx
service_group: nginx

@ -0,0 +1,3 @@
---
service_user: nginx
service_group: nginx

@ -0,0 +1,3 @@
---
service_user: nginx
service_group: nginx

@ -0,0 +1,3 @@
---
service_user: nginx
service_group: nginx

@ -0,0 +1,28 @@
---
- name: Creates directorys
file:
path: "{{ item.path }}"
state: directory
mode: "0770"
owner: "{{ service_user }}"
group: "{{ service_group }}"
become: true
ignore_errors: yes
with_items:
- { path: "{{ service_dir }}"}
- { path: "{{ service_dir }}/conf.d"}
- { path: "{{ service_dir }}/sites-enabled"}
- { path: "/var/log/{{ service }}/"}
- name: "Create {{ service }}"
docker_container:
name: "{{ CONT_NAME }}"
image: "{{ image_name }}"
recreate: yes
network_mode: host
volumes:
- "/etc/{{ service }}/:{{ cont_etc_dir }}/:rw"
- "/tmp:/tmp:ro"
- "/var/log:/var/log:rw"
vars:
ansible_python_interpreter: /usr/bin/python3

@ -0,0 +1,56 @@
#!/bin/bash
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
case "$KEY" in
PROXY) PROXY=${VALUE} ;;
HOST) HOST=${VALUE} ;;
USER) USER=${VALUE} ;;
PASS) PASS=${VALUE} ;;
KEY) KEY=${VALUE} ;;
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
STAT_PORT) STAT_PORT=${VALUE} ;;
STAT_PAGE) STAT_PAGE=${VALUE} ;;
STATS_USER) STATS_USER=${VALUE} ;;
STATS_PASS) STATS_PASS=${VALUE} ;;
SSH_PORT) SSH_PORT=${VALUE} ;;
CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
DOCKER) DOCKER=${VALUE} ;;
CONT_NAME) CONT_NAME=${VALUE} ;;
service_dir) service_dir=${VALUE} ;;
*)
esac
done
if [[ $DOCKER == '1' ]]; then
tags='docker'
else
tags='system'
fi
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=`pwd`
PWD=$PWD/scripts/ansible/
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
if [[ $KEY == "" ]]; then
ansible-playbook $PWD/roles/apache.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
else
ansible-playbook $PWD/roles/apache.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
fi
if [ $? -gt 0 ]
then
echo "error: Can't install Apache service <br /><br />"
exit 1
else
echo "ok"
fi
rm -f $PWD/$HOST

@ -9,17 +9,17 @@ do
HOST) HOST=${VALUE} ;;
USER) USER=${VALUE} ;;
PASS) PASS=${VALUE} ;;
KEY) KEY=${VALUE} ;;
KEY) KEY=${VALUE} ;;
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
STAT_PORT) STAT_PORT=${VALUE} ;;
STAT_PAGE) STAT_PAGE=${VALUE} ;;
STATS_USER) STATS_USER=${VALUE} ;;
STATS_PASS) STATS_PASS=${VALUE} ;;
SSH_PORT) SSH_PORT=${VALUE} ;;
CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
DOCKER) DOCKER=${VALUE} ;;
STAT_PORT) STAT_PORT=${VALUE} ;;
STAT_PAGE) STAT_PAGE=${VALUE} ;;
STATS_USER) STATS_USER=${VALUE} ;;
STATS_PASS) STATS_PASS=${VALUE} ;;
SSH_PORT) SSH_PORT=${VALUE} ;;
CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
DOCKER) DOCKER=${VALUE} ;;
CONT_NAME) CONT_NAME=${VALUE} ;;
nginx_dir) nginx_dir=${VALUE} ;;
service_dir) service_dir=${VALUE} ;;
*)
esac
done
@ -49,14 +49,14 @@ PWD=$PWD/scripts/ansible/
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
if [[ $KEY == "" ]]; then
ansible-playbook $PWD/roles/nginx.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME nginx_dir=$nginx_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT" -i $PWD/$HOST -t $tags
ansible-playbook $PWD/roles/nginx.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=nginx" -i $PWD/$HOST -t $tags
else
ansible-playbook $PWD/roles/nginx.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME nginx_dir=$nginx_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT" -i $PWD/$HOST -t $tags
ansible-playbook $PWD/roles/nginx.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=nginx" -i $PWD/$HOST -t $tags
fi
if [ $? -gt 0 ]
then
echo "error: Can't install Nginx service <br /><br />"
echo "error: Can't install NGINX service <br /><br />"
exit 1
else
echo "ok"

@ -0,0 +1,201 @@
<tr class="odd">
<td class="padding10 first-collumn-wi">
{% if metrics_master == 'active' %}
<span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View metrics master's logs" class="logs_link">
Metrics master
</a>
{% else %}
Metrics master
{% endif %}
{% else %}
{% if metrics_master == 'inactive' or metrics_master == 'failed' %}
<span class="serverDown server-status" title="Metrics is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Metrics - Roxy-WI service" class="logs_link">
Metrics master
</a>
{% else %}
Metrics master
{% endif %}
{% else %}
<span class="serverNone server-status" title="Metrics is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" target="_blank" class="logs_link">
Metrics master
</a>
{% endif %}
{% endif %}
</td>
<td class="third-collumn-wi">
{% if checker_master == 'active' %}
<span class="serverUp server-status" title="running {{ checker_master }} master processes"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker master's logs" class="logs_link">
Checker master
</a>
{% else %}
Checker master
{% endif %}
{% else %}
{% if checker_master == 'inactive' or checker_master == 'failed' %}
<span class="serverDown server-status" title="Checker is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Checker - Roxy-WI service" class="logs_link">
Checker master
</a>
{% else %}
Checker master
{% endif %}
{% else %}
<span class="serverNone server-status" title="Backends checker is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=checker#installation" title="Backends checker installation" target="_blank" class="logs_link">
Checker master
</a>
{% endif %}
{% endif %}
</td>
<td class="third-collumn-wi">
{% if keep_alive == 'active' %}
<span class="serverUp server-status" title="running {{ keep_alive }} processe"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{keep_alive_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Auto start logs" class="logs_link">
Auto start
</a>
{% else %}
Auto star
{% endif %}
{% else %}
{% if keep_alive == 'inactive' or keep_alive == 'failed' %}
<span class="serverDown server-status" title="Auto start is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Auto star - Roxy-WI service" class="logs_link">
Auto start
</a>
{% else %}
Auto start
{% endif %}
{% else %}
<span class="serverNone server-status" title="Auto start is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=auto_start#installation" title="Auto start installation" target="_blank" class="logs_link">
Auto start
</a>
{% endif %}
{% endif %}
</td>
</tr>
<tr class="even">
<td class="padding10 first-collumn-wi">
{% if metrics_worker|int() >= 1 %}
<span class="serverUp server-status" title="running {{metrics_worker}} worker processes"></span>
{% else %}
{% if is_metrics_worker|int() == 0 %}
<span class="serverNone server-status" title="There is not job for metrics"></span>
{% else %}
<span class="serverDown server-status" title="running {{is_checker_worker}} worker processes"></span>
{% endif %}
{% endif %}
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View worker's logs" class="logs_link">
Metrics workers
</a>
{% else %}
Metrics workers
{% endif %}
</td>
<td>
{% if checker_worker|int() >= 1 %}
<span class="serverUp server-status" title="running {{ checker_worker }} worker processes"></span>
{% else %}
{% if is_checker_worker|int() == 0 %}
<span class="serverNone server-status" title="There is not job for checker"></span>
{% else %}
<span class="serverDown server-status" title="running {{ checker_worker }} worker processes"></span>
{% endif %}
{% endif %}
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker's logs" class="logs_link">
Checker workers
</a>
{% else %}
Checker workers
{% endif %}
</td>
<td>
{% if smon == 'active' %}
<span class="serverUp server-status" title="SMON is started"></span>
<a href="/app/smon.py?action=view" title="SMON Dashboard" class="logs_link">
SMON
</a>
{% else %}
{% if smon == 'inactive' or smon == 'failed' %}
<span class="serverDown server-status" title="SMON is stopped"></span>
<a href="/app/users.py#services" title="Start SMON - Roxy-WI service" class="logs_link">
SMON
</a>
{% else %}
<span title="SMON is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=smon" title="Simple monitoring ports installation" target="_blank" class="logs_link">
SMON
</a>
{% endif %}
{% endif %}
</td>
</tr>
<tr class="odd">
{% if role == 1 %}
<td class="padding10 first-collumn-wi">
{% if grafana|int() >= 1 %}
<span class="serverUp server-status" title="running {{grafana}} process"></span>
<a href="http://{{host}}:3000" target="_blank" title="Open Grafana" class="logs_link" rel="noopener noreferrer">Grafana</a>
{% else %}
<span class="serverNone server-status" title="The service is not installed or not running"></span>
<span>Grafana</span>
{% endif %}
{% endif %}
</td>
<td {% if role != 1 %}class="padding10 first-collumn-wi"{%endif%}>
{% if socket == 'active' %}
<span class="serverUp server-status" title="Socket service is started"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{socket_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Socket's logs" class="logs_link">
Socket service
</a>
{% else %}
Socket service
{% endif %}
{% else %}
{% if socket == 'inactive' or socket == 'failed' %}
<span class="serverDown server-status" title="Socket service scanner is stopped"></span>
<a href="/app/users.py#services" title="Socket service - Roxy-WI service" class="logs_link">
Socket service
</a>
{% else %}
<span title="Socket service is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=socket" title="Socket service" target="_blank" class="logs_link">
Socket service
</a>
{% endif %}
{% endif %}
</td>
<td>
{% if port_scanner == 'active' %}
<span class="serverUp server-status" title="Port scanner is started"></span>
<a href="/app/portscanner.py" title="Port scanner Dashboard" class="logs_link">
Port scanner
</a>
{% else %}
{% if port_scanner == 'inactive' or port_scanner == 'failed' %}
<span class="serverDown server-status" title="Port scanner is stopped"></span>
<a href="/app/users.py#services" title="Start Port scanner - Roxy-WI service" class="logs_link">
Port scanner
</a>
{% else %}
<span title="Port scanner is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=port_scanner" title="Port scanner" target="_blank" class="logs_link">
Port scanner
</a>
{% endif %}
{% endif %}
</td>
</tr>

@ -159,8 +159,8 @@
<li><a href="/app/servers.py#installproxy" title="Servers: Proxy service installation" class="hap-menu installproxy head-submenu">Proxy installation</a> </li>
<li><a href="/app/servers.py#installmon" title="Servers: Monitoring service installation" class="hap1 installmon head-submenu">Monitoring installation</a> </li>
<li><a href="/app/provisioning.py" title="Servers: Provisioning" class="hap1 head-submenu">Server provisioning</a> </li>
<li><a href="/app/viewlogs.py?type=2" title="Servers: View internal logs" class="logs head-submenu">Internal logs</a></li>
<li><a href="/app/servers.py#backup" title="Servers: Backup configs" class="backup head-submenu">Backups</a> </li>
<li><a href="/app/viewlogs.py?type=2" title="Servers: View internal logs" class="logs head-submenu">Internal logs</a></li>
</ul>
</li>
{% endif %}

@ -92,218 +92,25 @@
</tr>
</table>
<table class="overview-wi" id="overview-services">
<tr class="overviewHead">
<td class="padding10 first-collumn-wi" colspan=4>
{% if role <= 1 %}
<a href="/app/users.py#services" title="View services status" class="logs_link">
Roxy-WI services status
</a>
{% else %}
Roxy-WI services status
{% endif %}
</td>
</tr>
<tr class="odd">
<td class="padding10 first-collumn-wi">
{% if metrics_master == 'active' %}
<span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View metrics master's logs" class="logs_link">
Metrics master
</a>
{% else %}
Metrics master
{% endif %}
{% else %}
{% if metrics_master == 'inactive' or metrics_master == 'failed' %}
<span class="serverDown server-status" title="Metrics is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Metrics - Roxy-WI service" class="logs_link">
Metrics master
</a>
{% else %}
Metrics master
{% endif %}
{% else %}
<span class="serverNone server-status" title="Metrics is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" target="_blank" class="logs_link">
Metrics master
</a>
{% endif %}
{% endif %}
</td>
<td class="third-collumn-wi">
{% if checker_master == 'active' %}
<span class="serverUp server-status" title="running {{ checker_master }} master processes"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker master's logs" class="logs_link">
Checker master
</a>
{% else %}
Checker master
{% endif %}
{% else %}
{% if checker_master == 'inactive' or checker_master == 'failed' %}
<span class="serverDown server-status" title="Checker is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Checker - Roxy-WI service" class="logs_link">
Checker master
</a>
{% else %}
Checker master
{% endif %}
{% else %}
<span class="serverNone server-status" title="Backends checker is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=checker#installation" title="Backends checker installation" target="_blank" class="logs_link">
Checker master
</a>
{% endif %}
{% endif %}
</td>
<td class="third-collumn-wi">
{% if keep_alive == 'active' %}
<span class="serverUp server-status" title="running {{ keep_alive }} processe"></span>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{keep_alive_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Auto start logs" class="logs_link">
Auto start
</a>
{% else %}
Auto star
{% endif %}
{% else %}
{% if keep_alive == 'inactive' or keep_alive == 'failed' %}
<span class="serverDown server-status" title="Auto start is stopped"></span>
{% if role <= 1 %}
<a href="/app/users.py#services" title="Start Auto star - Roxy-WI service" class="logs_link">
Auto start
</a>
{% else %}
Auto start
{% endif %}
{% else %}
<span class="serverNone server-status" title="Auto start is not installed"></span>
<a href="https://roxy-wi.org/services.py?service=auto_start#installation" title="Auto start installation" target="_blank" class="logs_link">
Auto start
</a>
{% endif %}
{% endif %}
</td>
</tr>
<tr class="even">
<td class="padding10 first-collumn-wi">
{% if metrics_worker|int() >= 1 %}
<span class="serverUp server-status" title="running {{metrics_worker}} worker processes"></span>
{% else %}
{% if is_metrics_worker|int() == 0 %}
<span class="serverNone server-status" title="There is not job for metrics"></span>
{% else %}
<span class="serverDown server-status" title="running {{is_checker_worker}} worker processes"></span>
{% endif %}
{% endif %}
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View worker's logs" class="logs_link">
Metrics workers
</a>
{% else %}
Metrics workers
{% endif %}
</td>
<td>
{% if checker_worker|int() >= 1 %}
<span class="serverUp server-status" title="running {{ checker_worker }} worker processes"></span>
{% else %}
{% if is_checker_worker|int() == 0 %}
<span class="serverNone server-status" title="There is not job for checker"></span>
{% else %}
<span class="serverDown server-status" title="running {{ checker_worker }} worker processes"></span>
{% endif %}
{% endif %}
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker's logs" class="logs_link">
Checker workers
</a>
{% else %}
Checker workers
{% endif %}
</td>
<td>
{% if smon == 'active' %}
<span class="serverUp server-status" title="SMON is started"></span>
<a href="/app/smon.py?action=view" title="SMON Dashboard" class="logs_link">
SMON
</a>
{% else %}
{% if smon == 'inactive' or smon == 'failed' %}
<span class="serverDown server-status" title="SMON is stopped"></span>
<a href="/app/users.py#services" title="Start SMON - Roxy-WI service" class="logs_link">
SMON
</a>
{% else %}
<span title="SMON is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=smon" title="Simple monitoring ports installation" target="_blank" class="logs_link">
SMON
</a>
{% endif %}
{% endif %}
</td>
</tr>
<tr class="odd">
{% if role == 1 %}
<td class="padding10 first-collumn-wi">
{% if grafana|int() >= 1 %}
<span class="serverUp server-status" title="running {{grafana}} process"></span>
<a href="http://{{host}}:3000" target="_blank" title="Open Grafana" class="logs_link" rel="noopener noreferrer">Grafana</a>
{% else %}
<span class="serverNone server-status" title="The service is not installed or not running"></span>
<span>Grafana</span>
{% endif %}
{% endif %}
</td>
<td {% if role != 1 %}class="padding10 first-collumn-wi"{%endif%}>
{% if socket == 'active' %}
<span class="serverUp server-status" title="Socket service is started"></span>
<thead>
<tr class="overviewHead">
<td class="padding10 first-collumn-wi" colspan=2>
{% if role <= 1 %}
<a href="/app/viewlogs.py?viewlogs={{socket_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Socket's logs" class="logs_link">
Socket service
<a href="/app/users.py#services" title="View services status" class="logs_link">
Roxy-WI services status
</a>
{% else %}
Socket service
{% endif %}
{% else %}
{% if socket == 'inactive' or socket == 'failed' %}
<span class="serverDown server-status" title="Socket service scanner is stopped"></span>
<a href="/app/users.py#services" title="Socket service - Roxy-WI service" class="logs_link">
Socket service
</a>
{% else %}
<span title="Socket service is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=socket" title="Socket service" target="_blank" class="logs_link">
Socket service
</a>
Roxy-WI services status
{% endif %}
{% endif %}
</td>
<td>
{% if port_scanner == 'active' %}
<span class="serverUp server-status" title="Port scanner is started"></span>
<a href="/app/portscanner.py" title="Port scanner Dashboard" class="logs_link">
Port scanner
</td>
<td>
<a onclick="showServicesOverview()" title="Refresh" style="float: right; margin-right: 15px;">
<span class="refresh"></span>
</a>
{% else %}
{% if port_scanner == 'inactive' or port_scanner == 'failed' %}
<span class="serverDown server-status" title="Port scanner is stopped"></span>
<a href="/app/users.py#services" title="Start Port scanner - Roxy-WI service" class="logs_link">
Port scanner
</a>
{% else %}
<span title="Port scanner is not installed"><span class="serverNone server-status"></span></span>
<a href="https://roxy-wi.org/services.py?service=port_scanner" title="Port scanner" target="_blank" class="logs_link">
Port scanner
</a>
{% endif %}
{% endif %}
</td>
</tr>
</td>
</tr>
</thead>
<tbody id="services_ovw"></tbody>
</table>
{% if role <= 2 %}
{% if role == 2 %}

@ -63,7 +63,7 @@
<td></td>
</tr>
<tr>
<td id="cur_hap_ver" class="padding10 first-collumn">
<td id="cur_haproxy_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;">
{% set values = dict() %}
@ -125,6 +125,41 @@
</td>
</tr>
</table>
<table>
<caption><h3>Install Apache</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 20%;">Server</td>
<td class="help_cursor" title="Install Apache service as a Docker container" >Use Docker</td>
<td>SYN-flood protection</td>
<td></td>
</tr>
<tr>
<td id="cur_apache_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;">
Roxy-WI will try to install the latest Apache version from an official Apache repository
</td>
<td class="padding10 first-collumn">
<select autofocus required name="apacheaddserv" id="apacheaddserv">
<option disabled selected>------</option>
{% for select in servers %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td style="padding-left: 25px;">
{{ checkbox('apache_docker', title="Install Apache service as a Docker container") }}
</td>
<td class="syn-flood-protection-field">
{{ checkbox('apache_syn_flood', title="Enable SYN-flood protection", checked='checked') }}
</td>
<td>
<span class="ui-button ui-widget ui-corner-all" id="apache_install" title="Install Apache">Install</span>
</td>
</tr>
</table>
<div id="ajax"></div>
{% endif %}
</div>

@ -65,6 +65,7 @@ function showOverview(serv, hostnamea) {
showOverviewCallBack(serv[i], hostnamea[i])
}
showSubOverview();
showServicesOverview();
}
function showOverviewCallBack(serv, hostnamea) {
$.ajax( {
@ -88,6 +89,28 @@ function showOverviewCallBack(serv, hostnamea) {
}
} );
}
function showServicesOverview() {
$.ajax( {
url: "options.py",
data: {
act: "overviewServices",
token: $('#token').val()
},
beforeSend: function() {
$("#services_ovw").html('<img class="loading_small_bin_bout" style="padding-left: 100%;padding-top: 40px;padding-bottom: 40px;" src="/inc/images/loading.gif" />');
},
type: "POST",
success: function( data ) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
$("#services_ovw").empty();
$("#services_ovw").html(data);
}
}
} );
}
function showOverviewServer(name, ip, id, service) {
$.ajax( {
url: "options.py",

@ -1104,7 +1104,7 @@ $( function() {
$(this).children(".installmon").css('padding-left', '30px');
$(this).children(".installmon").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 6 );
$( "#tabs" ).tabs( "option", "active", 7 );
} );
$( ".backup" ).on( "click", function() {
$('.menu li ul li').each(function () {
@ -1113,7 +1113,7 @@ $( function() {
$(this).children(".backup").css('padding-left', '30px');
$(this).children(".backup").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 7 );
$( "#tabs" ).tabs( "option", "active", 6 );
} );
}
}

@ -47,49 +47,10 @@ $( function() {
} );
});
$('#nginx_install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
var docker = 0;
if ($('#nginx_syn_flood').is(':checked')) {
syn_flood = '1';
}
if ($('#nginx_docker').is(':checked')) {
docker = '1';
}
if ($('#nginxaddserv').val() == '------') {
toastr.warning('Select a server');
return false
}
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
install_nginx: $('#nginxaddserv').val(),
syn_flood: syn_flood,
docker: docker,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
$("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1' || data.indexOf('UNREACHABLE') != '-1') {
toastr.clear();
var p_err = show_pretty_ansible_error(data);
toastr.error(p_err);
} else if (data.indexOf('success') != '-1' ){
toastr.clear();
toastr.success(data);
$("#nginxaddserv").trigger( "selectmenuchange" );
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
} else {
toastr.clear();
toastr.info(data);
}
}
} );
installService('apache');
});
$('#apache_install').click(function() {
installService('apache');
});
$('#grafna_install').click(function() {
$("#ajaxmon").html('');
@ -273,53 +234,13 @@ $( function() {
} );
});
$( "#haproxyaddserv" ).on('selectmenuchange',function() {
$.ajax( {
url: "options.py",
data: {
get_hap_v: 1,
serv: $('#haproxyaddserv option:selected').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
if(data != '') {
data = data+'-1';
$('#cur_hap_ver').text(data);
$('#cur_hap_ver').css('font-weight', 'bold');
$('#install').text('Update');
$('#install').attr('title', 'Update HAProxy');
} else {
$('#cur_hap_ver').text('HAProxy has not installed');
$('#install').text('Install');
$('#install').attr('title', 'Install HAProxy');
}
}
} );
showServiceVersion('haproxy');
});
$( "#nginxaddserv" ).on('selectmenuchange',function() {
$.ajax( {
url: "options.py",
data: {
get_nginx_v: 1,
serv: $('#nginxaddserv option:selected').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
if(data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
$('#cur_nginx_ver').text('Nginx has not installed');
$('#nginx_install').text('Install');
$('#nginx_install').attr('title', 'Install Nginx');
} else {
$('#cur_nginx_ver').text(data);
$('#cur_nginx_ver').css('font-weight', 'bold');
$('#nginx_install').text('Update');
$('#nginx_install').attr('title', 'Update Nginx');
}
}
} );
showServiceVersion('nginx');
});
$( "#apacheaddserv" ).on('selectmenuchange',function() {
showServiceVersion('apache');
});
$( "#haproxy_exp_addserv" ).on('selectmenuchange',function() {
$.ajax( {
@ -2931,3 +2852,74 @@ function checkGeoipInstallation() {
}
} );
}
function installService(service){
$("#ajax").html('')
var syn_flood = 0;
var docker = 0;
if ($('#'+service+'_syn_flood').is(':checked')) {
syn_flood = '1';
}
if ($('#'+service+'_docker').is(':checked')) {
docker = '1';
}
if ($('#'+service+'addserv').val() == '------') {
toastr.warning('Select a server');
return false
}
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
install_service: $('#' + service + 'ddserv').val(),
syn_flood: syn_flood,
docker: docker,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
$("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1' || data.indexOf('UNREACHABLE') != '-1') {
toastr.clear();
var p_err = show_pretty_ansible_error(data);
toastr.error(p_err);
} else if (data.indexOf('success') != '-1' ){
toastr.clear();
toastr.success(data);
$('#'+service+'addserv').trigger( "selectmenuchange" );
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
} else {
toastr.clear();
toastr.info(data);
}
}
} );
}
function showServiceVersion(service) {
$.ajax({
url: "options.py",
data: {
get_service_v: service,
serv: $('#'+service+'addserv option:selected').val(),
token: $('#token').val()
},
type: "POST",
success: function (data) {
data = data.replace(/^\s+|\s+$/g, '');
if (data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
$('#cur_'+service+'_ver').text(service+' has not installed');
$('#'+service+'_install').text('Install');
$('#'+service+'_install').attr('title', 'Install');
} else if (data.indexOf('warning: ') != '-1') {
toastr.warning(data);
} else {
$('#cur_'+service+'_ver').text(data);
$('#cur_'+service+'_ver').css('font-weight', 'bold');
$('#'+service+'_install').text('Update');
$('#'+service+'_install').attr('title', 'Update');
}
}
} );
}

Loading…
Cancel
Save