diff --git a/bin/eth.sh b/bin/eth.sh index 2f90c71..f944bee 100755 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -1,9 +1,25 @@ #!/bin/bash -IP=$(ec2metadata --public-ipv4) + trap "exit" INT -if [[ -f /usr/bin/geth ]]; + +if [[ -f `which ec2metadata 2>/dev/null` ]] +then + # If ec2 instance then get ips from ec2metadata + LOCALIP=$(ec2metadata --local-ipv4) + IP=$(ec2metadata --public-ipv4) +else + # Else get IPs from ifconfig and dig + LOCALIP=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | head -n1 | awk '{print $2}' | cut -d':' -f2) + IP=$(dig +short myip.opendns.com @resolver1.opendns.com) +fi + +if [[ -f `which geth 2>/dev/null` ]] then geth -rpc -maxpeers "50" -verbosity "3" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" -nat "extip:$IP" +elif [[ -f `which eth 2>/dev/null` ]] +then + eth --bootstrap --peers 50 --remote 52.16.188.185:30303 --mining off --json-rpc --local-ip $LOCALIP -v 5 else - eth --bootstrap --peers 50 --remote 52.16.188.185:30303 --mining off --json-rpc --public-ip $IP -v 5 + echo "Ethereum was not found!" + exit 1; fi \ No newline at end of file