Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions 00.Setup/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
This folder contains a list of scripts help get boot strap the process.

**Windows**
*StartGeth.ps1* - This script will download and unzip Go Ethereum then launch it in mining mode. It will consume
the genesis json from the 01.LocalBlockchain folder.

*LaunchEthereumWallet.ps1* - This script will download the Ethereum Wallet and launch it which will attempt to connect to the local geth instance that is running.
**Windows & Linux**
*StartGeth* - This script will download and unzip Go Ethereum then launch it in mining mode. It will consume the genesis json from the 01.LocalBlockchain folder.
*LaunchEthereumWallet* - This script will download the Ethereum Wallet and launch it which will attempt to connect to the local geth instance that is running.
21 changes: 21 additions & 0 deletions 00.Setup/linux/LaunchEthereumWallet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
source ./common/common.sh

wallet=""

Invoke-Unpack \
"EthereumWallet" \
"https://github.com/ethereum/mist/releases/download/v0.8.9/Ethereum-Wallet-linux64-0-8-9.zip" \
"0.8.9" \
"ethereumwallet" \
wallet \
Extract-Zip

PATH=$wallet:$PATH

# add geth to the path
pushd "../../.download/"
gethPath="$(realpath $(dirname $(find . -name geth)))"
PATH=$gethPath:$PATH
popd

ethereumwallet
93 changes: 93 additions & 0 deletions 00.Setup/linux/StartGeth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
source ./common/common.sh

function Print-Help
{
echo "***********************************************"
echo "Package Requirements: wget, unzip, tar, realpath"
echo "Arguments:"
echo " -d -> Disable Mining"
echo " -n 1234 -> Network Id"
echo " -e \"enode://...\" -> Enode Url"
echo "***********************************************"
}

# Process arguments (-h, -d, -n 123, -e enode://...)
disableMining=0
networkId="54321"
eNodeUrl=""

while getopts "hdn:e:" opt; do
case ${opt} in
h )
Print-Help
exit 0
;;
d )
disableMining=1
;;
n )
networkId="$OPTARG"
;;
e )
eNodeUrl="$OPTARG"
;;
\? )
exit 1
;;
esac
done
shift $((OPTIND -1))

# Download solidity compiler & add to path
solcPath=""

Invoke-Unpack \
"Solidity" \
"https://github.com/ethereum/solidity/releases/download/v0.4.9/solidity-ubuntu-trusty.zip" \
"0.4.9" \
"solc" \
solcPath \
Extract-Zip

PATH=$solcPath:$PATH

# Download Go Ethereum & add to path
gethPath=""

Invoke-Unpack \
"GoEthereum" \
"https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.5.7-da2a22c3.tar.gz" \
"1.5.7" \
"geth" \
gethPath \
Extract-TarGz

PATH=$gethPath:$PATH

# Initialize geth from the genesis block if not done before
lessonRoot=$(realpath "../../01.LocalBlockchain")
dataRoot=$lessonRoot"/data"
chainDataRoot=$dataRoot"/geth/chaindata"

if [ ! -d "$chainDataRoot" ]; then
genesisPath=$lessonRoot"/genesis.json"
geth --datadir $chainDataRoot init $genesisPath
fi

# If the eNode URL option is set, create the static-nodes.json file
if [ ! -z "$eNodeUrl" ]; then
eNodeJson=$(wget $eNodeUrl -O -)
staticNodesFile=$dataRoot"/static-nodes.json"
rm -r "$staticNodesFile"
touch "$staticNodesFile"
echo "$eNodeJson" > "$staticNodesFile"
fi

# If mining is disabled
if [ "$disableMining" -eq "1" ]; then
# Launch Geth in TX mode
geth --datadir $dataRoot --networkid $networkId
else
# Launch Geth with mining enabled
geth --datadir $dataRoot --mine --minerthreads 1 --networkid $networkId
fi
58 changes: 58 additions & 0 deletions 00.Setup/linux/common/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function Invoke-Unpack
{
local name=$1
local uri=$2
local version=$3
local fileName=$4
local fileNamePathVar=$5
local extractFunc=$6
local downloadDir="../../.download/"
local extractDir="unpacked/$name/$version/"
local extractFile="$name.$version.comp"

mkdir $downloadDir
pushd $downloadDir

local filePath="$(realpath $(dirname $(find . -name $fileName)))"

# If the file already exists, use it. Else, download.
if [ ! -z "$filePath" ]; then
eval "$fileNamePathVar=$filePath"
else
# download
wget -O $extractFile $uri

# create extraction dir
mkdir -p "$extractDir"

# invoke extraction function
eval "$extractFunc ./$extractFile '$extractDir'"

# delete archive file
rm -r ./$extractFile

# find the file we're looking for, and get its parent folder, fully resolved
local filePath="$(realpath $(dirname $(find . -name $fileName)))"

# set the path var for the caller
eval "$fileNamePathVar=$filePath"
fi

popd
}

function Extract-Zip
{
local fileName=$1
local extractDirectory=$2

unzip $fileName -d $extractDirectory
}

function Extract-TarGz
{
local fileName=$1
local extractDirectory=$2

tar -xzvf $fileName -C $extractDirectory
}
3 changes: 3 additions & 0 deletions 00.Setup/windows/LaunchEthereumWallet.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

Set-StrictMode -Version 2

# Accept all TLS security protocols
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

Import-Module (Join-Path $PSScriptRoot "Common") -Force

$config = [PSCustomObject]@{
Expand Down
3 changes: 3 additions & 0 deletions 00.Setup/windows/StartGeth.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ param(

Set-StrictMode -Version 2

# Accept all TLS security protocols
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

Import-Module (Join-Path $PSScriptRoot "Common") -Force

$config = [PSCustomObject]@{
Expand Down