Skip to content

Instantly share code, notes, and snippets.

@martinhbramwell
Last active April 24, 2016 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinhbramwell/3c4945272d485536060282e14c7842bf to your computer and use it in GitHub Desktop.
Save martinhbramwell/3c4945272d485536060282e14c7842bf to your computer and use it in GitHub Desktop.
Bundle the initialization files of an Ethereum root node
#!/bin/bash
#
source .userVars.sh
declare WORK_DIR=${HOME}/${PROJECT_DIR};
declare GETH_PATH=${WORK_DIR}/geth;
declare IPC_ENDPOINT=${GETH_PATH}/geth.ipc;
declare INITIAL_FILES_ARCHIVE="/tmp/initialFiles.tar.gz";
declare GENESIS_FILE="Genesis.json";
declare CHAINDATA_DIR="geth/chaindata";
declare NODE_INFO_FILE="nodeInfo.json";
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
echo "Host node reports : \"Collecting client initialization files from ${DIR} into ${INITIAL_FILES_ARCHIVE}\"";
cd ${DIR};
declare GETH_CONSOLE_RUNNING=$(ps aux | grep geth | grep -c console);
declare GETH_CONNECTION_TYPE="console";
if [[ ${GETH_CONSOLE_RUNNING} -gt 0 ]]; then GETH_CONNECTION_TYPE="attach"; fi;
echo "Host node reports : \"Geth usage type is : ${GETH_CONNECTION_TYPE}\"";
# echo "Type : ${GETH_CONNECTION_TYPE}";
geth \
--datadir ${GETH_PATH} \
--verbosity 0 \
--networkid ${NETWORK_ID} \
--exec admin.nodeInfo \
${GETH_CONNECTION_TYPE} ipc:/${IPC_ENDPOINT} > ${NODE_INFO_FILE};
tar \
--create \
--gzip \
--file ${INITIAL_FILES_ARCHIVE} \
${GENESIS_FILE} \
${CHAINDATA_DIR} \
${NODE_INFO_FILE};
echo "Host node reports : \"The file ${INITIAL_FILES_ARCHIVE}\" is ready for pick up.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment