from lib import config as config_module from lib import init_server from lib import xfs from lib import utils from clore_hosting import main as clore_hosting import asyncio, os from lib import logging as logging_lib config = config_module.config log = logging_lib.log auth = utils.get_auth() if config.init_token: if auth=='': init_token = str(config.init_token) if len(init_token)==48: asyncio.run(init_server.init(init_token)) else: print("\x1b[31mInvalid token\x1b[0m") else: print("\x1b[31mServer has already set up login credentials\x1b[0m") elif config.reset: if auth=='': print("\x1b[31mCan't reset not logged in client\x1b[0m") else: res = utils.yes_no_question("\x1b[31mDo you really want to reset client?\x1b[0m\nIf you reset, authorization key will be dumped and you will never be able to login as the old server") if res: os.remove(config.auth_file) utils.run_command_v2("systemctl restart clore-hosting.service") log.success("Client login reseted") elif config.service: if len(auth)==32+48+1: utils.run_command("sysctl -w net.ipv4.ip_forward=1") xfs_state = xfs.init() if os.path.isfile("/opt/clore-hosting/.run_hive_driver_update"): utils.run_command("systemctl stop docker && PATH=/hive/bin:/hive/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./ nvidia-driver-update http://45.12.132.34/NVIDIA-Linux-x86_64-550.135.run --force") utils.run_command("systemctl restart docker") os.remove("/opt/clore-hosting/.run_hive_driver_update") try: os.remove(config.update_driver_550_flag) except Exception as e: pass if os.path.isfile(config.restart_docker_flag_file): utils.run_command("systemctl restart docker") os.remove(config.restart_docker_flag_file) clore_client = clore_hosting.CloreClient(auth_key=auth, xfs_state=xfs_state) asyncio.run(clore_client.service()) else: print("TODO: Firstly config auth") else: print("Clore client help\n--init-token (Initialize server)\n--reset (Remove current login)")