#!/usr/bin/env bash ############################################################################# # # # Blurt-in-a-box Easy Installer # # # # Created by Someguy123 (github.com/Someguy123) # # (C) 2020 - Created by Someguy123 # # # # https://github.com/Someguy123 ||| https://peakd.com/@someguy123 # # # # Blurt chain files hosted by Privex™ # # # # Buy a server from https://www.privex.io :) # # # # Usage: # # # # curl -fsSL https://cdn.privex.io/extras/ezblurt.sh | bash # # # ############################################################################# : ${BLURT_DIR="/blurt"} : ${SG_REPO="https://github.com/Someguy123/blurt-docker.git"} has_binary() { /usr/bin/env which "$1" > /dev/null } # Error handling function for ShellCore _sc_fail() { >&2 echo "Failed to load or install Privex ShellCore..." && exit 1; } # If `load.sh` isn't found in the user install / global install, then download and run the auto-installer # from Privex's CDN. [[ -f "${HOME}/.pv-shcore/load.sh" ]] || [[ -f "/usr/local/share/pv-shcore/load.sh" ]] || \ { curl -fsS https://cdn.privex.io/github/shell-core/install.sh | bash >/dev/null; } || _sc_fail # Attempt to load the local install of ShellCore first, then fallback to global install if it's not found. [[ -d "${HOME}/.pv-shcore" ]] && source "${HOME}/.pv-shcore/load.sh" || \ source "/usr/local/share/pv-shcore/load.sh" || _sc_fail autoupdate_shellcore msg msg bold purple " ====================================================== " msg bold purple " # # " msg bold purple " # Blurt-in-a-box Easy Installer # " msg bold purple " # # " msg bold purple " # Created by Someguy123 (github.com/Someguy123) # " msg bold purple " # (C) 2020 - Someguy123 # " msg bold purple " # # " msg bold purple " # Blurt chain files hosted by Privex™ # " msg bold purple " # # " msg bold purple " # Buy a server from https://www.privex.io :) # " msg bold purple " # # " msg bold purple " ====================================================== " msg if ! has_binary sudo; then if [[ "$(whoami)" == "root" ]]; then sudo() { env "$@" } else >&2 msg red "ERROR: You are not 'root', and sudo is not available!" >&2 msg red "Please become root (maybe with 'su') and then run this script." exit 3 fi fi msg green "\n >>> Updating apt + installing dependencies\n" sudo apt update -qy >/dev/null sudo apt install -qy curl jq pv wget git rsync >/dev/null if [[ ! -d /blurt ]]; then msg green " >>> Creating $BLURT_DIR\n" sudo mkdir -v /blurt fi msg green "\n >>> Fixing permissions for $BLURT_DIR\n" CUR_USER="$(whoami)" sudo chmod -Rv 775 "$BLURT_DIR" sudo chown -Rv "${CUR_USER}:${CUR_USER}" "$BLURT_DIR" msg green "\n >>> Cloning blurt-docker into $BLURT_DIR\n" if ! git clone "$SG_REPO" "$BLURT_DIR"; then >&2 msg bold red "\n !!! Failed to clone $SG_REPO - aborting !!!\n" exit 1 fi cd "$BLURT_DIR" msg green "\n >>> Setting up .env\n" { echo "NETWORK=blurt" echo "DOCKER_NAME=blurt" echo "DATADIR=${BLURT_DIR}/data" echo "SHM_DIR=${BLURT_DIR}/data/shm" } >> .env [[ ! -d "${BLURT_DIR}/data/shm" ]] && mkdir -p "${BLURT_DIR}/data/shm" [[ ! -d "${BLURT_DIR}/data/witness_node_data_dir/blockchain" ]] && mkdir -p "${BLURT_DIR}/data/witness_node_data_dir/blockchain" msg bold green "\n >>> Downloading block_log and block_log.index from files.privex.io\n" sudo rsync -avh --progress 'rsync://files.privex.io/blockchains/blurt/block_log' "${BLURT_DIR}/data/witness_node_data_dir/blockchain/" sudo rsync -avh --progress 'rsync://files.privex.io/blockchains/blurt/block_log.index' "${BLURT_DIR}/data/witness_node_data_dir/blockchain/" msg bold green "\n >>> Downloading shared_memory.bin from files.privex.io\n" sudo rsync -avh --sparse --progress 'rsync://files.privex.io/blockchains/blurt/shared_memory.bin' "${BLURT_DIR}/data/shm/" if ! has_binary docker; then msg bold green "\n >>> Installing docker ...\n" curl -fsSL https://get.docker.com | sudo sh if [[ "$(whoami)" != "root" ]]; then sudo gpasswd -a "$(whoami)" docker fi fi msg bold green "\n >>> Downloading/installing someguy123/blurt:latest\n" sudo ./run.sh install someguy123/blurt:latest msg bold green "\n >>> Starting blurt\n" sudo ./run.sh start msg msg bold purple " ====================================================== " msg bold purple " # # " msg bold purple " # Blurt-in-a-box Easy Installer # " msg bold purple " # # " msg bold purple " # Created by Someguy123 (github.com/Someguy123) # " msg bold purple " # (C) 2020 - Someguy123 # " msg bold purple " # # " msg bold purple " # Blurt chain files hosted by Privex™ # " msg bold purple " # # " msg bold purple " # Buy a server from https://www.privex.io :) # " msg bold purple " # # " msg bold purple " ====================================================== " msg msg bold green "\n +++ Finished installing Blurt into $BLURT_DIR +++ \n" echo msg cyan "Blurt-in-a-box (blurt-docker) is located at $BLURT_DIR" msg cyan "Your config is at ${BLURT_DIR}/data/witness_node_data_dir/config.ini" msg cyan "The blockchain is at: ${BLURT_DIR}/data/witness_node_data_dir/blockchain/" msg cyan "Shared memory is at: ${BLURT_DIR}/data/shm/" echo