Skip to content

Commit 5adb779

Browse files
authored
Merge pull request #30 from sova-network/extend-master
add support for custom TON node git URL
2 parents 3816eb2 + f69cd20 commit 5adb779

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

mytonctrl/mytonctrl.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,15 @@ def Upgrade(local, ton, args: list):
345345
branch = args[args.index('--btc-teleport') + 1]
346346
upgrade_btc_teleport(local, ton, reinstall=True, branch=branch, user=user)
347347
return
348-
repo = "ton"
349-
author, repo, branch = check_git(args, repo, "upgrade")
348+
349+
git_url = None
350+
351+
if '--url' in args and '--branch' in args:
352+
git_url = args[args.index('--url') + 1]
353+
branch = args[args.index('--branch') + 1]
354+
else:
355+
repo = "ton"
356+
author, repo, branch = check_git(args, repo, "upgrade")
350357

351358
# bugfix if the files are in the wrong place
352359
liteClient = ton.GetSettings("liteClient")
@@ -376,7 +383,11 @@ def Upgrade(local, ton, args: list):
376383

377384
# Run script
378385
upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh')
379-
runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch]
386+
if git_url:
387+
runArgs = ["bash", upgrade_script_path, "-g", git_url, "-b", branch]
388+
else:
389+
runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch]
390+
380391
exitCode = run_as_root(runArgs)
381392
if ton.using_validator():
382393
upgrade_btc_teleport(local, ton)

mytonctrl/scripts/upgrade.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,30 @@ bindir="/usr/bin/"
1616
tmpdir="/tmp/ton_src/"
1717

1818
# Get arguments
19-
while getopts a:r:b: flag
19+
while getopts a:r:b:g: flag
2020
do
2121
case "${flag}" in
2222
a) author=${OPTARG};;
2323
r) repo=${OPTARG};;
2424
b) branch=${OPTARG};;
25+
g) git_url=${OPTARG};;
2526
esac
2627
done
2728

29+
remote_url="https://github.com/${author}/${repo}.git"
30+
if [ -n "$git_url" ]; then
31+
if [[ "$git_url" == *"#"* ]]; then
32+
remote_url="${git_url%%#*}"
33+
ref_from_url="${git_url##*#}"
34+
35+
if [ "$branch" = "master" ]; then
36+
branch="$ref_from_url"
37+
fi
38+
else
39+
remote_url="$git_url"
40+
fi
41+
fi
42+
2843
# Цвета
2944
COLOR='\033[92m'
3045
ENDC='\033[0m'
@@ -63,8 +78,8 @@ fi
6378
rm -rf ${tmpdir}/${repo}
6479
mkdir -p ${tmpdir}/${repo}
6580
cd ${tmpdir}/${repo}
66-
echo "https://github.com/${author}/${repo}.git -> ${branch}"
67-
git clone --recursive https://github.com/${author}/${repo}.git . || exit 1
81+
echo "${remote_url} -> ${branch}"
82+
git clone --recursive ${remote_url} . || exit 1
6883

6984
# Go to work dir
7085
cd ${srcdir}/${repo}

scripts/install.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repo="mytonctrl"
1717
branch="master"
1818
network="mainnet"
1919
ton_node_version="master" # Default version
20-
20+
ton_node_git_url="https://github.com/ton-blockchain/ton.git"
2121

2222
show_help_and_exit() {
2323
echo 'Supported arguments:'
@@ -28,6 +28,7 @@ show_help_and_exit() {
2828
echo ' -a Set MyTonCtrl git repo author'
2929
echo ' -r Set MyTonCtrl git repo'
3030
echo ' -b Set MyTonCtrl git repo branch'
31+
echo ' -g URL TON node git repo URL (default: https://github.com/ton-blockchain/ton.git)'
3132
echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
3233
echo ' -n NETWORK Specify the network (mainnet or testnet)'
3334
echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
@@ -55,14 +56,15 @@ mode=none
5556
cpu_required=16
5657
mem_required=64000000 # 64GB in KB
5758

58-
while getopts ":c:tidola:r:b:m:n:v:u:p:h" flag; do
59+
while getopts ":c:tidola:r:b:m:n:v:u:p:g:h" flag; do
5960
case "${flag}" in
60-
c) config=${OPTARG};;
61+
c) config=${OPTARG}; config_overridden=true;;
6162
t) telemetry=false;;
6263
i) ignore=true;;
6364
d) dump=true;;
6465
a) author=${OPTARG};;
6566
r) repo=${OPTARG};;
67+
g) ton_node_git_url=${OPTARG};;
6668
b) branch=${OPTARG};;
6769
m) mode=${OPTARG};;
6870
n) network=${OPTARG};;
@@ -100,7 +102,10 @@ fi
100102

101103
# Set config based on network argument
102104
if [ "${network}" = "testnet" ]; then
103-
config="https://ton-blockchain.github.io/testnet-global.config.json"
105+
if [ "${config_overridden}" = false ]; then
106+
config="https://ton-blockchain.github.io/testnet-global.config.json"
107+
fi
108+
104109
cpu_required=8
105110
mem_required=16000000 # 16GB in KB
106111
fi
@@ -144,7 +149,7 @@ file3=${BIN_DIR}/ton/validator-engine-console/validator-engine-console
144149
if [ ! -f "${file1}" ] || [ ! -f "${file2}" ] || [ ! -f "${file3}" ]; then
145150
echo "TON does not exists, building"
146151
wget https://raw.githubusercontent.com/${author}/${repo}/${branch}/scripts/ton_installer.sh -O /tmp/ton_installer.sh
147-
bash /tmp/ton_installer.sh -c ${config} -v ${ton_node_version}
152+
bash /tmp/ton_installer.sh -c ${config} -g ${ton_node_git_url} -v ${ton_node_version}
148153
fi
149154

150155
# Cloning mytonctrl

scripts/ton_installer.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ if [ "$(id -u)" != "0" ]; then
88
exit 1
99
fi
1010

11-
while getopts ":c:v:h" flag; do
11+
repo_git_url="https://github.com/ton-blockchain/ton.git"
12+
13+
while getopts ":c:v:g:h" flag; do
1214
case "${flag}" in
15+
g) repo_git_url=${OPTARG};;
1316
c) config=${OPTARG};;
1417
v) ton_node_version=${OPTARG};;
1518
h) show_help_and_exit;;
@@ -108,7 +111,7 @@ make build_libs -j$(nproc)
108111
echo -e "${COLOR}[3/6]${ENDC} Preparing for compilation"
109112
cd $SOURCES_DIR
110113
rm -rf $SOURCES_DIR/ton
111-
git clone --recursive https://github.com/ton-blockchain/ton.git
114+
git clone --recursive $repo_git_url $SOURCES_DIR/ton
112115

113116
echo "checkout to ${ton_node_version}"
114117

0 commit comments

Comments
 (0)