def install_nginx(serv): import sql script = "install_nginx.sh" stats_user = sql.get_setting('nginx_stats_user') stats_password = sql.get_setting('nginx_stats_password') stats_port = sql.get_setting('nginx_stats_port') stats_page = sql.get_setting('nginx_stats_page') config_path = sql.get_setting('nginx_config_path') proxy = sql.get_setting('proxy') ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path( serv) if ssh_enable == 0: ssh_key_name = '' os.system("cp scripts/%s ." % script) if proxy is not None and proxy != '' and proxy != 'None': proxy_serv = proxy else: proxy_serv = '' servers = sql.select_servers(server=serv) for server in servers: ssh_port = str(server[10]) syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else '' commands = [ "chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " STATS_USER="******" STATS_PASS="******" SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path + " STAT_PORT=" + stats_port + " STAT_PAGE=" + stats_page + " SYN_FLOOD=" + syn_flood_protect + " HOST=" + serv + " USER="******" PASS="******" KEY=" + ssh_key_name ] output, error = subprocess_execute(commands[0]) if error: logging('localhost', error, haproxywi=1) print('error: ' + error) else: for l in output: if "msg" in l or "FAILED" in l: try: l = l.split(':')[1] l = l.split('"')[1] print(l + "<br>") break except Exception: print(output) break else: print('success: Nginx was installed<br>') os.system("rm -f %s" % script) sql.update_nginx(serv)
def install_nginx(serv, **kwargs): import sql script = "install_nginx.sh" stats_user = sql.get_setting('nginx_stats_user') stats_password = sql.get_setting('nginx_stats_password') stats_port = sql.get_setting('nginx_stats_port') stats_page = sql.get_setting('nginx_stats_page') config_path = sql.get_setting('nginx_config_path') server_for_installing = kwargs.get('server') proxy = sql.get_setting('proxy') ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path( serv) if ssh_enable == 0: ssh_key_name = '' os.system("cp scripts/%s ." % script) if proxy is not None and proxy != '' and proxy != 'None': proxy_serv = proxy else: proxy_serv = '' servers = sql.select_servers(server=serv) for server in servers: ssh_port = str(server[10]) syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else '' commands = [ "chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " STATS_USER="******" STATS_PASS="******" SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path + " STAT_PORT=" + stats_port + " STAT_PAGE=" + stats_page + " SYN_FLOOD=" + syn_flood_protect + " HOST=" + serv + " USER="******" PASS="******" KEY=" + ssh_key_name ] output, error = subprocess_execute(commands[0]) if server_for_installing: service = server_for_installing + ' Nginx' else: service = ' Nginx' show_installation_output(error, output, service) os.system("rm -f %s" % script) sql.update_nginx(serv)