2024-03-21 01:28:02 +00:00
from lib import config as config_module
from lib import init_server
2024-12-02 00:06:53 +00:00
from lib import xfs
2024-03-21 01:28:02 +00:00
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 \n If 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 :
2024-12-02 00:06:53 +00:00
utils . run_command ( " sysctl -w net.ipv4.ip_forward=1 " )
xfs_state = xfs . init ( )
2024-12-10 23:48:01 +00:00
if os . path . isfile ( " /opt/clore-hosting/.run_hive_driver_update " ) :
2024-12-10 23:54:59 +00:00
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 " )
2024-12-10 23:48:01 +00:00
utils . run_command ( " systemctl restart docker " )
os . remove ( " /opt/clore-hosting/.run_hive_driver_update " )
2024-12-11 08:59:14 +00:00
try :
os . remove ( config . update_driver_550_flag )
except Exception as e :
pass
2024-12-02 00:06:53 +00:00
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 )
2024-03-21 01:28:02 +00:00
asyncio . run ( clore_client . service ( ) )
else :
print ( " TODO: Firstly config auth " )
else :
print ( " Clore client help \n --init-token <token> (Initialize server) \n --reset (Remove current login) " )