#!/usr/bin/env python3 import os import yaml from pathlib import Path home_Dir = Path.home() map_Server = "TheIsland" dir_Server = f"{home_Dir}/ARK_Servers/" name_Server = "Dodo server" port_Server = 7777 query_Port = 27015 password_Server = "" max_Players = 70 mods_Id = [] listen_Server = True cluster_Server = False if not os.path.exists(dir_Server): os.mkdir(dir_Server) def yaml_create(): 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() 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 print("Укажите название Сервера") name_Server = input("") print("Укажите порт Сервера <7777>") port_Server = input("") print("Укажите Query-порт Сервера <27015>") query_Port = input("") 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 install(): 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() install() start()