Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mytoninstaller/mytoninstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ def PrintLiteServerConfig(local, args):
def CreateLocalConfigFile(local, args):
initBlock = GetInitBlock()
initBlock_b64 = dict2b64(initBlock)
args = ["python3", "-m", "mytoninstaller", "-u", local.buffer.user, "-e", "clc", "-i", initBlock_b64]
user = local.buffer.user or os.environ.get("USER", "root")
args = ["python3", "-m", "mytoninstaller", "-u", user, "-e", "clc", "-i", initBlock_b64]
run_as_root(args)
#end define

Expand Down
25 changes: 22 additions & 3 deletions mytoninstaller/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,36 @@ def EnableJsonRpc(local):
color_print(text)
#end define

def tha_exists():
try:
resp = requests.get('http://127.0.0.1:8801/healthcheck', timeout=3)
except:
return False
if resp.status_code == 200 and resp.text == '"OK"':
return True
return False
#end define

def enable_ton_http_api(local):
local.add_log("start EnableTonHttpApi function", "debug")
try:
if not tha_exists():
do_enable_ton_http_api(local)
except Exception as e:
local.add_log(f"Error in enable_ton_http_api: {e}", "warning")
pass
#end define

def do_enable_ton_http_api(local):
local.add_log("start do_enable_ton_http_api function", "debug")
if not os.path.exists('/usr/bin/ton/local.config.json'):
from mytoninstaller.mytoninstaller import CreateLocalConfigFile
CreateLocalConfigFile(local, [])
ton_http_api_installer_path = pkg_resources.resource_filename('mytoninstaller.scripts', 'ton_http_api_installer.sh')
exit_code = run_as_root(["bash", ton_http_api_installer_path])
if exit_code == 0:
text = "EnableTonHttpApi - {green}OK{endc}"
text = "do_enable_ton_http_api - {green}OK{endc}"
else:
text = "EnableTonHttpApi - {red}Error{endc}"
text = "do_enable_ton_http_api - {red}Error{endc}"
color_print(text)
#end define

Expand Down