1+ #! /bin/bash
2+
3+ export GOGC=200
4+ # default values
5+ FullImmutabilityThreshold=90000
6+ MinBlocksForBlobRequests=524288
7+ DefaultExtraReserveForBlobRequests=28800
8+ BreatheBlockInterval=600
9+ FixedTurnLength=1
10+ LAST_FORK_MORE_DELAY=1800
11+
12+ function startChaind() {
13+ workspace=/server/validator
14+
15+ PassedForkTime=` cat ${workspace} /hardforkTime.txt| grep passedHardforkTime| awk -F" " ' {print $NF}' `
16+ LastHardforkTime=$( expr ${PassedForkTime} + ${LAST_FORK_MORE_DELAY} )
17+ initLog=${workspace} /init.log
18+ rialtoHash=` cat ${initLog} | grep " database=lightchaindata" | awk -F" =" ' {print $NF}' | awk -F' "' ' {print $1}' `
19+
20+ ip=` ifconfig eth0| grep inet| grep -v inet6 | awk ' { print $2 }' `
21+ sed -i -e " s?FileRoot = \"\" ?FileRoot = \" /mnt/efs/validator/${ip} /\" ?g" /server/validator/config.toml
22+ mkdir -p /mnt/efs/validator/${ip}
23+ ${workspace} /bsc --config ${workspace} /config.toml \
24+ --datadir ${workspace} \
25+ --password ${workspace} /password.txt \
26+ --blspassword ${workspace} /password.txt \
27+ --unlock {{validatorAddr}} --miner.etherbase {{validatorAddr}} --rpc.allow-unprotected-txs --allow-insecure-unlock \
28+ --ws --ws.port 8545 --ws.addr ${ip} --http.addr 0.0.0.0 --http.corsdomain " *" \
29+ --metrics --metrics.addr 0.0.0.0 \
30+ --pprof --pprof.port 6061 \
31+ --syncmode snap --mine --vote --monitor.maliciousvote \
32+ --cache 10480 --light.serve 50 \
33+ --rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.bohr ${LastHardforkTime} \
34+ --override.immutabilitythreshold ${FullImmutabilityThreshold} --override.breatheblockinterval ${BreatheBlockInterval} \
35+ --override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
36+ ` # --override.fixedturnlength ${FixedTurnLength}` \
37+ >> /mnt/efs/validator/${ip} /bscnode.log 2>&1
38+ }
39+
40+ function stopChaind() {
41+ pid=` ps -ef | grep /server/validator/bsc | grep -v grep | awk ' {print $2}' `
42+ if [ -n " $pid " ]; then
43+ for(( i= 1 ;i<= 4 ;i++ )) ;
44+ do
45+ kill $pid
46+ sleep 5
47+ pid=` ps -ef | grep /server/validator/bsc | grep -v grep | awk ' {print $2}' `
48+ if [ -z " $pid " ]; then
49+ break
50+ elif [ $i -eq 4 ]; then
51+ kill -9 $kid
52+ fi
53+ done
54+ fi
55+ }
56+
57+ CMD=$1
58+
59+ case $CMD in
60+ -start)
61+ echo " start"
62+ startChaind
63+ ;;
64+ -stop)
65+ echo " stop"
66+ stopChaind
67+ ;;
68+ -restart)
69+ stopChaind
70+ sleep 3
71+ startChaind
72+ ;;
73+ * )
74+ echo " Usage: chaind.sh -start | -stop | -restart .Or use systemctl start | stop | restart bsc.service "
75+ ;;
76+ esac
0 commit comments