From 24e08b6f22f1481174d1d575d7eef0a9d69dd2e2 Mon Sep 17 00:00:00 2001 From: xpamych Date: Sun, 5 Feb 2023 15:21:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=20=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=B1=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D0=BB=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- config.yaml | 10 --- dodo.py | 222 +++++++++++++++++++++++++++----------------------- settings.yaml | 10 +++ 4 files changed, 135 insertions(+), 111 deletions(-) delete mode 100644 config.yaml mode change 100644 => 100755 dodo.py create mode 100644 settings.yaml diff --git a/.gitignore b/.gitignore index ed8ebf5..78dfa72 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -__pycache__ \ No newline at end of file +__pycache__ +# Ignore dynaconf secret files +.secrets.* diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 85a01d7..0000000 --- a/config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -map_server: TheIsland -dir_server: "~/ARK_Servers/" -session_name: Dodo server -Port: 7777 -QueryPort: 27015 -ServerPassword: -MaxPlayers: 70 -ModsId: -listen: True -Cluster: False \ No newline at end of file diff --git a/dodo.py b/dodo.py old mode 100644 new mode 100755 index 77bd593..d9632f5 --- a/dodo.py +++ b/dodo.py @@ -2,122 +2,144 @@ import os import yaml from pathlib import Path -home_Dir = Path.home() -map_server = "TheIsland" -dir_server = "~/ARK_Servers/" -#session_name = "Dodo server" -#Port = 7777 -#QueryPort = 27015 -#ServerPassword = "" -#MaxPlayers = 70 -#ModsId = [] -#listen = True -#Cluster = False -#if not os.path.exists("~/.config/dodo/config.yaml"): - #os.system("") +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("config.yaml"): - example = open("/usr/share/dodo/config.yaml", "r") - f = example.read() - else: - example = open("config.yaml") - f = example.read() - config = open(f"{home_Dir}/.config/dodo/config.yaml", "w+") - config.write(f) - example.close() - config.close() - - - -#if not os.path.exists(dir_server): -# os.mkdir(dir_server) + 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("""Укажите требуется ли кластер? - 1. Да - 2. Нет""") - count_cluster = input(":\n") - if count_cluster == "1": - Cluster = True - else: - Cluster = False + 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("Укажите название Сервера") - session_name = input("") + print("Укажите название Сервера") + name_Server = input("") - print("Укажите порт Сервера <7777>") - Port = input("") + print("Укажите порт Сервера <7777>") + port_Server = input("") - print("Укажите Query-порт Сервера <27015>") - QueryPort = 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("") + count_maps = input("Укажите количество карт:\n") 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("/usr/share/dodo/config.yaml", "rw+") as f: - config_Data = yaml.safe_load(f) - config_Data[""] -def install(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") -#os.chdir(dir_server + map_server + "/" + "ShooterGame/Binaries/Linux/") + + 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(): - if Cluster == False: - os.system(f"./ShooterGameServer {map_server}?SessionName={session_name}?Port={Port}?QueryPort={QueryPort}?MaxPlayers={MaxPlayers}?GameModIds={ModsId}?listen={listen}") - #os.system("ShooterGameServer") + 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(map_server) +install() start() \ No newline at end of file diff --git a/settings.yaml b/settings.yaml new file mode 100644 index 0000000..d56141c --- /dev/null +++ b/settings.yaml @@ -0,0 +1,10 @@ +- Cluster: 'False' + Listen: 'True' + Map: TheIsland + MaxPlayers: '70' + ModsId: '[]' + Port: '7777' + QueryPort: '27015' + ServerPassword: '' + ServerPath: /home/xpamych/ARK_Servers/ + SessionName: Dodo server