From f2aece2be0beff80abce3526b0ebb4f41a5a2c5d Mon Sep 17 00:00:00 2001 From: Leopere Date: Sat, 3 Nov 2018 21:32:00 -0400 Subject: [PATCH] initial commit of quick-bootstrap.sh --- chainquery/quick-bootstrap.sh | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 chainquery/quick-bootstrap.sh diff --git a/chainquery/quick-bootstrap.sh b/chainquery/quick-bootstrap.sh new file mode 100644 index 0000000..6636e46 --- /dev/null +++ b/chainquery/quick-bootstrap.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +## Be Polite and ask for permission. +function QandA() { + read -r -p "Continue with $1 [y/N] " response + response=${response,,} # tolower + if [[ "$response" =~ ^(yes|y)$ ]]; then + echo "Continuing with this." + eval $1 + else + echo "Skipping the $1." + fi +} + +## Check your $PATH for required dependencies. +## Stop and complain for now, later automagically install them. +function test_for_deps() { + ## Test for Command + if ! [ -x "$(command -v $1)" ]; then + echo "Error: $1 is not installed." >&2 + echo "You must have $1 installed." + else + echo "Info: $1 is installed." + fi +} + +## Declare Linux app dependencies to check for. +DEPENDENCIES=( + wget + unzip + docker +) +## Recommended. +BONUS_DEPENDENCIES=( + docker-compose +) + +for i in "${!DEPENDENCIES[@]}"; do + echo ${DEPENDENCIES[$i]}"_KEY" + ## Indirect references http://tldp.org/LDP/abs/html/ivr.html + eval TESTDEP=\$"${DEPENDENCIES[$i]}" + test_for_deps $TESTDEP +done + +## Add ways to get into and out of a bind here. +case i in + * ) + echo "==================================================" + echo "You look like you need usage examples let me help." + echo "==================================================" + echo "Add documentation on script params HERE" + ;; + getdata ) + ## Get DB Checkpoint data. + wget http://chainquery-data.s3.amazonaws.com/data.zip ./chainquery.zip + ;; + extract ) + ## Unpack the data again if need be. + unzip ./chainquery.zip + ;; + cleanup ) + ## Remove any junk here. + rm chainquery.zip + ;; + reset ) + ## Give up on everything and try again. + # rm -Rf ./data + # rm -f ./chainquery.zip + ;; +esac