Skip to content

Commit

Permalink
Added some sanity checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Clouet authored and Benoît Clouet committed Jul 10, 2017
1 parent 8237c7c commit 653d41e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions facts.d/geth-getconfig.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#!/bin/bash

# Ethereum seems not to be properly installed
if [ ! -f /lib/systemd/system/geth.service ]; then
echo -e "{}"
exit 0
fi

ETH_PID=$(pidof eth)

# Ethereum seems not to be running
if [ -z $ETH_PID ]; then
echo -e "{}"
exit 0
fi
DATADIR=$(grep datadir /lib/systemd/system/geth.service |cut --delimiter '"' --fields 2)
IPC="ipc:$(find $DATADIR -name geth.ipc)"

function fact {
geth --exec "$1" attach $IPC
}

nodeInfo=$(fact "admin.nodeInfo")
eth=$(fact "eth")
NODE_INFO=$(geth --exec "admin.nodeInfo" attach $IPC)
ETH=$(geth --exec "eth" attach $IPC)

echo -e " {\n nodeInfo: $nodeInfo,\n eth: $eth\n}"
echo -e "{\n ethPid: $ETH_PID,\n nodeInfo: $NODE_INFO,\n eth: $ETH\n}"

0 comments on commit 653d41e

Please sign in to comment.