Skip to content

Commit 4f5ad58

Browse files
Little-Peonyclaude
andcommitted
chore(scripts): fix shell script bugs and modernize JVM flags
- start.sh: fix always-false `if $darwin` → `if [[ "$(uname)" == "Darwin" ]]` - start.sh: replace `$(\`echo fn\`)` anti-pattern with `$(fn)` in 8 call sites - start.sh: replace removed CMS GC flags with G1GC - start.sh: fix always-true `ALL_OPT_LENGTH -eq 0 || -gt 0` and duplicate restart - ver.sh: remove `set -x` debug mode left in by mistake - ver.sh: fix Version.java path to framework/src/main/java/org/tron/program/Version.java Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3ab5adf commit 4f5ad58

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

start.sh

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if [ -z "$JAVA_HOME" ]; then
7777
# readlink(1) is not available as standard on Solaris 10.
7878
readLink=`which readlink`
7979
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
80-
if $darwin ; then
80+
if [[ "$(uname)" == "Darwin" ]]; then
8181
javaHome="`dirname \"$javaExecutable\"`"
8282
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
8383
else
@@ -151,7 +151,7 @@ getLatestReleaseVersion() {
151151
}
152152

153153
checkVersion() {
154-
github_release_version=$(`echo getLatestReleaseVersion`)
154+
github_release_version=$(getLatestReleaseVersion)
155155
if [[ -n $github_release_version ]]; then
156156
echo "info: github latest version: $github_release_version"
157157
echo $github_release_version
@@ -162,7 +162,7 @@ checkVersion() {
162162
}
163163

164164
upgrade() {
165-
latest_version=$(`echo getLatestReleaseVersion`)
165+
latest_version=$(getLatestReleaseVersion)
166166
echo "info: latest version: $latest_version"
167167
if [[ -n $latest_version ]]; then
168168
old_jar="$PWD/$JAR_NAME"
@@ -204,7 +204,7 @@ mkdirFullNode() {
204204
}
205205

206206
quickStart() {
207-
full_node_version=$(`echo getLatestReleaseVersion`)
207+
full_node_version=$(getLatestReleaseVersion)
208208
if [[ -n $full_node_version ]]; then
209209
mkdirFullNode
210210
echo "info: check latest version: $full_node_version"
@@ -280,7 +280,7 @@ stopService() {
280280

281281
checkAllowMemory() {
282282
os=`uname`
283-
totalMemory=$(`echo getTotalMemory`)
283+
totalMemory=$(getTotalMemory)
284284
total=`expr $totalMemory / 1024`
285285
if [[ $os == 'Darwin' ]]; then
286286
return
@@ -333,7 +333,7 @@ setJVMMemory() {
333333
JVM_MX=$(echo "$SPECIFY_MEMORY/1024*0.6" | bc | awk -F. '{print $1"g"}')
334334
JVM_MS=$JVM_MX
335335
else
336-
total=$(`echo getTotalMemory`)
336+
total=$(getTotalMemory)
337337
MAX_DIRECT_MEMORY=$(echo "$total/1024/1024*0.1" | bc | awk -F. '{print $1"g"}')
338338
JVM_MX=$(echo "$total/1024/1024*0.6" | bc | awk -F. '{print $1"g"}')
339339
JVM_MS=$JVM_MX
@@ -355,8 +355,8 @@ startService() {
355355
exit
356356
fi
357357

358-
nohup $JAVACMD -Xms$JVM_MS -Xmx$JVM_MX -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./gc.log \
359-
-XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing \
358+
nohup $JAVACMD -Xms$JVM_MS -Xmx$JVM_MX -XX:+UseG1GC -XX:+PrintGCDetails -Xloggc:./gc.log \
359+
-XX:+PrintGCDateStamps -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing \
360360
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
361361
-XX:MaxDirectMemorySize=$MAX_DIRECT_MEMORY -XX:+HeapDumpOnOutOfMemoryError \
362362
-XX:NewRatio=2 -jar \
@@ -383,7 +383,7 @@ rebuildManifest() {
383383
$JAVACMD -jar $ARCHIVE_JAR -d $REBUILD_DIR -m $REBUILD_MANIFEST_SIZE -b $REBUILD_BATCH_SIZE
384384
else
385385
echo 'info: download the rebuild manifest plugin from the github'
386-
local latest=$(`echo getLatestReleaseVersion`)
386+
local latest=$(getLatestReleaseVersion)
387387
download $RELEASE_URL/download/GreatVoyage-v"$latest"/$ARCHIVE_JAR $ARCHIVE_JAR
388388
if [[ $download == 0 ]]; then
389389
echo 'info: download success, rebuild manifest'
@@ -428,7 +428,7 @@ specifyConfig(){
428428

429429
checkSign() {
430430
echo 'info: verify signature'
431-
local latest_version=$(`echo getLatestReleaseVersion`)
431+
local latest_version=$(getLatestReleaseVersion)
432432
download $RELEASE_URL/download/$latest_version/sha256sum.txt sha256sum.txt
433433
fullNodeSha256=$(cat sha256sum.txt|grep 'FullNode'| awk -F ' ' '{print $1}')
434434

@@ -603,7 +603,7 @@ if [[ $UPGRADE == true ]]; then
603603
fi
604604

605605
if [[ $DOWNLOAD == true ]]; then
606-
latest=$(`echo getLatestReleaseVersion`)
606+
latest=$(getLatestReleaseVersion)
607607
if [[ -n $latest ]]; then
608608
download $RELEASE_URL/download/$latest/$JAR_NAME $latest
609609
exit
@@ -612,11 +612,7 @@ if [[ $DOWNLOAD == true ]]; then
612612
fi
613613
fi
614614

615-
if [[ $ALL_OPT_LENGTH -eq 0 || $ALL_OPT_LENGTH -gt 0 ]]; then
616-
restart
617-
fi
618-
619-
if [[ $RUN == true ]]; then
615+
if [[ $ALL_OPT_LENGTH -eq 0 || $RUN == true ]]; then
620616
restart
621617
fi
622618

ver.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
2-
set -x
3-
currentBranch=`git rev-parse --abbrev-ref HEAD`
2+
currentBranch=$(git rev-parse --abbrev-ref HEAD)
43

54
if [ "$currentBranch"x != "master"x ]
65
then
@@ -24,7 +23,7 @@ then
2423
fi
2524

2625

27-
versionPath="src/main/java/org/tron/program/Version.java"
26+
versionPath="framework/src/main/java/org/tron/program/Version.java"
2827
sed -i -e "s/VERSION_NAME.*$/VERSION_NAME = \"$versionName\";/g;s/VERSION_CODE.*$/VERSION_CODE = \"$versionCode\";/g" $versionPath
2928
git add $versionPath
3029
git commit -m "update a new version. version name:$versionName,version code:$versionCode"

0 commit comments

Comments
 (0)