Skip to content

Commit 00d1caf

Browse files
authored
Merge pull request tronprotocol#4408 from forfreeday/feature/optimize_shell_net
feat: optimize start.sh
2 parents 414a728 + 4e55f4c commit 00d1caf

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

shell.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ The script is available in the java-tron project at [github](https://github.com/
4444
sh start.sh -cb --run
4545
```
4646

47+
* Select a supported network,default network `main`, optional network `test`,`private`
48+
```
49+
sh start.sh --net test
50+
```
4751

4852

4953
## Options
@@ -73,6 +77,9 @@ The script is available in the java-tron project at [github](https://github.com/
7377
* `-mem`
7478

7579
Specify the maximum memory of the `FullNode.jar` service in`MB`, jvm's startup maximum memory will be adjusted according to this parameter.
80+
81+
* `--net`
82+
Select test and private networks.
7683

7784
### build project
7885

@@ -226,4 +233,4 @@ sh start.sh --run -d /tmp/db/database -m 128 -b 64000
226233
sh start.sh --release --run -d /tmp/db/database -m 128 -b 64000
227234
```
228235

229-
For more design details, please refer to: [TIP298](https://github.com/tronprotocol/tips/issues/298) | [Leveldb Startup Optimization Plugins](https://github.com/tronprotocol/documentation-en/blob/master/docs/developers/archive-manifest.md)
236+
For more design details, please refer to: [TIP298](https://github.com/tronprotocol/tips/issues/298) | [Leveldb Startup Optimization Plugins](https://github.com/tronprotocol/documentation-en/blob/master/docs/developers/archive-manifest.md)

start.sh

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@
1919

2020
# Build FullNode config
2121
FULL_NODE_DIR="FullNode"
22-
FULL_NODE_CONFIG="main_net_config.conf"
22+
FULL_NODE_CONFIG_DIR="config"
23+
# config file
24+
FULL_NODE_CONFIG_MAIN_NET="main_net_config.conf"
25+
FULL_NODE_CONFIG_TEST_NET="test_net_config.conf.conf"
26+
FULL_NODE_CONFIG_PRIVATE_NET="private_net_config.conf"
2327
DEFAULT_FULL_NODE_CONFIG='config.conf'
2428
JAR_NAME="FullNode.jar"
2529
FULL_START_OPT=''
30+
31+
# Github
2632
GITHUB_BRANCH='master'
33+
GITHUB_CLONE_TYPE='HTTPS'
34+
GITHUB_REPOSITORY=''
35+
GITHUB_REPOSITORY_HTTPS_URL='https://github.com/tronprotocol/java-tron.git'
36+
GITHUB_REPOSITORY_SSH_URL='git@github.com:tronprotocol/java-tron.git'
2737

2838
# Shell option
2939
ALL_OPT_LENGTH=$#
@@ -53,6 +63,12 @@ RELEASE_URL='https://github.com/tronprotocol/java-tron/releases'
5363
QUICK_START=false
5464
CLONE_BUILD=false
5565

66+
if [[ $GITHUB_CLONE_TYPE == 'HTTPS' ]]; then
67+
GITHUB_REPOSITORY=$GITHUB_REPOSITORY_HTTPS_URL
68+
else
69+
GITHUB_REPOSITORY=$GITHUB_REPOSITORY_SSH_URL
70+
fi
71+
5672
# Determine the Java command to use to start the JVM.
5773
if [ -z "$JAVA_HOME" ]; then
5874
javaExecutable="`which javac`"
@@ -99,7 +115,7 @@ fi
99115

100116

101117
getLatestReleaseVersion() {
102-
full_node_version=`git ls-remote --tags git@github.com:tronprotocol/java-tron.git |grep GreatVoyage- | awk -F '/' 'END{print $3}'`
118+
full_node_version=`git ls-remote --tags $GITHUB_REPOSITORY |grep GreatVoyage- | awk -F '/' 'END{print $3}'`
103119
if [[ -n $full_node_version ]]; then
104120
echo $full_node_version
105121
else
@@ -166,8 +182,8 @@ quickStart() {
166182
mkdirFullNode
167183
echo "info: check latest version: $full_node_version"
168184
echo 'info: download config'
169-
download https://raw.githubusercontent.com/tronprotocol/tron-deployment/$GITHUB_BRANCH/$FULL_NODE_CONFIG $FULL_NODE_CONFIG
170-
mv $FULL_NODE_CONFIG 'config.conf'
185+
download https://raw.githubusercontent.com/tronprotocol/tron-deployment/$GITHUB_BRANCH/$FULL_NODE_CONFIG_MAIN_NET $FULL_NODE_CONFIG_MAIN_NET
186+
mv $FULL_NODE_CONFIG_MAIN_NET 'config.conf'
171187

172188
echo "info: download $full_node_version"
173189
download $RELEASE_URL/download/$full_node_version/$JAR_NAME $JAR_NAME
@@ -180,7 +196,7 @@ quickStart() {
180196

181197
cloneCode() {
182198
if type git >/dev/null 2>&1; then
183-
git_clone=$(git clone -b $GITHUB_BRANCH git@github.com:tronprotocol/java-tron.git)
199+
git_clone=$(git clone -b $GITHUB_BRANCH $GITHUB_REPOSITORY)
184200
if [[ git_clone == 0 ]]; then
185201
echo 'info: git clone java-tron success'
186202
fi
@@ -353,6 +369,35 @@ rebuildManifest() {
353369
fi
354370
}
355371

372+
specifyConfig(){
373+
echo "info: specify the net: $1"
374+
local netType=$1
375+
local configName;
376+
if [[ "$netType" = 'test' ]]; then
377+
configName=$FULL_NODE_CONFIG_TEST_NET
378+
elif [[ "$netType" = 'private' ]]; then
379+
configName=$FULL_NODE_CONFIG_PRIVATE_NET
380+
else
381+
echo "warn: no support config $nodeType"
382+
exit
383+
fi
384+
385+
if [[ ! -d $FULL_NODE_CONFIG_DIR ]]; then
386+
mkdir -p $FULL_NODE_CONFIG_DIR
387+
fi
388+
389+
if [[ -d $FULL_NODE_CONFIG_DIR/$configName ]]; then
390+
DEFAULT_FULL_NODE_CONFIG=$FULL_NODE_CONFIG_DIR/$configName
391+
break
392+
fi
393+
394+
if [[ ! -f $FULL_NODE_CONFIG_DIR/$configName ]]; then
395+
download https://raw.githubusercontent.com/tronprotocol/tron-deployment/$GITHUB_BRANCH/$configName $configName
396+
mv $configName $FULL_NODE_CONFIG_DIR/$configName
397+
DEFAULT_FULL_NODE_CONFIG=$FULL_NODE_CONFIG_DIR/$configName
398+
fi
399+
}
400+
356401
checkSign() {
357402
echo 'info: verify signature'
358403
local latest_version=$(`echo getLatestReleaseVersion`)
@@ -391,7 +436,6 @@ while [ -n "$1" ]; do
391436
case "$1" in
392437
-c)
393438
DEFAULT_FULL_NODE_CONFIG=$2
394-
FULL_START_OPT="$FULL_START_OPT $1 $2"
395439
shift 2
396440
;;
397441
-d)
@@ -403,6 +447,22 @@ while [ -n "$1" ]; do
403447
JAR_NAME=$2
404448
shift 2
405449
;;
450+
-p)
451+
FULL_START_OPT="$FULL_START_OPT $1 $2"
452+
shift 2
453+
;;
454+
-w)
455+
FULL_START_OPT="$FULL_START_OPT $1"
456+
shift 1
457+
;;
458+
--witness)
459+
FULL_START_OPT="$FULL_START_OPT $1"
460+
shift 1
461+
;;
462+
--net)
463+
specifyConfig $2
464+
shift 2
465+
;;
406466
-m)
407467
REBUILD_MANIFEST_SIZE=$2
408468
shift 2
@@ -487,8 +547,8 @@ while [ -n "$1" ]; do
487547
exit
488548
fi
489549
fi
490-
echo "warn: option $1 does not exist"
491-
exit
550+
FULL_START_OPT="$FULL_START_OPT $@"
551+
break
492552
;;
493553
esac
494554
done

0 commit comments

Comments
 (0)