Skip to content

Commit 6088012

Browse files
committed
add branch option to btc teleport upgrading
1 parent 06e3720 commit 6088012

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

modules/btc_teleport.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,20 @@ def add_daemon(self):
5555
user = os.environ.get("USER", "root")
5656
run_as_root(['bash', script_path, '-n', 'btc_teleport', '-u', user, '-g', user, '-s', start, '-w', self.bin_dir])
5757

58-
def install(self):
58+
def install(self, branch):
5959
script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport1.sh')
60-
exit_code = run_as_root(["bash", script_path, "-s", '/usr/src', "-r", self.repo_name])
60+
exit_code = run_as_root(["bash", script_path, "-s", '/usr/src', "-r", self.repo_name, "-b", branch])
6161
if exit_code != 0:
6262
raise Exception('Failed to install btc_teleport')
6363
script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport2.sh')
6464
subprocess.run(["bash", script_path, "-s", self.src_dir])
6565

66-
def init(self, reinstall=False):
66+
def init(self, reinstall=False, branch: str = 'master'):
6767
if os.path.exists(self.src_dir) and not reinstall:
6868
return
6969
self.local.add_log('Installing btc_teleport', 'info')
7070
os.makedirs(self.keystore_path, mode=0o700, exist_ok=True)
71-
self.install()
71+
self.install(branch)
7272
self.create_env_file()
7373
self.add_daemon()
7474
self.local.add_log('Installed btc_teleport', 'info')

mytonctrl/mytonctrl.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,10 @@ def Update(local, args):
348348
local.exit()
349349
#end define
350350

351-
def Upgrade(local, ton, args):
352-
if '--btc-teleport' in args: # upgrade --btc-teleport
353-
upgrade_btc_teleport(local, ton, reinstall=True)
351+
def Upgrade(local, ton, args: list):
352+
if '--btc-teleport' in args: # upgrade --btc-teleport [branch]
353+
branch = args[args.index('--btc-teleport') + 1] if len(args) > args.index('--btc-teleport') + 1 else 'master'
354+
upgrade_btc_teleport(local, ton, reinstall=True, branch=branch)
354355
return
355356
repo = "ton"
356357
author, repo, branch = check_git(args, repo, "upgrade")
@@ -386,10 +387,10 @@ def Upgrade(local, ton, args):
386387
color_print(text)
387388
#end define
388389

389-
def upgrade_btc_teleport(local, ton, reinstall=False):
390+
def upgrade_btc_teleport(local, ton, reinstall=False, branch: str = 'master'):
390391
from modules.btc_teleport import BtcTeleportModule
391392
module = BtcTeleportModule(ton, local)
392-
local.try_function(module.init, args=[reinstall])
393+
local.try_function(module.init, args=[reinstall, branch])
393394

394395
def rollback_to_mtc1(local, ton, args):
395396
color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}")

mytonctrl/scripts/btc_teleport1.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
REPO=""
22
SRC_DIR=""
33
USER=$(logname)
4+
BRANCH=master
45

5-
while getopts s:r: flag
6+
while getopts s:r:b: flag
67
do
78
case "${flag}" in
89
s) SRC_DIR=${OPTARG};;
910
r) REPO=${OPTARG};;
11+
b) BRANCH=${OPTARG};;
1012
*) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;;
1113
esac
1214
done
@@ -27,6 +29,8 @@ REPO_URL=https://github.com/RSquad/${REPO}.git
2729
cd $SRC_DIR || exit 1
2830
rm -rf $REPO
2931
git clone $REPO_URL
32+
cd $REPO && git checkout $BRANCH
33+
cd ..
3034

3135
chown -R $USER:$USER $REPO
3236

0 commit comments

Comments
 (0)