@@ -16,19 +16,24 @@ author="ton-blockchain"
1616repo=" mytonctrl"
1717branch=" master"
1818mode=" validator"
19+ network=" mainnet"
20+ ton_node_version=" master" # Default version
21+
1922
2023show_help_and_exit () {
21- echo ' Supported argumets :'
24+ echo ' Supported arguments :'
2225 echo ' -c PATH Provide custom config for toninstaller.sh'
2326 echo ' -t Disable telemetry'
24- echo ' -i Ignore minimum reqiurements '
27+ echo ' -i Ignore minimum requirements '
2528 echo ' -d Use pre-packaged dump. Reduces duration of initial synchronization.'
2629 echo ' -a Set MyTonCtrl git repo author'
27- echo ' -r Set MyTonCtrl git repo'
28- echo ' -b Set MyTonCtrl git repo branch'
29- echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
30- echo ' -h Show this help'
31- exit
30+ echo ' -r Set MyTonCtrl git repo'
31+ echo ' -b Set MyTonCtrl git repo branch'
32+ echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
33+ echo ' -n NETWORK Specify the network (mainnet or testnet)'
34+ echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
35+ echo ' -h Show this help'
36+ exit
3237}
3338
3439if [[ " ${1-} " =~ ^-* h(elp)? $ ]]; then
@@ -40,36 +45,44 @@ config="https://ton-blockchain.github.io/global.config.json"
4045telemetry=true
4146ignore=false
4247dump=false
43-
44-
45-
46- while getopts c:tida:r:b:m: flag
47- do
48- case " ${flag} " in
49- c) config=${OPTARG} ;;
50- t) telemetry=false;;
51- i) ignore=true;;
52- d) dump=true;;
53- a) author=${OPTARG} ;;
54- r) repo=${OPTARG} ;;
55- b) branch=${OPTARG} ;;
56- m) mode=${OPTARG} ;;
57- h) show_help_and_exit;;
58- * )
48+ cpu_required=16
49+ mem_required=64000000 # 64GB in KB
50+
51+ while getopts " :c:tida:r:b:m:n:v:h" flag; do
52+ case " ${flag} " in
53+ c) config=${OPTARG} ;;
54+ t) telemetry=false;;
55+ i) ignore=true;;
56+ d) dump=true;;
57+ a) author=${OPTARG} ;;
58+ r) repo=${OPTARG} ;;
59+ b) branch=${OPTARG} ;;
60+ m) mode=${OPTARG} ;;
61+ n) network=${OPTARG} ;;
62+ v) ton_node_version=${OPTARG} ;;
63+ h) show_help_and_exit;;
64+ * )
5965 echo " Flag -${flag} is not recognized. Aborting"
6066 exit 1 ;;
61- esac
67+ esac
6268done
6369
70+ # Set config based on network argument
71+ if [ " ${network} " = " testnet" ]; then
72+ config=" https://ton-blockchain.github.io/testnet-global.config.json"
73+ cpu_required=8
74+ mem_required=16000000 # 16GB in KB
75+ fi
76+
6477# check machine configuration
6578echo -e " ${COLOR} [1/5]${ENDC} Checking system requirements"
6679
6780cpus=$( lscpu | grep " CPU(s)" | head -n 1 | awk ' {print $2}' )
6881memory=$( cat /proc/meminfo | grep MemTotal | awk ' {print $2}' )
6982
7083echo " This machine has ${cpus} CPUs and ${memory} KB of Memory"
71- if [ " $ignore " = false ] && ([ " ${cpus} " -lt 16 ] || [ " ${memory} " -lt 64000000 ]); then
72- echo " Insufficient resources. Requires a minimum of 16 processors and 64Gb RAM."
84+ if [ " $ignore " = false ] && ([ " ${cpus} " -lt " ${cpu_required} " ] || [ " ${memory} " -lt " ${mem_required} " ]); then
85+ echo " Insufficient resources. Requires a minimum of " ${cpu_required} " processors and " ${mem_required} " RAM."
7386 exit 1
7487fi
7588
@@ -92,7 +105,7 @@ file3=${BIN_DIR}/ton/validator-engine-console/validator-engine-console
92105if [ ! -f " ${file1} " ] || [ ! -f " ${file2} " ] || [ ! -f " ${file3} " ]; then
93106 echo " TON does not exists, building"
94107 wget https://raw.githubusercontent.com/${author} /${repo} /${branch} /scripts/ton_installer.sh -O /tmp/ton_installer.sh
95- bash /tmp/ton_installer.sh -c ${config}
108+ bash /tmp/ton_installer.sh -c ${config} -v ${ton_node_version}
96109fi
97110
98111# Cloning mytonctrl
@@ -129,5 +142,10 @@ mkdir -p ${version_dir}
129142echo ${migrate_version} > ${version_path}
130143chown ${user} :${user} ${version_dir} ${version_path}
131144
145+ # create symbolic link if branch not eq mytonctrl
146+ if [ " ${repo} " != " mytonctrl" ]; then
147+ ln -sf ${SOURCES_DIR} /${repo} ${SOURCES_DIR} /mytonctrl
148+ fi
149+
132150echo -e " ${COLOR} [5/5]${ENDC} Mytonctrl installation completed"
133151exit 0
0 commit comments