Skip to content

Commit

Permalink
bugfix if the files are in the wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
igroman787 committed Aug 10, 2023
1 parent c3f3119 commit 2c68e2f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
21 changes: 20 additions & 1 deletion mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,29 @@ def Update(args):
def Upgrade(args):
repo = "ton"
author, repo, branch = check_git(args, repo, "upgrade")


# bugfix if the files are in the wrong place
liteClient = ton.GetSettings("liteClient")
configPath = liteClient.get("configPath")
pubkeyPath = liteClient.get("liteServer").get("pubkeyPath")
if "ton-lite-client-test1" in configPath:
liteClient["configPath"] = configPath.replace("lite-client/ton-lite-client-test1.config.json", "global.config.json")
if "/usr/bin/ton" in pubkeyPath:
liteClient["liteServer"]["pubkeyPath"] = "/var/ton-work/keys/liteserver.pub"
ton.SetSettings("liteClient", liteClient)
validatorConsole = ton.GetSettings("validatorConsole")
privKeyPath = validatorConsole.get("privKeyPath")
pubKeyPath = validatorConsole.get("pubKeyPath")
if "/usr/bin/ton" in privKeyPath:
validatorConsole["privKeyPath"] = "/var/ton-work/keys/client"
if "/usr/bin/ton" in pubKeyPath:
validatorConsole["pubKeyPath"] = "/var/ton-work/keys/server.pub"
ton.SetSettings("validatorConsole", validatorConsole)

# Run script
runArgs = ["bash", "/usr/src/mytonctrl/scripts/upgrade.sh", "-a", author, "-r", repo, "-b", branch]
exitCode = run_as_root(runArgs)
exitCode += run_as_root(["python3", "/usr/src/mytonctrl/scripts/upgrade.py"])
if exitCode == 0:
text = "Upgrade - {green}OK{endc}"
else:
Expand Down
2 changes: 1 addition & 1 deletion mytoninstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,5 +1049,5 @@ def b642dict(b64):
General()
else:
console.Run()
local.Exit()
local.exit()
#end if
7 changes: 3 additions & 4 deletions scripts/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from mypylib.mypylib import *


# validator.service
file = open("/etc/systemd/system/validator.service", 'rt')
text = file.read()
file.close()
Expand All @@ -17,10 +18,8 @@
line = lines[i]
if "ExecStart" not in line:
continue
if " --threads " in line or " -t " in line:
continue
cpus = psutil.cpu_count() - 1
lines[i] += " --threads {cpus}".format(cpus=cpus)
if "ton-global.config.json" in line:
lines[i] += line.replace("validator-engine/ton-global.config.json", "global.config.json")
#end for

text = "\n".join(lines)
Expand Down
13 changes: 13 additions & 0 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ ENDC='\033[0m'
# Установить дополнительные зависимости
apt-get install -y libsecp256k1-dev libsodium-dev ninja-build

# bugfix if the files are in the wrong place
wget "https://ton-blockchain.github.io/global.config.json" -O global.config.json
if [ -f "/var/ton-work/keys/liteserver.pub" ]; then
echo "Ok"
else
echo "bugfix"
mkdir /var/ton-work/keys
cp /usr/bin/ton/validator-engine-console/client /var/ton-work/keys/client
cp /usr/bin/ton/validator-engine-console/client.pub /var/ton-work/keys/client.pub
cp /usr/bin/ton/validator-engine-console/server.pub /var/ton-work/keys/server.pub
cp /usr/bin/ton/validator-engine-console/liteserver.pub /var/ton-work/keys/liteserver.pub
fi

# Go to work dir
cd ${srcdir}
rm -rf ${srcdir}/${repo}
Expand Down

0 comments on commit 2c68e2f

Please sign in to comment.