@@ -21,63 +21,73 @@ author="tonstakers"
2121repo=" mytonctrl-v2"
2222branch=" master"
2323mode=" validator"
24+ network=" mainnet"
25+ ton_node_version=" master" # Default version
26+
2427
2528show_help_and_exit () {
26- echo ' Supported argumets :'
29+ echo ' Supported arguments :'
2730 echo ' -c PATH Provide custom config for toninstaller.sh'
2831 echo ' -t Disable telemetry'
29- echo ' -i Ignore minimum reqiurements '
32+ echo ' -i Ignore minimum requirements '
3033 echo ' -d Use pre-packaged dump. Reduces duration of initial synchronization.'
3134 echo ' -a Set MyTonCtrl git repo author'
32- echo ' -r Set MyTonCtrl git repo'
33- echo ' -b Set MyTonCtrl git repo branch'
34- echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
35- echo ' -h Show this help'
36- exit
35+ echo ' -r Set MyTonCtrl git repo'
36+ echo ' -b Set MyTonCtrl git repo branch'
37+ echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
38+ echo ' -n NETWORK Specify the network (mainnet or testnet)'
39+ echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
40+ echo ' -h Show this help'
41+ exit
3742}
3843
3944if [[ " ${1-} " =~ ^-* h(elp)? $ ]]; then
4045 show_help_and_exit
4146fi
4247
4348# node install parameters
44- # todo support parametr
45- # config="https://ton-blockchain.github.io/global.config.json"
46- config=" https://ton-blockchain.github.io/testnet-global.config.json"
47-
49+ config=" https://ton-blockchain.github.io/global.config.json"
4850telemetry=true
4951ignore=false
5052dump=false
51-
52-
53-
54- while getopts c:tida:r:b:m: flag
55- do
56- case " ${flag} " in
57- c) config=${OPTARG} ;;
58- t) telemetry=false;;
59- i) ignore=true;;
60- d) dump=true;;
61- a) author=${OPTARG} ;;
62- r) repo=${OPTARG} ;;
63- b) branch=${OPTARG} ;;
64- m) mode=${OPTARG} ;;
65- h) show_help_and_exit;;
66- * )
53+ cpu_required=16
54+ mem_required=64000000 # 64GB in KB
55+
56+ while getopts " :c:tida:r:b:m:n:v:h" flag; do
57+ case " ${flag} " in
58+ c) config=${OPTARG} ;;
59+ t) telemetry=false;;
60+ i) ignore=true;;
61+ d) dump=true;;
62+ a) author=${OPTARG} ;;
63+ r) repo=${OPTARG} ;;
64+ b) branch=${OPTARG} ;;
65+ m) mode=${OPTARG} ;;
66+ n) network=${OPTARG} ;;
67+ v) ton_node_version=${OPTARG} ;;
68+ h) show_help_and_exit;;
69+ * )
6770 echo " Flag -${flag} is not recognized. Aborting"
6871 exit 1 ;;
69- esac
72+ esac
7073done
7174
75+ # Set config based on network argument
76+ if [ " ${network} " = " testnet" ]; then
77+ config=" https://ton-blockchain.github.io/testnet-global.config.json"
78+ cpu_required=8
79+ mem_required=16000000 # 16GB in KB
80+ fi
81+
7282# check machine configuration
7383echo -e " ${COLOR} [1/5]${ENDC} Checking system requirements"
7484
7585cpus=$( lscpu | grep " CPU(s)" | head -n 1 | awk ' {print $2}' )
7686memory=$( cat /proc/meminfo | grep MemTotal | awk ' {print $2}' )
7787
7888echo " This machine has ${cpus} CPUs and ${memory} KB of Memory"
79- if [ " $ignore " = false ] && ([ " ${cpus} " -lt 16 ] || [ " ${memory} " -lt 64000000 ]); then
80- echo " Insufficient resources. Requires a minimum of 16 processors and 64Gb RAM."
89+ if [ " $ignore " = false ] && ([ " ${cpus} " -lt " ${cpu_required} " ] || [ " ${memory} " -lt " ${mem_required} " ]); then
90+ echo " Insufficient resources. Requires a minimum of " ${cpu_required} " processors and " ${mem_required} " RAM."
8191 exit 1
8292fi
8393
@@ -99,10 +109,8 @@ file3=${BIN_DIR}/ton/validator-engine-console/validator-engine-console
99109
100110if [ ! -f " ${file1} " ] || [ ! -f " ${file2} " ] || [ ! -f " ${file3} " ]; then
101111 echo " TON does not exists, building"
102- # wget https://raw.githubusercontent.com/${author}/${repo}/${branch}/scripts/ton_installer.sh -O /tmp/ton_installer.sh
103- wget https://raw.githubusercontent.com/tonstakers/mytonctrl-v2/master/scripts/ton_installer.sh -O /tmp/ton_installer.sh
104- # todo set vas scrip patch
105- bash /tmp/ton_installer.sh -c ${config}
112+ wget https://raw.githubusercontent.com/${author} /${repo} /${branch} /scripts/ton_installer.sh -O /tmp/ton_installer.sh
113+ bash /tmp/ton_installer.sh -c ${config} -v ${ton_node_version}
106114fi
107115
108116# Cloning mytonctrl
@@ -139,5 +147,10 @@ mkdir -p ${version_dir}
139147echo ${migrate_version} > ${version_path}
140148chown ${user} :${user} ${version_dir} ${version_path}
141149
150+ # create symbolic link if branch not eq mytonctrl
151+ if [ " ${repo} " != " mytonctrl" ]; then
152+ ln -sf ${SOURCES_DIR} /${repo} ${SOURCES_DIR} /mytonctrl
153+ fi
154+
142155echo -e " ${COLOR} [5/5]${ENDC} Mytonctrl installation completed"
143156exit 0
0 commit comments