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
29 changes: 20 additions & 9 deletions mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def Init(argv):

def PreUp():
CheckMytonctrlUpdate()
CheckDiskUsage()
check_vport()
# CheckTonUpdate()
#end define
Expand Down Expand Up @@ -140,34 +141,34 @@ def check_git(input_args, default_repo, text):
git_path = f"{src_dir}/{default_repo}"
default_author = "ton-blockchain"
default_branch = "master"

# Get author, repo, branch
local_author, local_repo = get_git_author_and_repo(git_path)
local_branch = get_git_branch(git_path)

# Set author, repo, branch
data = GetAuthorRepoBranchFromArgs(input_args)
need_author = data.get("author")
need_repo = data.get("repo")
need_branch = data.get("branch")

# Check if remote repo is different from default
if ((need_author is None and local_author != default_author) or
if ((need_author is None and local_author != default_author) or
(need_repo is None and local_repo != default_repo)):
remote_url = f"https://github.com/{local_author}/{local_repo}/tree/{need_branch if need_branch else local_branch}"
raise Exception(f"{text} error: You are on {remote_url} remote url, to {text} to the tip use `{text} {remote_url}` command")
elif need_branch is None and local_branch != default_branch:
raise Exception(f"{text} error: You are on {local_branch} branch, to {text} to the tip of {local_branch} branch use `{text} {local_branch}` command")
#end if

if need_author is None:
need_author = local_author
if need_repo is None:
need_repo = local_repo
if need_branch is None:
need_branch = local_branch
#end if

return need_author, need_repo, need_branch
#end define

Expand Down Expand Up @@ -209,7 +210,7 @@ def Update(args):
def Upgrade(args):
repo = "ton"
author, repo, branch = check_git(args, repo, "upgrade")

# Run script
runArgs = ["bash", "/usr/src/mytonctrl/scripts/upgrade.sh", "-a", author, "-r", repo, "-b", branch]
exitCode = run_as_root(runArgs)
Expand All @@ -227,6 +228,16 @@ def CheckMytonctrlUpdate():
color_print(local.translate("mytonctrl_update_available"))
#end define


def CheckDiskUsage():
usage = ton.GetDbUsage()
if usage > 90:
print('============================================================================================')
color_print(local.translate("disk_usage_warning"))
print('============================================================================================')
#end define


def CheckTonUpdate():
git_path = "/usr/src/ton"
result = check_git_update(git_path)
Expand Down Expand Up @@ -405,7 +416,7 @@ def PrintLocalStatus(adnlAddr, validatorIndex, validatorEfficiency, validatorWal
dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb")
dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%")
dbStatus_text = local.translate("local_status_db").format(dbSize_text, dbUsage_text)

# Mytonctrl and validator git hash
mtcGitPath = "/usr/src/mytonctrl"
validatorGitPath = "/usr/src/ton"
Expand All @@ -430,7 +441,7 @@ def PrintLocalStatus(adnlAddr, validatorIndex, validatorEfficiency, validatorWal
print(cpuLoad_text)
print(netLoad_text)
print(memoryLoad_text)

print(disksLoad_text)
print(mytoncoreStatus_text)
print(validatorStatus_text)
Expand Down
5 changes: 5 additions & 0 deletions translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@
"ru": "{green}Доступно обновление MyTonCtrl. {red}Пожалуйста, обновите его с помощью команды `update`.{endc}",
"zh_TW": "{green}MyTonCtrl 有可用更新. {red}請使用 `update` 命令進行更新.{endc}"
},
"disk_usage_warning": {
"en": "{red} Disk is almost full, clean the TON database immediately: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
"ru": "{red} Диск почти заполнен, немедленно очистите базу данных TON: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
"zh_TW": "{red} 磁盤幾乎滿了,立即清理 TON 數據庫: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}"
},
"ton_update_available": {
"en": "{green}TON update available. {red}Please update it with `upgrade` command.{endc}",
"ru": "{green}Доступно обновление TON. {red}Пожалуйста, обновите его с помощью команды `upgrade`.{endc}",
Expand Down