diff --git a/dodo.py b/dodo.py index d9632f5..40e2d77 100755 --- a/dodo.py +++ b/dodo.py @@ -4,69 +4,99 @@ import yaml from pathlib import Path home_Dir = Path.home() -map_Server = "TheIsland" +#count_Maps = 1 +#map_Server = "TheIsland" dir_Server = f"{home_Dir}/ARK_Servers/" -name_Server = "Dodo server" -port_Server = 7777 -query_Port = 27015 +#name_Server = "Dodo server" +#port_Server = 7777 +#query_Port = 27015 password_Server = "" max_Players = 70 mods_Id = [] listen_Server = True -cluster_Server = False +#cluster_Server = False if not os.path.exists(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/"): os.mkdir(f"{home_Dir}/.config/dodo/") - if not os.path.exists(f"{home_Dir}/.config/dodo/settings.yaml"): - settings_dodo = [ -{ - 'Map' : f"{map_Server}", - 'ServerPath' : f"{dir_Server}", - 'SessionName' : f"{name_Server}", - 'Port' : f"{port_Server}", - 'QueryPort' : f"{query_Port}", - 'ServerPassword' : f"{password_Server}", - 'MaxPlayers' : f"{max_Players}", - 'ModsId' : f"{mods_Id}", - 'Listen' : f"{listen_Server}", - 'Cluster' : f"{cluster_Server}" - } -] - with open(f"{home_Dir}/.config/dodo/settings.yaml", 'w') as yamlfile: - data = yaml.dump(settings_dodo, yamlfile) - 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() + settings_dodo = [ + { + 'Map' : f"{map_Server}", + 'ServerPath' : f"{dir_Server}", + 'SessionName' : f"{name_Server}", + 'Port' : f"{port_Server}", + 'QueryPort' : f"{query_Port}", + 'ServerPassword' : f"{password_Server}", + 'MaxPlayers' : f"{max_Players}", + 'ModsId' : f"{mods_Id}", + 'Listen' : f"{listen_Server}", + 'Cluster' : f"{cluster_Server}" + } + + ] + with open(f"{home_Dir}/.config/dodo/{map_Server}.yaml", 'w') as yamlfile: + data = yaml.dump(settings_dodo, yamlfile) + print("Конфиг создан") def yaml_edit(): - print("""Используем стандартные настройки?(Карта TheIsland) - В противном случае придётся произвести настройки - 1. Стандартные настройки - 2. Настроить""") - count_Settings = input(":\n") - if count_Settings == "2": - print("""Укажите требуется ли кластер? - 1. Да - 2. Нет""") - count_Cluster = input(":\n") - if count_Cluster == "1": - cluster_Server = True - else: - cluster_Server = False + count_Maps = 1 + print("""Укажите требуется ли кластер? + 1. Да + 2. Нет""") + 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("Укажите название Сервера") name_Server = input("") @@ -75,71 +105,36 @@ def yaml_edit(): 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 - while True: - count_maps = input("Укажите количество карт:\n") - if count_maps.isdigit: - break - print("Введите цифры") - - for i in range(int(count_maps)): - 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""") - 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 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(): - + read_yaml(map_Server) if not os.path.isdir(dir_Server + map_Server): os.mkdir(dir_Server + map_Server) else: os.system(f"steamcmd +force_install_dir {dir_Server + map_Server} +login anonymous +app_update 376030 +quit") -def start(): - os.chdir(dir_Server + map_Server + "/" + "ShooterGame/Binaries/Linux/") - 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}") -yaml_create() -yaml_edit() +# def start(): +# os.chdir(dir_Server + map_Server + "/" + "ShooterGame/Binaries/Linux/") +# # 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}") +map_Server, query_Port, port_Server, name_Server, cluster_Server = yaml_edit() install() -start() \ No newline at end of file +#start() + # with open(f"{home_Dir}/.config/dodo/settings.yaml", "r") as yamlfile: + # data = yaml.load(yamlfile, Loader=yaml.FullLoader) + # print("Конфиг прочитан") \ No newline at end of file diff --git a/settings.yaml b/settings.yaml deleted file mode 100644 index d56141c..0000000 --- a/settings.yaml +++ /dev/null @@ -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