ops: add channel inventory and metinctl
This commit is contained in:
21
install.py
21
install.py
@@ -4,7 +4,7 @@ sys.dont_write_bytecode = True
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import channels
|
||||
import channel_inventory
|
||||
|
||||
GAMEDIR = os.getcwd()
|
||||
|
||||
@@ -14,19 +14,17 @@ def write_lines_to_files(path, lines):
|
||||
f.write(line)
|
||||
f.write("\n")
|
||||
|
||||
def generate_auth_config(path, port, p2p_port):
|
||||
def generate_auth_config(path, channel_id, port, p2p_port):
|
||||
file_content = [
|
||||
"HOSTNAME: auth",
|
||||
"CHANNEL: 1",
|
||||
f"CHANNEL: {channel_id}",
|
||||
f"PORT: {port}",
|
||||
f"P2P_PORT: {p2p_port}",
|
||||
"AUTH_SERVER: master",
|
||||
]
|
||||
write_lines_to_files(os.path.join(path, "CONFIG"), file_content)
|
||||
|
||||
def generate_game_config(path, channel, core, map_allow):
|
||||
port = 11000 + (channel * 10 + core)
|
||||
p2p_port = 12000 + (channel * 10 + core)
|
||||
def generate_game_config(path, channel, core, map_allow, port, p2p_port):
|
||||
file_content = [
|
||||
f"HOSTNAME: channel{channel}_{core}",
|
||||
f"CHANNEL: {channel}",
|
||||
@@ -106,17 +104,20 @@ print_green("> Setting up environment for AUTH...")
|
||||
auth_dir = os.path.join(GAMEDIR, "channels", "auth")
|
||||
os.makedirs(auth_dir)
|
||||
setup_links_game(auth_dir, "game_auth")
|
||||
generate_auth_config(auth_dir, 11000, 12000)
|
||||
auth_config = channel_inventory.get_auth()
|
||||
generate_auth_config(auth_dir, auth_config["channel"], auth_config["port"], auth_config["p2p_port"])
|
||||
|
||||
## Game Channel Setup
|
||||
|
||||
for channel_id, cores in channels.CHANNEL_MAP.items():
|
||||
for channel in channel_inventory.iter_channels():
|
||||
channel_id = int(channel["id"])
|
||||
print_green(f"> Setting up environment for CH{channel_id}...")
|
||||
for core_id, maps in cores.items():
|
||||
for core in sorted(channel["cores"], key=lambda item: int(item["id"])):
|
||||
core_id = int(core["id"])
|
||||
core_dir = os.path.join(GAMEDIR, "channels", f"channel{channel_id}", f"core{core_id}")
|
||||
os.makedirs(core_dir)
|
||||
setup_links_game(core_dir, f"channel{channel_id}_core{core_id}")
|
||||
generate_game_config(core_dir, channel_id, core_id, maps)
|
||||
generate_game_config(core_dir, channel_id, core_id, core["map_allow"], core["port"], core["p2p_port"])
|
||||
|
||||
print_green("> We are all done!")
|
||||
os.chdir(GAMEDIR)
|
||||
|
||||
Reference in New Issue
Block a user