Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ The script allows you to customize the run in several ways, as listed below:
* `--archivist`: (as described above) run the node as an archivist instead of a validator
* `--name`: (as described above) set the name of the node. If you omit this option, one will be generated for you but it's not encouraged.
* `--stash_account`: provide `AccountId` of the stash account linked to your validator node. If you run as validator, then this argument is mandatory.
* `--no_prompts`: skip all prompts and use the default choices: useful for setups involving a supervisor like systemd.

83 changes: 83 additions & 0 deletions run_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,89 @@

set -eo pipefail

Help()
{
echo "Run the aleph-node as either a validator or an archivist."
echo "Syntax: ./run_node.sh [--<name|image|stash_account> <value>] [--<archivist|mainnet|build_only|sync_from_genesis>]"
echo
echo "options:"
echo "archivist Run the node as an archivist (the default is to run as a validator)"
echo "stash_account Stash account of your validator: optional but recommended, if you're re-running the script."
echo "n | name Set the node's name."
echo "d | data_dir Specify the directory where all the chain data will be stored (default: ~/.alephzero)."
echo "mainnet Join the mainnet (by default the script will join testnet)."
echo "i | image Specify the Docker image to use"
echo "build_only Do not run after the setup."
echo "sync_from_genesis Perform a full sync instead of downloading the backup."
echo "no_prompts Auto-select the default value in all cases instead of prompting."
echo "help Print this help."
echo
echo "Example usage:"
echo "./run_node.sh --name my-aleph-node --mainnet --stash_account 5CeeD3MGHCvZecJkvfJVzYvYkoPtw9pTVvskutXAUtZtjcYa"
echo
echo "or, shorter:"
echo "./run_node.sh --n my-aleph-node --mainnet --stash_account 5CeeD3MGHCvZecJkvfJVzYvYkoPtw9pTVvskutXAUtZtjcYa"
echo
}




# The defaults
export NAME="aleph-node-$(xxd -l "16" -p /dev/urandom | tr -d " \n" ; echo)"
export BASE_PATH="/data"
export HOST_BASE_PATH="${HOME}/.alephzero"
export DB_SNAPSHOT_FILE="db_backup.tar.gz"
export DB_SNAPSHOT_URL="https://db.test.azero.dev/latest.html"
export MAINNET_DB_SNAPSHOT_URL="https://db.azero.dev/latest.html"
export DB_SNAPSHOT_PATH="chains/testnet/" # testnet by default
export CHAINSPEC_FILE="testnet_chainspec.json"
export PROMPTS=true

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help) # display Help
Help
exit;;
--archivist) # Run as an archivist
export ARCHIVIST=true
shift;;
-n | --name) # Enter a name
export NAME="$2"
shift 2;;
-d | --data_dir) # Choose the data directory
export HOST_BASE_PATH="$2"
shift 2;;
--mainnet) # Join the mainnet
export DB_SNAPSHOT_PATH="chains/mainnet/"
export CHAINSPEC_FILE="mainnet_chainspec.json"
export DB_SNAPSHOT_URL="${MAINNET_DB_SNAPSHOT_URL}"
shift;;
-i | --image) # Enter a base path
export ALEPH_IMAGE="$2"
export PULL_IMAGE=false
shift 2;;
--build_only)
export BUILD_ONLY=true
shift;;
--sync_from_genesis)
export SYNC=true
shift;;
--stash_account)
export STASH_ACCOUNT=$2
shift 2;;
--no_prompts)
export PROMPTS=false
shift;;
-* | --* )
echo "Warning: unrecognized option: $1"
exit;;
*)
echo "Unrecognized command"
Help
exit;;
esac
done

./scripts/update.sh

Expand Down
95 changes: 14 additions & 81 deletions scripts/run_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,6 @@

set -eo pipefail

Help()
{
echo "Run the aleph-node as either a validator or an archivist."
echo "Syntax: ./run_node.sh [--<name|image|stash_account> <value>] [--<archivist|mainnet|build_only|sync_from_genesis>]"
echo
echo "options:"
echo "archivist Run the node as an archivist (the default is to run as a validator)"
echo "stash_account Stash account of your validator: optional but recommended, if you're re-running the script."
echo "n | name Set the node's name."
echo "d | data_dir Specify the directory where all the chain data will be stored (default: ~/.alephzero)."
echo "mainnet Join the mainnet (by default the script will join testnet)."
echo "i | image Specify the Docker image to use"
echo "build_only Do not run after the setup."
echo "sync_from_genesis Perform a full sync instead of downloading the backup."
echo "help Print this help."
echo
echo "Example usage:"
echo "./run_node.sh --name my-aleph-node --mainnet --stash_account 5CeeD3MGHCvZecJkvfJVzYvYkoPtw9pTVvskutXAUtZtjcYa"
echo
echo "or, shorter:"
echo "./run_node.sh --n my-aleph-node --mainnet --stash_account 5CeeD3MGHCvZecJkvfJVzYvYkoPtw9pTVvskutXAUtZtjcYa"
echo
}




# The defaults
NAME="aleph-node-$(xxd -l "16" -p /dev/urandom | tr -d " \n" ; echo)"
BASE_PATH="/data"
HOST_BASE_PATH="${HOME}/.alephzero"
DB_SNAPSHOT_FILE="db_backup.tar.gz"
DB_SNAPSHOT_URL="https://db.test.azero.dev/latest.html"
MAINNET_DB_SNAPSHOT_URL="https://db.azero.dev/latest.html"
DB_SNAPSHOT_PATH="chains/testnet/" # testnet by default
CHAINSPEC_FILE="testnet_chainspec.json"


while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help) # display Help
Help
exit;;
--archivist) # Run as an archivist
ARCHIVIST=true
shift;;
-n | --name) # Enter a name
NAME="$2"
shift 2;;
-d | --data_dir) # Choose the data directory
HOST_BASE_PATH="$2"
shift 2;;
--mainnet) # Join the mainnet
DB_SNAPSHOT_PATH="chains/mainnet/"
CHAINSPEC_FILE="mainnet_chainspec.json"
DB_SNAPSHOT_URL="${MAINNET_DB_SNAPSHOT_URL}"
shift;;
-i | --image) # Enter a base path
ALEPH_IMAGE="$2"
PULL_IMAGE=false
shift 2;;
--build_only)
BUILD_ONLY=true
shift;;
--sync_from_genesis)
SYNC=true
shift;;
--stash_account)
STASH_ACCOUNT=$2
shift 2;;
-* | --* )
echo "Warning: unrecognized option: $1"
exit;;
*)
echo "Unrecognized command"
Help
exit;;
esac
done

ALEPH_VERSION=$(cat env/version)

Expand All @@ -91,9 +12,15 @@ then
echo "If you wish to customize the directory, select 'n' and re-run the script"
echo "with the '--data_dir' argument."
echo "Do you want to continue? [Y/n]"
read -r CONT

if [[ "$PROMPTS" = true ]]
then
read -r CONT
else
CONT='y'
fi

if [[ "$CONT" == 'n' ]]
if [[ "$CONT" -eq 'n' ]]
then
echo "Please re-run the script, supplying the '--data_dir' argument, exiting."
exit 0
Expand Down Expand Up @@ -173,6 +100,12 @@ echo 'Performing session key checks...'

if [[ -z "${STASH_ACCOUNT}" ]]
then
if [[ "$PROMPTS" = false ]]
then
echo "Skipping the session keys check."
exit 0
fi

echo "Stash account not provided. This is ok if you're running the script for the first time but recommended for subsequent runs."
read -p "Are you sure you want to skip the session keys check? [y/N]" -r -n 1
echo ""
Expand Down
12 changes: 9 additions & 3 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ git remote update
RES=$(git status -uno | grep behind)

if [ $? -eq 0 ]; then
echo "Newer version available, would you like to update? [y/N]"
read -r UPDATE
if [[ "${UPDATE}" != 'y' ]]
echo "Newer version available, would you like to update? [Y/n]"
if [[ "$PROMPTS" = true ]]
then
read -r UPDATE
else
UPDATE='y'
fi

if [[ "${UPDATE}" -eq 'n' ]]
then
echo "Skipping the update. You can still do it manually using git."
exit 0
Expand Down