forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09485e9
commit 91118bc
Showing
16 changed files
with
266 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# | ||
# 一键安装脚本说明 | ||
#1 build.sh在centos和Ubuntu版本测试成功; | ||
#2 所有Linux发行版本请确保yum和git已安装,并能正常使用; | ||
#3 如遇到中途依赖库下载失败,一般和网络状况有关,请到https://github.com/bcosorg/lib找到相应的库,手动安装成功后,再执行此脚本 | ||
# | ||
|
||
#!/bin/sh | ||
|
||
#install nodejs | ||
sudo yum install -y nodejs | ||
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org | ||
sudo cnpm install -g babel-cli babel-preset-es2017 | ||
echo '{ "presets": ["es2017"] }' > ~/.babelrc | ||
|
||
|
||
#install solc | ||
wget https://github.com/ethereum/solidity/releases/download/v0.4.13/solc-static-linux | ||
sudo cp solc-static-linux /usr/bin/solc | ||
sudo chmod +x /usr/bin/solc | ||
|
||
#install console | ||
sudo cnpm install -g ethereum-console | ||
|
||
#install deps | ||
sudo yum -y install cmake3 | ||
sudo yum install -y openssl openssl-devel | ||
chmod +x scripts/install_deps.sh | ||
./scripts/install_deps.sh | ||
|
||
#build bcos | ||
mkdir -p build | ||
cd build/ | ||
if grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then | ||
cmake -DEVMJIT=OFF -DTESTS=OFF -DMINIUPNPC=OFF .. | ||
else | ||
cmake3 -DEVMJIT=OFF -DTESTS=OFF -DMINIUPNPC=OFF .. | ||
fi | ||
|
||
make -j2 | ||
|
||
make install | ||
|
||
cd .. | ||
cd ./tool | ||
cnpm install | ||
|
||
cd .. | ||
cd ./systemcontractv2 | ||
cnpm install | ||
|
||
if [ ! -f "/usr/local/bin/bcoseth" ]; then | ||
echo 'bcoseth build fail!' | ||
else | ||
echo 'bcoseth build succ! path: /usr/local/bin/bcoseth' | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"sealEngine": "PBFT", | ||
"systemproxyaddress":"0x0", | ||
"systemproxyaddressDfsFile":"", | ||
"systemproxyaddressDfsServer":"", | ||
"listenip":"{ip}", | ||
"rpcport":"{rpcport}", | ||
"p2pport":"{p2pport}", | ||
"wallet":"{nodedir}keys.info", | ||
"keystoredir":"{nodedir}keystore/", | ||
"datadir":"{nodedir}data/", | ||
"vm":"interpreter", | ||
"networkid":"{networkid}", | ||
"logverbosity":"4", | ||
"coverlog":"OFF", | ||
"eventlog":"ON", | ||
"logconf":"{nodedir}log.conf", | ||
"dfsNode":"", | ||
"dfsGroup":"group1", | ||
"dfsStorage":"filestorage", | ||
"params": { | ||
"accountStartNonce": "0x0", | ||
"maximumExtraDataSize": "0x0", | ||
"tieBreakingGas": false, | ||
"blockReward": "0x0", | ||
"networkID" : "0x0" | ||
}, | ||
"NodeextraInfo":{nodeextrainfo} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"nonce": "0x0", | ||
"difficulty": "0x0", | ||
"mixhash": "0x0", | ||
"coinbase": "0x0", | ||
"timestamp": "0x0", | ||
"parentHash": "0x0", | ||
"extraData": "0x0", | ||
"gasLimit": "0x13880000000000", | ||
"god":"{admin}", | ||
"alloc": {}, | ||
"initMinerNodes":{initMinerNodes} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
var fs=require('fs'); | ||
var execSync =require('child_process').execSync; | ||
|
||
var options = process.argv; | ||
if( options.length < 3 ) | ||
{ | ||
console.log('Usage: node init.js node0.sample node1.sample node2.sample... '); | ||
process.exit(0); | ||
} | ||
|
||
var nodeconfiglength=0; | ||
var nodeconfig=[]; | ||
while(nodeconfig.length<options.length-2 ){ | ||
var node=JSON.parse(fs.readFileSync(options[2+nodeconfig.length], 'utf-8')); | ||
nodeconfig.push(node); | ||
} | ||
|
||
console.log("开始检查配置..."); | ||
var check=true; | ||
for( var i=0;i<nodeconfig.length;i++){ | ||
for( var j=0;j<nodeconfig.length;j++){ | ||
if( i!=j ){ | ||
if( nodeconfig[i].networkid != nodeconfig[j].networkid){ | ||
check=false; | ||
console.log('节点'+i+'和节点'+j+' networkid不一致,请检查!'); | ||
} | ||
if( nodeconfig[i].ip == nodeconfig[j].ip ){ | ||
if( nodeconfig[i].nodedir == nodeconfig[j].nodedir ){ | ||
console.log('节点'+i+',和节点'+j+' IP相同且datadir相同,请检查!'); | ||
check=false; | ||
} | ||
if( nodeconfig[i].rpcport == nodeconfig[j].rpcport ){ | ||
console.log('节点'+i+',和节点'+j+' IP相同且rpcport相同,请检查!'); | ||
check=false; | ||
} | ||
if( nodeconfig[i].p2pport == nodeconfig[j].p2pport ){ | ||
console.log('节点'+i+',和节点'+j+' IP相同且p2pport相同,请检查!'); | ||
check=false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if( !check ){ | ||
process.exit(1); | ||
} | ||
else{ | ||
console.log('配置检查成功!!!'); | ||
} | ||
|
||
var admin; | ||
try{ | ||
admin=execSync("node ../tool/accountManager.js"); | ||
console.log('生成管理员账户成功!!!即将拷贝备份到每个节点目录的admin.message文件中,请注意保管!!!'); | ||
}catch(e){ | ||
console.log('管理员账户生成失败!!!'); | ||
process.exit(1); | ||
} | ||
|
||
var nodeid=[]; | ||
console.log('开始初始化节点配置...'); | ||
for( var i=0;i<nodeconfig.length;i++){ | ||
try{ | ||
execSync("mkdir -p "+nodeconfig[i].nodedir); | ||
execSync("mkdir -p "+nodeconfig[i].nodedir+"log/"); | ||
execSync("mkdir -p "+nodeconfig[i].nodedir+"data/"); | ||
execSync("mkdir -p "+nodeconfig[i].nodedir+"keystore/"); | ||
execSync("bcoseth --gennetworkrlp "+nodeconfig[i].nodedir+"data/network.rlp"); | ||
nodeid.push(fs.readFileSync(nodeconfig[i].nodedir+"data/network.rlp.pub", 'utf-8')); | ||
|
||
var logconfig=fs.readFileSync("log.conf.template", 'utf-8'); | ||
fs.writeFileSync(nodeconfig[i].nodedir+'log.conf',logconfig.replace(/{nodedir}/g,nodeconfig[i].nodedir)); | ||
|
||
var startsh=fs.readFileSync("start.sh.template", 'utf-8'); | ||
startsh=startsh.replace(/{genesis}/g,nodeconfig[i].nodedir+'genesis.json'); | ||
fs.writeFileSync(nodeconfig[i].nodedir+'start'+i+'.sh',startsh.replace(/{config}/g,nodeconfig[i].nodedir+'config.json')); | ||
execSync("chmod -x "+nodeconfig[i].nodedir+'start'+i+'.sh'); | ||
|
||
fs.writeFileSync(nodeconfig[i].nodedir+'admin.message',admin); | ||
console.log('节点'+i+'目录生成成功!!!'); | ||
}catch(e){ | ||
console.log('节点'+i+'目录生成失败!'+e); | ||
} | ||
|
||
}//for | ||
|
||
admin=fs.readFileSync(nodeconfig[0].nodedir+'admin.message','utf-8'); | ||
admin=(admin.split(/\n/)[2].split(/ /)[2]); | ||
|
||
var genesis=fs.readFileSync("genesis.json.template", 'utf-8'); | ||
genesis=genesis.replace(/{initMinerNodes}/g,JSON.stringify(nodeid)); | ||
genesis=genesis.replace(/{admin}/g,admin); | ||
console.log('创世文件生成成功!!!'); | ||
|
||
var nodeextrainfo=[]; | ||
for( var i=0;i<nodeconfig.length;i++){ | ||
nodeextrainfo.push({ | ||
"Nodeid":nodeid[i], | ||
"Nodedesc": "node"+i, | ||
"Agencyinfo": "node"+i, | ||
"Peerip": nodeconfig[i].ip, | ||
"Identitytype": 1, | ||
"Port":nodeconfig[i].p2pport, | ||
"Idx":i | ||
}); | ||
} | ||
console.log('记账节点列表生成成功!!!'); | ||
|
||
for( var i=0;i<nodeconfig.length;i++){ | ||
try{ | ||
fs.writeFileSync(nodeconfig[i].nodedir+'genesis.json',genesis); | ||
console.log('节点'+i+' genesis.json生成成功!!!'); | ||
|
||
|
||
var config=fs.readFileSync("config.json.template", 'utf-8'); | ||
config=config.replace(/{nodedir}/g,nodeconfig[i].nodedir); | ||
config=config.replace(/{networkid}/g,nodeconfig[i].networkid); | ||
config=config.replace(/{ip}/g,nodeconfig[i].ip); | ||
config=config.replace(/{rpcport}/g,nodeconfig[i].rpcport); | ||
config=config.replace(/{p2pport}/g,nodeconfig[i].p2pport); | ||
config=config.replace(/{nodeextrainfo}/g,JSON.stringify(nodeextrainfo)); | ||
|
||
fs.writeFileSync(nodeconfig[i].nodedir+'config.json',config); | ||
|
||
console.log('节点'+i+' config.json生成成功!!!'); | ||
}catch(e){ | ||
console.log('节点'+i+' 配置生成失败!'+e); | ||
} | ||
|
||
}//for | ||
console.log('恭喜!已全部构建成功!'); | ||
|
||
for( var i=0;i<nodeconfig.length;i++){ | ||
console.log('执行 '+nodeconfig[i].nodedir+'start'+i+'.sh 即可启动节点'+i); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"networkid":"123456", | ||
"nodedir":"/bcos-data/node0/", | ||
"ip":"127.0.0.1", | ||
"rpcport":8545, | ||
"p2pport":30303 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"networkid":"123456", | ||
"nodedir":"/bcos-data/node1/", | ||
"ip":"127.0.0.1", | ||
"rpcport":8546, | ||
"p2pport":30304 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
node init.js node0.sample node1.sample | ||
chmod +x /bcos-data/node0/start0.sh | ||
chmod +x /bcos-data/node1/start1.sh | ||
sh /bcos-data/node0/start0.sh & | ||
sh /bcos-data/node1/start1.sh & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
bcoseth --genesis {genesis} --config {config} | ||
|