Skip to content

Commit 5b06eb2

Browse files
authored
Merge pull request #304 from tonstakers/update-install-scripts
Update install scripts
2 parents dce4c78 + c188aba commit 5b06eb2

File tree

3 files changed

+68
-36
lines changed

3 files changed

+68
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![GitHub stars](https://img.shields.io/github/stars/ton-blockchain/mytonctrl?style=flat-square&logo=github) ![GitHub forks](https://img.shields.io/github/forks/ton-blockchain/mytonctrl?style=flat-square&logo=github) ![GitHub issues](https://img.shields.io/github/issues/ton-blockchain/mytonctrl?style=flat-square&logo=github) ![GitHub pull requests](https://img.shields.io/github/issues-pr/ton-blockchain/mytonctrl?style=flat-square&logo=github) ![GitHub last commit](https://img.shields.io/github/last-commit/ton-blockchain/mytonctrl?style=flat-square&logo=github) ![GitHub license](https://img.shields.io/github/license/ton-blockchain/mytonctrl?style=flat-square&logo=github)
22

3-
<!-- omit from toc -->
3+
<!-- omit from toc -->
44
# MyTonCtrl
55

66
<!-- omit from toc -->

scripts/install.sh

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@ author="ton-blockchain"
1616
repo="mytonctrl"
1717
branch="master"
1818
mode="validator"
19+
network="mainnet"
20+
ton_node_version="master" # Default version
21+
1922

2023
show_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

3439
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
@@ -40,36 +45,44 @@ config="https://ton-blockchain.github.io/global.config.json"
4045
telemetry=true
4146
ignore=false
4247
dump=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
6268
done
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
6578
echo -e "${COLOR}[1/5]${ENDC} Checking system requirements"
6679

6780
cpus=$(lscpu | grep "CPU(s)" | head -n 1 | awk '{print $2}')
6881
memory=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
6982

7083
echo "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
7487
fi
7588

@@ -92,7 +105,7 @@ file3=${BIN_DIR}/ton/validator-engine-console/validator-engine-console
92105
if [ ! -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}
96109
fi
97110

98111
# Cloning mytonctrl
@@ -129,5 +142,10 @@ mkdir -p ${version_dir}
129142
echo ${migrate_version} > ${version_path}
130143
chown ${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+
132150
echo -e "${COLOR}[5/5]${ENDC} Mytonctrl installation completed"
133151
exit 0

scripts/ton_installer.sh

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

11-
# Get arguments
12-
config=https://ton-blockchain.github.io/global.config.json
13-
while getopts c: flag
14-
do
15-
case "${flag}" in
16-
c) config=${OPTARG};;
17-
esac
11+
while getopts ":c:v:h" flag; do
12+
case "${flag}" in
13+
c) config=${OPTARG};;
14+
v) ton_node_version=${OPTARG};;
15+
h) show_help_and_exit;;
16+
*)
17+
echo "Flag -${flag} is not recognized. Aborting"
18+
exit 1 ;;
19+
esac
1820
done
1921

22+
echo "config: ${config}"
23+
echo "checkout to ${ton_node_version}"
24+
2025
# Цвета
2126
COLOR='\033[95m'
2227
ENDC='\033[0m'
@@ -71,7 +76,7 @@ elif [[ "$OSTYPE" =~ darwin.* ]]; then
7176

7277
echo "Please, write down your username, because brew package manager cannot be run under root user:"
7378
read LOCAL_USERNAME
74-
79+
7580
su $LOCAL_USERNAME -c "brew update"
7681
su $LOCAL_USERNAME -c "brew install openssl cmake llvm"
7782
elif [ "$OSTYPE" == "freebsd"* ]; then
@@ -104,6 +109,15 @@ echo -e "${COLOR}[3/6]${ENDC} Preparing for compilation"
104109
cd $SOURCES_DIR
105110
rm -rf $SOURCES_DIR/ton
106111
git clone --recursive https://github.com/ton-blockchain/ton.git
112+
113+
echo "checkout to ${ton_node_version}"
114+
115+
if [ "${ton_node_version}" != "master" ]; then
116+
cd $SOURCES_DIR/ton
117+
git checkout ${ton_node_version}
118+
cd ../
119+
fi
120+
107121
git config --global --add safe.directory $SOURCES_DIR/ton
108122

109123
# Подготавливаем папки для компиляции

0 commit comments

Comments
 (0)