Skip to content

Commit

Permalink
add deployment shell and modify ContractAddress BtcHost tokenAmount t…
Browse files Browse the repository at this point in the history
…o string
  • Loading branch information
etying committed Nov 27, 2018
1 parent 2296356 commit bb8c73b
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 96 deletions.
4 changes: 2 additions & 2 deletions adaptor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Config struct {

type BTC struct {
NetID int
Host string
BtcHost string
RPCUser string
RPCPasswd string
CertPath string
Expand All @@ -49,7 +49,7 @@ type CCInfo struct {
var DefaultConfig = Config{
Btc: BTC{
NetID: 1,
Host: "localhost:18332",
BtcHost: "localhost:18332",
RPCUser: "zxl",
RPCPasswd: "123456",
CertPath: "",
Expand Down
6 changes: 3 additions & 3 deletions build/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [ ! -d "$adafullpath" ]; then
go get -u $ada
else
echo "adaptor exist"
git -C $adafullpath pull
# git -C $adafullpath pull
fi


Expand All @@ -36,7 +36,7 @@ if [ ! -d "$btcfullpath" ]; then
go get -u $btc
else
echo "btc exist"
git -C $btcfullpath pull
# git -C $btcfullpath pull
fi


Expand All @@ -45,7 +45,7 @@ if [ ! -d "$ethfullpath" ]; then
go get -u $eth
else
echo "eth exist"
git -C $ethfullpath pull
# git -C $ethfullpath pull
fi


Expand Down
Empty file modified cmd/deployment/createaccount.sh
100644 → 100755
Empty file.
117 changes: 107 additions & 10 deletions cmd/deployment/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,115 @@
#!/bin/bash
#!/usr/bin/expect

echo "deployment"
#mkdir node1
#mkdir node2
#mkdir node3
echo "===============deployment================"

#cp gptn node1/.
#cp gptn node2/.
#cp gptn node3/.
function ExecInit()
{

count=1
while [ $count -le $1 ] ;
do
#echo $count;
#ExecDeploy $count
if [ $count -eq 1 ] ;then
cd node$count
cp ../init.sh .
gptninit=`./init.sh`
`echo $gptninit`
path=`pwd`
fullpath=${path}"/palletone/gptn/leveldb"
echo $fullpath
if [ ! -d $fullpath ]; then
echo "====================init err=================="
return
fi
cd ../
else
echo $count
cd node$count
cp ../node1/palletone/gptn/leveldb ./palletone/gptn/. -rf
cd ../
fi
let ++count;
sleep 1;
done
echo "====================init ok====================="
return 0;

}

cd node1
#./gptn dumpjson
#./gptn dumpconfig


function replacejson()
{
length=`cat $1 |jq '.initialMediatorCandidates| length'`

MinMediatorCount="MinMediatorCount"
line=`awk "/$MinMediatorCount/{print NR}" $1`
newMinMediatorCount="\"MinMediatorCount\":$length,"
replace=`sed -e "${line}c $newMinMediatorCount" $1`
rm $1
`echo $replace >>t.json`
jq -r . t.json >> $1
rm t.json


add=`cat $1 |
jq "to_entries |
map(if .key == \"initialActiveMediators\"
then . + {\"value\":$length}
else .
end
) |
from_entries"`

rm $1
echo $add >> temp.json
jq -r . temp.json >> $1
rm temp.json
echo "======modify genesis json ok======="
}

function ExecDeploy()
{
echo ===============$1===============
mkdir "node"$1
#if [ $1 -eq 4 ] ;then
#echo "=="$1
cp gptn ./createaccount.sh modifyconfig.sh modifyjson.sh init.sh node$1
cd node$1
/bin/bash modifyconfig.sh
#source ./modifyjson.sh
source ./modifyconfig.sh
ModifyConfig $1
rm *.sh
cd ../
#else
#echo $1
#fi
}



function LoopDeploy()
{
count=1;
while [ $count -le $1 ] ;
do
#echo $count;
ExecDeploy $count
let ++count;
sleep 1;
done
return 0;
}
read -p "Please input the numbers of nodes you want: " n;

LoopDeploy $n;

json="node1/ptn-genesis.json"
replacejson $json

ExecInit $n


18 changes: 18 additions & 0 deletions cmd/deployment/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/expect
#!/bin/bash
set timeout 30
spawn ./gptn init
expect "Passphrase:"
send "1\r"
interact











21 changes: 0 additions & 21 deletions cmd/deployment/initdks.sh

This file was deleted.

116 changes: 94 additions & 22 deletions cmd/deployment/modifyconfig.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,48 +1,66 @@
#!/bin/bash
source ./modifyjson.sh

newipcpath="IPCPath=\"gptn1.ipc\""


HTTPPort=8545
WSPort=8546
Port=8080
ListenAddr=30303
BtcHost=18332
ContractAddress=12345
LocalHost=localhost



function ModifyConfig()
{

dumcpconfig=`./gptn dumpconfig`
echo $dumpconfig

if [ $1 -ne 1 ] ;then
newipcpath="IPCPath=\"gptn$1.ipc\""
sed -i '/^IPCPath/c'$newipcpath'' ptn-config.toml

newHTTPPort="HTTPPort=8555"
newHTTPPort="HTTPPort=$[$HTTPPort+$1*10]"
sed -i '/^HTTPPort/c'$newHTTPPort'' ptn-config.toml

newWSPort="WSPort=8556"
newWSPort="WSPort=$[$WSPort+$1*10]"
sed -i '/^WSPort/c'$newWSPort'' ptn-config.toml

newPort="Port=8081"
newPort="Port=$[$Port+$1]"
sed -i '/^Port/c'$newPort'' ptn-config.toml


newListenAddr="ListenAddr=\":30305\""
newListenAddr="ListenAddr=\":$[$ListenAddr+$1]\""
sed -i '/^ListenAddr/c'$newListenAddr'' ptn-config.toml

newBtcHost="BtcHost=\"localhost:18333\""
newBtcHost="BtcHost=\"localhost:$[$BtcHost+$1]\""
sed -i '/^BtcHost/c'$newBtcHost'' ptn-config.toml


newContractAddress="ContractAddress=\"127.0.0.1:12346\""
newContractAddress="ContractAddress=\"127.0.0.1:$[$ContractAddress+$1]\""
sed -i '/^ContractAddress/c'$newContractAddress'' ptn-config.toml
else
dumcpjson=`./gptn dumpjson`
echo $dumpjson

createaccount=`./createaccount.sh`
#echo "...\r $createaccount"
account=`echo $createaccount | sed -n '$p'| awk '{print $NF}'`
echo "account: "$account

newEnableStaleProduction="EnableStaleProduction=true"
sed -i '/^EnableStaleProduction/c'$newEnableStaleProduction'' ptn-config.toml

fi


key=`./gptn mediator initdks`
createaccount=`./createaccount.sh`
tempinfo=`echo $createaccount | sed -n '$p'| awk '{print $NF}'`
accountlength=35
accounttemp=${tempinfo:0:$accountlength}
#account=`echo ${accounttemp//^M/}`
account=`echo ${accounttemp///}`

privatekeylength=45
private=${key#*private key: }
privatekey=${private:0:$privatekeylength}
echo $privatekey


publickeylength=176
public=${key#*public key: }
publickey=${public:0:$publickeylength}
echo $publickey


newAddress="Address=\"$account\""
sed -i '/^Address/c'$newAddress'' ptn-config.toml
Expand All @@ -51,6 +69,28 @@ sed -i '/^Address/c'$newAddress'' ptn-config.toml
newPassword="Password=\"1\""
sed -i '/^Password/c'$newPassword'' ptn-config.toml




info=`./gptn mediator initdks`
key=`echo $info`

privatekeylength=44
private=${key#*private key: }
privatekeytemp=${private:0:$privatekeylength}
privatekey=`echo ${privatekeytemp///}`
#echo $privatekey


publickeylength=175
public=${key#*public key: }
publickeytemp=${public:0:$publickeylength}
publickey=`echo ${publickeytemp///}`
#echo $publickey




newInitPartSec="InitPartSec=\"$privatekey\""
sed -i '/^InitPartSec/c'$newInitPartSec'' ptn-config.toml

Expand All @@ -61,6 +101,38 @@ sed -i '/^InitPartPub/c'$newInitPartPub'' ptn-config.toml



while :
do
info=`./gptn nodeInfo`
tempinfo=`echo $info | sed -n '$p'| awk '{print $NF}'`
length=`echo ${#tempinfo}`
nodeinfotemp=${tempinfo:0:$length}
nodeinfo=`echo ${nodeinfotemp//^M/}`
length=`echo ${#nodeinfo}`
b=140
if [ "$length" -lt "$b" ]
then
continue
else
break
fi


done



echo "account: "$account
echo "publickey: "$publickey
echo "nodeinfo: "$nodeinfo




ModifyJson $account $publickey $nodeinfo
}


#ModifyConfig 4


Expand Down
Loading

0 comments on commit bb8c73b

Please sign in to comment.