добавлена начальная работа с конфигом
This commit is contained in:
parent
24e08b6f22
commit
dde1e2d472
215
dodo.py
215
dodo.py
@ -4,69 +4,99 @@ 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}",
|
'ServerPath' : f"{dir_Server}",
|
||||||
'ServerPath' : f"{dir_Server}",
|
'SessionName' : f"{name_Server}",
|
||||||
'SessionName' : f"{name_Server}",
|
'Port' : f"{port_Server}",
|
||||||
'Port' : f"{port_Server}",
|
'QueryPort' : f"{query_Port}",
|
||||||
'QueryPort' : f"{query_Port}",
|
'ServerPassword' : f"{password_Server}",
|
||||||
'ServerPassword' : f"{password_Server}",
|
'MaxPlayers' : f"{max_Players}",
|
||||||
'MaxPlayers' : f"{max_Players}",
|
'ModsId' : f"{mods_Id}",
|
||||||
'ModsId' : f"{mods_Id}",
|
'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
|
||||||
В противном случае придётся произвести настройки
|
print("""Укажите требуется ли кластер?
|
||||||
1. Стандартные настройки
|
1. Да
|
||||||
2. Настроить""")
|
2. Нет""")
|
||||||
count_Settings = input(":\n")
|
count_Cluster = input(":\n")
|
||||||
if count_Settings == "2":
|
if count_Cluster == "1":
|
||||||
print("""Укажите требуется ли кластер?
|
cluster_Server = True
|
||||||
1. Да
|
else:
|
||||||
2. Нет""")
|
cluster_Server = False
|
||||||
count_Cluster = input(":\n")
|
|
||||||
if count_Cluster == "1":
|
|
||||||
cluster_Server = True
|
|
||||||
else:
|
|
||||||
cluster_Server = False
|
|
||||||
|
|
||||||
|
while cluster_Server == True:
|
||||||
|
count_Maps = input("Укажите количество карт:\n")
|
||||||
|
if count_Maps.isdigit:
|
||||||
|
break
|
||||||
|
print("Введите цифры")
|
||||||
|
for i in range(1, int(count_Maps) + 1):
|
||||||
|
print("""Выберите карту из списка указав номер
|
||||||
|
1. The Island
|
||||||
|
2. The Center
|
||||||
|
3. Scorched Earth
|
||||||
|
4. Ragnarok
|
||||||
|
5. Aberration
|
||||||
|
6. Extinction
|
||||||
|
7. Valguero
|
||||||
|
8. Genesis: Part 1
|
||||||
|
9. Crystal Isles
|
||||||
|
10. Genesis: Part 2
|
||||||
|
11. Lost Island
|
||||||
|
12. Fjordur""")
|
||||||
|
amount_map = input("")
|
||||||
|
if amount_map == "1":
|
||||||
|
map_Server = "TheIsland"
|
||||||
|
elif amount_map == "2":
|
||||||
|
map_Server = "TheCenter"
|
||||||
|
elif amount_map == "3":
|
||||||
|
map_Server = "ScorchedEarth_P"
|
||||||
|
elif amount_map == "4":
|
||||||
|
map_Server = "Ragnarok"
|
||||||
|
elif amount_map == "5":
|
||||||
|
map_Server = "Aberration_P"
|
||||||
|
elif amount_map == "6":
|
||||||
|
map_Server = "Extinction"
|
||||||
|
elif amount_map == "7":
|
||||||
|
map_Server = "Valguero_P"
|
||||||
|
elif amount_map == "8":
|
||||||
|
map_Server = "Genesis"
|
||||||
|
elif amount_map == "9":
|
||||||
|
map_Server = "CrystalIsles"
|
||||||
|
elif amount_map == "10":
|
||||||
|
map_Server = "Gen2"
|
||||||
|
elif amount_map == "11":
|
||||||
|
map_Server = "LostIsland"
|
||||||
|
elif amount_map == "12":
|
||||||
|
map_Server = "Fjordur"
|
||||||
|
print("Введите цифры")
|
||||||
print("Укажите название Сервера")
|
print("Укажите название Сервера")
|
||||||
name_Server = input("")
|
name_Server = input("")
|
||||||
|
|
||||||
@ -75,71 +105,36 @@ def yaml_edit():
|
|||||||
|
|
||||||
print("Укажите Query-порт Сервера <27015>")
|
print("Укажите Query-порт Сервера <27015>")
|
||||||
query_Port = input("")
|
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
|
||||||
|
|
||||||
while True:
|
def read_yaml(map_Server):
|
||||||
count_maps = input("Укажите количество карт:\n")
|
with open(f"{home_Dir}/.config/dodo/{map_Server}.yaml", "r") as yamlfile:
|
||||||
if count_maps.isdigit:
|
data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||||
break
|
map_Server = 'data.Map'
|
||||||
print("Введите цифры")
|
dir_Server = 'data.ServerPath'
|
||||||
|
name_Server = 'data.SessionName'
|
||||||
for i in range(int(count_maps)):
|
port_Server = 'data.Port'
|
||||||
print("""Выберите карту из списка указав номер
|
query_Port = 'data.QueryPort'
|
||||||
1. The Island
|
password_Server = 'data.ServerPassword'
|
||||||
2. The Center
|
max_Players = 'data.MaxPlayers'
|
||||||
3. Scorched Earth
|
mods_Id = 'data.ModsId'
|
||||||
4. Ragnarok
|
listen_Server = 'data.Listen'
|
||||||
5. Aberration
|
cluster_Server = 'data.Cluster'
|
||||||
6. Extinction
|
return map_Server, dir_Server, password_Server, max_Players, mods_Id, listen_Server, query_Port, port_Server, name_Server, cluster_Server
|
||||||
7. Valguero
|
|
||||||
8. Genesis: Part 1
|
|
||||||
9. Crystal Isles
|
|
||||||
10. Genesis: Part 2
|
|
||||||
11. Lost Island
|
|
||||||
12. Fjordur""")
|
|
||||||
while True:
|
|
||||||
count_map = input("")
|
|
||||||
if count_maps.isdigit:
|
|
||||||
break
|
|
||||||
if count_map == "1":
|
|
||||||
map_Server = "TheIsland"
|
|
||||||
elif count_map == "2":
|
|
||||||
map_Server = "TheCenter"
|
|
||||||
elif count_map == "3":
|
|
||||||
map_Server = "ScorchedEarth_P"
|
|
||||||
elif count_map == "4":
|
|
||||||
map_Server = "Ragnarok"
|
|
||||||
elif count_map == "5":
|
|
||||||
map_Server = "Aberration_P"
|
|
||||||
elif count_map == "6":
|
|
||||||
map_Server = "Extinction"
|
|
||||||
elif count_map == "7":
|
|
||||||
map_Server = "Valguero_P"
|
|
||||||
elif count_map == "8":
|
|
||||||
map_Server = "Genesis"
|
|
||||||
elif count_map == "9":
|
|
||||||
map_Server = "CrystalIsles"
|
|
||||||
elif count_map == "10":
|
|
||||||
map_Server = "Gen2"
|
|
||||||
elif count_map == "11":
|
|
||||||
map_Server = "LostIsland"
|
|
||||||
elif count_map == "12":
|
|
||||||
map_Server = "Fjordur"
|
|
||||||
print("Введите цифры")
|
|
||||||
# with open(f"{home_Dir}/.config/dodo/settings.yaml", "w+") as f:
|
|
||||||
# config_Data = yaml.safe_load(f)
|
|
||||||
# config_Data["map_Server"] = [map_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