меняли name_server(пока не победили)
This commit is contained in:
parent
f6da023004
commit
09edcffd1f
52
hlna.py
52
hlna.py
@ -155,7 +155,7 @@ def print_line(*text, flag="", sep=" ", end="\n"):
|
|||||||
color = colorama.Fore.CYAN
|
color = colorama.Fore.CYAN
|
||||||
else:
|
else:
|
||||||
color = colorama.Fore.WHITE
|
color = colorama.Fore.WHITE
|
||||||
len_text = str(*text)
|
len_text = str(text)
|
||||||
len_text = len_text.split("\n")
|
len_text = len_text.split("\n")
|
||||||
max_length = max(len(string) for string in len_text) + 2
|
max_length = max(len(string) for string in len_text) + 2
|
||||||
print(color + "." * max_length)
|
print(color + "." * max_length)
|
||||||
@ -386,12 +386,12 @@ def config_maps(i):
|
|||||||
return map_s, port_s, query_p, rcon_p
|
return map_s, port_s, query_p, rcon_p
|
||||||
|
|
||||||
|
|
||||||
def config_nameserver(map_s, flag=True):
|
def config_nameserver(map_s):
|
||||||
while True:
|
while True:
|
||||||
if flag:
|
name_exist_server = choose_map(g="ark", m=map_s)[-1] # вызывается когда не нужен, затем когда доходит до создания юнита в config_ark туда приходит не то имя, которое ожидалось
|
||||||
name_server = input("Укажите название Сервера: \n")
|
name_server = input("Укажите название Сервера: \n")
|
||||||
else:
|
if name_exist_server != name_server:
|
||||||
name_server = map_s
|
os.system(f"mv {dir_unit}ark_{name_exist_server}.service {dir_unit}ark_{name_server}.service")
|
||||||
if name_server == "":
|
if name_server == "":
|
||||||
if map_s in list_config:
|
if map_s in list_config:
|
||||||
count = 1
|
count = 1
|
||||||
@ -399,28 +399,34 @@ def config_nameserver(map_s, flag=True):
|
|||||||
while new_name in list_config:
|
while new_name in list_config:
|
||||||
new_name = f"{map_s}{str(count)}"
|
new_name = f"{map_s}{str(count)}"
|
||||||
count += 1
|
count += 1
|
||||||
list_config.append(new_name)
|
name_server = new_name
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
list_config.append(map_s)
|
name_server = map_s
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if name_server in list_allconfigs:
|
if name_server in list_config:
|
||||||
choose_reconf = input("""Сервер существует. Перенастроить? (по умолчанию) нет
|
choose_reconf = input("""Сервер существует. (по умолчанию - отмена)
|
||||||
1. Да
|
1. Переименовать
|
||||||
2. Нет
|
2. Изменить настройки
|
||||||
|
3. Отмена
|
||||||
:""")
|
:""")
|
||||||
if choose_reconf == "":
|
if choose_reconf == "" or choose_reconf == "3":
|
||||||
return
|
exit()
|
||||||
elif choose_reconf == "1":
|
elif choose_reconf == "1":
|
||||||
print_line("Введите новое имя сервера", flag="YELLOW")
|
continue
|
||||||
flag = True
|
elif choose_reconf == "2":
|
||||||
|
config_ark(flag=True)
|
||||||
else:
|
else:
|
||||||
return
|
print_line("Выберите ВОЗМОЖНОЕ действие")
|
||||||
else:
|
else:
|
||||||
list_config.append(name_server) # если enter, то ставим последним элементом карту
|
|
||||||
break
|
break
|
||||||
return list_config
|
return name_server
|
||||||
|
|
||||||
|
|
||||||
|
def reconf_yaml():
|
||||||
|
name_server = input("Укажите название Сервера: \n")
|
||||||
|
return name_server
|
||||||
|
|
||||||
|
|
||||||
def config_ports(port_s):
|
def config_ports(port_s):
|
||||||
@ -473,7 +479,7 @@ def config_listen():
|
|||||||
return listen_server
|
return listen_server
|
||||||
|
|
||||||
|
|
||||||
def config_ark(list_config=list_config):
|
def config_ark(list_config=list_config, flag=False):
|
||||||
"""конфигурирование сервера арк"""
|
"""конфигурирование сервера арк"""
|
||||||
create_dir(dir_server_ark)
|
create_dir(dir_server_ark)
|
||||||
create_dir(dir_maps_ark)
|
create_dir(dir_maps_ark)
|
||||||
@ -489,6 +495,9 @@ def config_ark(list_config=list_config):
|
|||||||
count_maps = config_nummap()
|
count_maps = config_nummap()
|
||||||
for i in range(count_maps):
|
for i in range(count_maps):
|
||||||
map_s, port_s, query_p, rcon_p = config_maps(i)
|
map_s, port_s, query_p, rcon_p = config_maps(i)
|
||||||
|
if flag:
|
||||||
|
list_config = [reconf_yaml()]
|
||||||
|
else:
|
||||||
list_config = config_nameserver(map_s)
|
list_config = config_nameserver(map_s)
|
||||||
port_server = config_ports(port_s)
|
port_server = config_ports(port_s)
|
||||||
query_port = config_query(query_p)
|
query_port = config_query(query_p)
|
||||||
@ -845,10 +854,12 @@ def switch(g, m, e): # добавить all
|
|||||||
if e:
|
if e:
|
||||||
port_s, query_p, rcon_p = ports_array()
|
port_s, query_p, rcon_p = ports_array()
|
||||||
state_msg = "активных" if e else "не активных"
|
state_msg = "активных" if e else "не активных"
|
||||||
for i in m:
|
name_server = choose_map(g, m)
|
||||||
|
for i in name_server:
|
||||||
try:
|
try:
|
||||||
data = read_yaml(g="ark", m=i, flag=not e)
|
data = read_yaml(g="ark", m=i, flag=not e)
|
||||||
if e: # добавить проверку занятости имени
|
if e: # добавить проверку занятости имени
|
||||||
|
if i in list_config:
|
||||||
data['SessionName'] = config_nameserver(i, flag=False)[-1]
|
data['SessionName'] = config_nameserver(i, flag=False)[-1]
|
||||||
data['Port'] = ports(data['Port'], port_s, e)
|
data['Port'] = ports(data['Port'], port_s, e)
|
||||||
data['QueryPort'] = ports(data['QueryPort'], port_s, e)
|
data['QueryPort'] = ports(data['QueryPort'], port_s, e)
|
||||||
@ -878,6 +889,7 @@ def switch(g, m, e): # добавить all
|
|||||||
print_line("ошибка операции", flag="RED")
|
print_line("ошибка операции", flag="RED")
|
||||||
|
|
||||||
|
|
||||||
|
# Добавить возможность вывода информации по запрошенной игре + карте (серверу), а так же по всем.
|
||||||
@hlna.command(help='Выводит статус настроеных серверов')
|
@hlna.command(help='Выводит статус настроеных серверов')
|
||||||
def status(list_config=list_config):
|
def status(list_config=list_config):
|
||||||
ext_ip = get_external_ip()
|
ext_ip = get_external_ip()
|
||||||
|
Loading…
Reference in New Issue
Block a user