77import json
88import subprocess
99
10- from mypylib .mypylib import MyPyClass , run_as_root
10+ from mypylib .mypylib import MyPyClass , run_as_root , color_print
1111from mypyconsole .mypyconsole import MyPyConsole
1212
13- from mytoninstaller .config import GetLiteServerConfig
13+ from mytoninstaller .config import GetLiteServerConfig , get_ls_proxy_config
1414from mytoninstaller .utils import GetInitBlock
1515from mytoncore .utils import dict2b64 , str2bool , b642dict
1616
1717from mytoninstaller .settings import (
18- FirstNodeSettings ,
19- FirstMytoncoreSettings ,
20- EnableValidatorConsole ,
21- EnableLiteServer ,
22- EnableDhtServer ,
23- EnableJsonRpc ,
24- EnablePytonv3 ,
18+ FirstNodeSettings ,
19+ FirstMytoncoreSettings ,
20+ EnableValidatorConsole ,
21+ EnableLiteServer ,
22+ EnableDhtServer ,
23+ EnableJsonRpc ,
2524 EnableTonHttpApi ,
26- DangerousRecoveryValidatorConfigFile ,
27- CreateSymlinks ,
25+ DangerousRecoveryValidatorConfigFile ,
26+ CreateSymlinks ,
27+ enable_ls_proxy
2828)
2929from mytoninstaller .config import (
30- CreateLocalConfig ,
31- BackupVconfig ,
32- BackupMconfig ,
30+ CreateLocalConfig ,
31+ BackupVconfig ,
32+ BackupMconfig ,
3333)
3434
3535from functools import partial
@@ -62,10 +62,12 @@ def inject_globals(func):
6262 console .name = "MyTonInstaller"
6363 console .color = console .RED
6464 console .AddItem ("status" , inject_globals (Status ), "Print TON component status" )
65- console .AddItem ("enable" , inject_globals (Enable ), "Enable some function: 'FN' - Full node, 'VC' - Validator console, 'LS' - Liteserver, 'DS' - DHT-Server, 'JR' - jsonrpc, 'PT' - ton-http-api. Example: 'enable FN' " )
65+ console .AddItem ("enable" , inject_globals (Enable ), "Enable some function" )
6666 console .AddItem ("update" , inject_globals (Enable ), "Update some function: 'JR' - jsonrpc. Example: 'update JR'" )
67- console .AddItem ("plsc" , inject_globals (PrintLiteServerConfig ), "Print LiteServer config" )
68- console .AddItem ("clcf" , inject_globals (CreateLocalConfigFile ), "CreateLocalConfigFile" )
67+ console .AddItem ("plsc" , inject_globals (PrintLiteServerConfig ), "Print lite-server config" )
68+ console .AddItem ("clcf" , inject_globals (CreateLocalConfigFile ), "Create lite-server config file" )
69+ console .AddItem ("print_ls_proxy_config" , inject_globals (print_ls_proxy_config ), "Print ls-proxy config" )
70+ console .AddItem ("create_ls_proxy_config_file" , inject_globals (create_ls_proxy_config_file ), "Create ls-proxy config file" )
6971 console .AddItem ("drvcf" , inject_globals (DRVCF ), "Dangerous recovery validator config file" )
7072 console .AddItem ("setwebpass" , inject_globals (SetWebPassword ), "Set a password for the web admin interface" )
7173
@@ -123,10 +125,22 @@ def Status(local, args):
123125
124126
125127def Enable (local , args ):
126- name = args [0 ]
127- if name == "PT" :
128+ try :
129+ name = args [0 ]
130+ except :
131+ color_print ("{red}Bad args. Usage:{endc} enable <mode-name>" )
132+ print ("'FN' - Full node" )
133+ print ("'VC' - Validator console" )
134+ print ("'LS' - Lite-Server" )
135+ print ("'DS' - DHT-Server" )
136+ print ("'JR' - jsonrpc" )
137+ print ("'THA' - ton-http-api" )
138+ print ("'LSP' - ls-proxy" )
139+ print ("Example: 'enable FN'" )
140+ return
141+ if name == "THA" :
128142 CreateLocalConfigFile (local , args )
129- args = ["python3" , "-m" , "mytoninstaller" , "-u" , local .buffer .user , "-e" , "enable{name}" . format ( name = name ) ]
143+ args = ["python3" , "-m" , "mytoninstaller" , "-u" , local .buffer .user , "-e" , f "enable{ name } " ]
130144 run_as_root (args )
131145#end define
132146
@@ -159,6 +173,15 @@ def CreateLocalConfigFile(local, args):
159173 run_as_root (args )
160174#end define
161175
176+ def print_ls_proxy_config (local , args ):
177+ ls_proxy_config = get_ls_proxy_config (local )
178+ text = json .dumps (ls_proxy_config , indent = 4 )
179+ print (text )
180+ #end define
181+
182+ def create_ls_proxy_config_file (local , args ):
183+ print ("TODO" )
184+ #end define
162185
163186def Event (local , name ):
164187 if name == "enableFN" :
@@ -173,9 +196,10 @@ def Event(local, name):
173196 DangerousRecoveryValidatorConfigFile (local )
174197 if name == "enableJR" :
175198 EnableJsonRpc (local )
176- if name == "enablePT" :
177- # EnablePytonv3(local)
199+ if name == "enableTHA" :
178200 EnableTonHttpApi (local )
201+ if name == "enableLSP" :
202+ enable_ls_proxy (local )
179203 if name == "clc" :
180204 ix = sys .argv .index ("-i" )
181205 initBlock_b64 = sys .argv [ix + 1 ]
@@ -219,12 +243,12 @@ def General(local):
219243### Start of the program
220244###
221245def mytoninstaller ():
222- local = MyPyClass (__file__ )
223- console = MyPyConsole ()
224-
225- Init (local , console )
226- if len (sys .argv ) > 1 :
227- General (local )
228- else :
229- console .Run ()
230- local .exit ()
246+ local = MyPyClass (__file__ )
247+ console = MyPyConsole ()
248+
249+ Init (local , console )
250+ if len (sys .argv ) > 1 :
251+ General (local )
252+ else :
253+ console .Run ()
254+ local .exit ()
0 commit comments