1919
2020# Build FullNode config
2121FULL_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"
2327DEFAULT_FULL_NODE_CONFIG=' config.conf'
2428JAR_NAME=" FullNode.jar"
2529FULL_START_OPT=' '
30+
31+ # Github
2632GITHUB_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
2939ALL_OPT_LENGTH=$#
@@ -53,6 +63,12 @@ RELEASE_URL='https://github.com/tronprotocol/java-tron/releases'
5363QUICK_START=false
5464CLONE_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.
5773if [ -z " $JAVA_HOME " ]; then
5874 javaExecutable=" ` which javac` "
99115
100116
101117getLatestReleaseVersion () {
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
181197cloneCode () {
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+
356401checkSign () {
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
494554done
0 commit comments