добавлена начальная работа с конфигом
This commit is contained in:
parent
24e08b6f22
commit
dde1e2d472
127
dodo.py
127
dodo.py
@ -4,24 +4,24 @@ import yaml
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
home_Dir = Path.home()
|
home_Dir = Path.home()
|
||||||
map_Server = "TheIsland"
|
#count_Maps = 1
|
||||||
|
#map_Server = "TheIsland"
|
||||||
dir_Server = f"{home_Dir}/ARK_Servers/"
|
dir_Server = f"{home_Dir}/ARK_Servers/"
|
||||||
name_Server = "Dodo server"
|
#name_Server = "Dodo server"
|
||||||
port_Server = 7777
|
#port_Server = 7777
|
||||||
query_Port = 27015
|
#query_Port = 27015
|
||||||
password_Server = ""
|
password_Server = ""
|
||||||
max_Players = 70
|
max_Players = 70
|
||||||
mods_Id = []
|
mods_Id = []
|
||||||
listen_Server = True
|
listen_Server = True
|
||||||
cluster_Server = False
|
#cluster_Server = False
|
||||||
|
|
||||||
if not os.path.exists(dir_Server):
|
if not os.path.exists(dir_Server):
|
||||||
os.mkdir(dir_Server)
|
os.mkdir(dir_Server)
|
||||||
|
|
||||||
def yaml_create():
|
def yaml_create(map_Server, query_Port, port_Server, name_Server, cluster_Server):
|
||||||
if not os.path.exists(f"{home_Dir}/.config/dodo/"):
|
if not os.path.exists(f"{home_Dir}/.config/dodo/"):
|
||||||
os.mkdir(f"{home_Dir}/.config/dodo/")
|
os.mkdir(f"{home_Dir}/.config/dodo/")
|
||||||
if not os.path.exists(f"{home_Dir}/.config/dodo/settings.yaml"):
|
|
||||||
settings_dodo = [
|
settings_dodo = [
|
||||||
{
|
{
|
||||||
'Map' : f"{map_Server}",
|
'Map' : f"{map_Server}",
|
||||||
@ -35,29 +35,14 @@ def yaml_create():
|
|||||||
'Listen' : f"{listen_Server}",
|
'Listen' : f"{listen_Server}",
|
||||||
'Cluster' : f"{cluster_Server}"
|
'Cluster' : f"{cluster_Server}"
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
with open(f"{home_Dir}/.config/dodo/settings.yaml", 'w') as yamlfile:
|
with open(f"{home_Dir}/.config/dodo/{map_Server}.yaml", 'w') as yamlfile:
|
||||||
data = yaml.dump(settings_dodo, yamlfile)
|
data = yaml.dump(settings_dodo, yamlfile)
|
||||||
print("Конфиг создан")
|
print("Конфиг создан")
|
||||||
#
|
|
||||||
# if not os.path.exists("settings.yaml"):
|
|
||||||
# example = open("/usr/share/dodo/settings.yaml", "r")
|
|
||||||
# f = example.read()
|
|
||||||
# else:
|
|
||||||
# example = open("settings.yaml")
|
|
||||||
# f = example.read()
|
|
||||||
# config = open(f"{home_Dir}/.config/dodo/settings.yaml", "w+")
|
|
||||||
# config.write(f)
|
|
||||||
# example.close()
|
|
||||||
# config.close()
|
|
||||||
|
|
||||||
def yaml_edit():
|
def yaml_edit():
|
||||||
print("""Используем стандартные настройки?(Карта TheIsland)
|
count_Maps = 1
|
||||||
В противном случае придётся произвести настройки
|
|
||||||
1. Стандартные настройки
|
|
||||||
2. Настроить""")
|
|
||||||
count_Settings = input(":\n")
|
|
||||||
if count_Settings == "2":
|
|
||||||
print("""Укажите требуется ли кластер?
|
print("""Укажите требуется ли кластер?
|
||||||
1. Да
|
1. Да
|
||||||
2. Нет""")
|
2. Нет""")
|
||||||
@ -67,22 +52,12 @@ def yaml_edit():
|
|||||||
else:
|
else:
|
||||||
cluster_Server = False
|
cluster_Server = False
|
||||||
|
|
||||||
print("Укажите название Сервера")
|
while cluster_Server == True:
|
||||||
name_Server = input("")
|
count_Maps = input("Укажите количество карт:\n")
|
||||||
|
if count_Maps.isdigit:
|
||||||
print("Укажите порт Сервера <7777>")
|
|
||||||
port_Server = input("")
|
|
||||||
|
|
||||||
print("Укажите Query-порт Сервера <27015>")
|
|
||||||
query_Port = input("")
|
|
||||||
|
|
||||||
while True:
|
|
||||||
count_maps = input("Укажите количество карт:\n")
|
|
||||||
if count_maps.isdigit:
|
|
||||||
break
|
break
|
||||||
print("Введите цифры")
|
print("Введите цифры")
|
||||||
|
for i in range(1, int(count_Maps) + 1):
|
||||||
for i in range(int(count_maps)):
|
|
||||||
print("""Выберите карту из списка указав номер
|
print("""Выберите карту из списка указав номер
|
||||||
1. The Island
|
1. The Island
|
||||||
2. The Center
|
2. The Center
|
||||||
@ -96,50 +71,70 @@ def yaml_edit():
|
|||||||
10. Genesis: Part 2
|
10. Genesis: Part 2
|
||||||
11. Lost Island
|
11. Lost Island
|
||||||
12. Fjordur""")
|
12. Fjordur""")
|
||||||
while True:
|
amount_map = input("")
|
||||||
count_map = input("")
|
if amount_map == "1":
|
||||||
if count_maps.isdigit:
|
|
||||||
break
|
|
||||||
if count_map == "1":
|
|
||||||
map_Server = "TheIsland"
|
map_Server = "TheIsland"
|
||||||
elif count_map == "2":
|
elif amount_map == "2":
|
||||||
map_Server = "TheCenter"
|
map_Server = "TheCenter"
|
||||||
elif count_map == "3":
|
elif amount_map == "3":
|
||||||
map_Server = "ScorchedEarth_P"
|
map_Server = "ScorchedEarth_P"
|
||||||
elif count_map == "4":
|
elif amount_map == "4":
|
||||||
map_Server = "Ragnarok"
|
map_Server = "Ragnarok"
|
||||||
elif count_map == "5":
|
elif amount_map == "5":
|
||||||
map_Server = "Aberration_P"
|
map_Server = "Aberration_P"
|
||||||
elif count_map == "6":
|
elif amount_map == "6":
|
||||||
map_Server = "Extinction"
|
map_Server = "Extinction"
|
||||||
elif count_map == "7":
|
elif amount_map == "7":
|
||||||
map_Server = "Valguero_P"
|
map_Server = "Valguero_P"
|
||||||
elif count_map == "8":
|
elif amount_map == "8":
|
||||||
map_Server = "Genesis"
|
map_Server = "Genesis"
|
||||||
elif count_map == "9":
|
elif amount_map == "9":
|
||||||
map_Server = "CrystalIsles"
|
map_Server = "CrystalIsles"
|
||||||
elif count_map == "10":
|
elif amount_map == "10":
|
||||||
map_Server = "Gen2"
|
map_Server = "Gen2"
|
||||||
elif count_map == "11":
|
elif amount_map == "11":
|
||||||
map_Server = "LostIsland"
|
map_Server = "LostIsland"
|
||||||
elif count_map == "12":
|
elif amount_map == "12":
|
||||||
map_Server = "Fjordur"
|
map_Server = "Fjordur"
|
||||||
print("Введите цифры")
|
print("Введите цифры")
|
||||||
# with open(f"{home_Dir}/.config/dodo/settings.yaml", "w+") as f:
|
print("Укажите название Сервера")
|
||||||
# config_Data = yaml.safe_load(f)
|
name_Server = input("")
|
||||||
# config_Data["map_Server"] = [map_Server]
|
|
||||||
|
|
||||||
|
print("Укажите порт Сервера <7777>")
|
||||||
|
port_Server = input("")
|
||||||
|
|
||||||
|
print("Укажите Query-порт Сервера <27015>")
|
||||||
|
query_Port = input("")
|
||||||
|
yaml_create(map_Server, query_Port, port_Server, name_Server, cluster_Server)
|
||||||
|
return map_Server, query_Port, port_Server, name_Server, cluster_Server
|
||||||
|
|
||||||
|
def read_yaml(map_Server):
|
||||||
|
with open(f"{home_Dir}/.config/dodo/{map_Server}.yaml", "r") as yamlfile:
|
||||||
|
data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||||
|
map_Server = 'data.Map'
|
||||||
|
dir_Server = 'data.ServerPath'
|
||||||
|
name_Server = 'data.SessionName'
|
||||||
|
port_Server = 'data.Port'
|
||||||
|
query_Port = 'data.QueryPort'
|
||||||
|
password_Server = 'data.ServerPassword'
|
||||||
|
max_Players = 'data.MaxPlayers'
|
||||||
|
mods_Id = 'data.ModsId'
|
||||||
|
listen_Server = 'data.Listen'
|
||||||
|
cluster_Server = 'data.Cluster'
|
||||||
|
return map_Server, dir_Server, password_Server, max_Players, mods_Id, listen_Server, query_Port, port_Server, name_Server, cluster_Server
|
||||||
def install():
|
def install():
|
||||||
|
read_yaml(map_Server)
|
||||||
if not os.path.isdir(dir_Server + map_Server):
|
if not os.path.isdir(dir_Server + map_Server):
|
||||||
os.mkdir(dir_Server + map_Server)
|
os.mkdir(dir_Server + map_Server)
|
||||||
else:
|
else:
|
||||||
os.system(f"steamcmd +force_install_dir {dir_Server + map_Server} +login anonymous +app_update 376030 +quit")
|
os.system(f"steamcmd +force_install_dir {dir_Server + map_Server} +login anonymous +app_update 376030 +quit")
|
||||||
def start():
|
# def start():
|
||||||
os.chdir(dir_Server + map_Server + "/" + "ShooterGame/Binaries/Linux/")
|
# os.chdir(dir_Server + map_Server + "/" + "ShooterGame/Binaries/Linux/")
|
||||||
if cluster_Server == False:
|
# # if cluster_Server == False:
|
||||||
os.system(f"./ShooterGameServer {map_Server}?SessionName={name_Server}?Port={port_Server}?QueryPort={query_Port}?MaxPlayers={max_Players}?GameModIds={mods_Id}?listen={listen_Server}")
|
# os.system(f"./ShooterGameServer {map_Server}?SessionName={name_Server}?Port={port_Server}?QueryPort={query_Port}?MaxPlayers={max_Players}?GameModIds={mods_Id}?listen={listen_Server}")
|
||||||
yaml_create()
|
map_Server, query_Port, port_Server, name_Server, cluster_Server = yaml_edit()
|
||||||
yaml_edit()
|
|
||||||
install()
|
install()
|
||||||
start()
|
#start()
|
||||||
|
# with open(f"{home_Dir}/.config/dodo/settings.yaml", "r") as yamlfile:
|
||||||
|
# data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||||
|
# print("Конфиг прочитан")
|
@ -1,10 +0,0 @@
|
|||||||
- Cluster: 'False'
|
|
||||||
Listen: 'True'
|
|
||||||
Map: TheIsland
|
|
||||||
MaxPlayers: '70'
|
|
||||||
ModsId: '[]'
|
|
||||||
Port: '7777'
|
|
||||||
QueryPort: '27015'
|
|
||||||
ServerPassword: ''
|
|
||||||
ServerPath: /home/xpamych/ARK_Servers/
|
|
||||||
SessionName: Dodo server
|
|
Loading…
Reference in New Issue
Block a user