-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77aa761
commit 8f8b78e
Showing
11 changed files
with
285 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/bin/bash | ||
#set -x -e | ||
|
||
echo "###################### WARNING!!! ######################" | ||
echo "### This script will bootstrap a validator node ###" | ||
echo "### for the Solana Testnet cluster, and connect ###" | ||
echo "### it to the monitoring dashboard ###" | ||
echo "### at solana.thevalidators.io ###" | ||
echo "########################################################" | ||
|
||
install_validator () { | ||
|
||
echo "### Which type of validator you want to set up? ###" | ||
select cluster in "mainnet-beta" "testnet"; do | ||
case $cluster in | ||
mainnet-beta ) inventory="mainnet.yaml"; break;; | ||
testnet ) inventory="testnet.yaml"; break;; | ||
esac | ||
done | ||
|
||
echo "Please enter a name for your validator node: " | ||
read VALIDATOR_NAME | ||
read -e -p "Please enter the full path to your validator key pair file: " -i "/root/" PATH_TO_VALIDATOR_KEYS | ||
|
||
if [ ! -f "$PATH_TO_VALIDATOR_KEYS/validator-keypair.json" ] | ||
then | ||
echo "OOPS! Key $PATH_TO_VALIDATOR_KEYS/validator-keypair.json not found. Please verify and run the script again" | ||
exit | ||
fi | ||
|
||
if [ ! -f "$PATH_TO_VALIDATOR_KEYS/vote-account-keypair.json" ] ## && [ "$inventory" = "mainnet.yaml" ] | ||
then | ||
echo "OOPS! Key $PATH_TO_VALIDATOR_KEYS/vote-account-keypair.json not found. Please verify and run the script again. For security reasons we do not create any keys for mainnet." | ||
exit | ||
fi | ||
|
||
read -e -p "Enter new RAM drive size, GB (recommended size: 200GB):" -i "200" RAM_DISK_SIZE | ||
read -e -p "Enter new server swap size, GB (recommended size: equal to server RAM): " -i "64" SWAP_SIZE | ||
|
||
rm -rf sv_manager/ | ||
|
||
if [[ $(which apt | wc -l) -gt 0 ]] | ||
then | ||
pkg_manager=apt | ||
elif [[ $(which yum | wc -l) -gt 0 ]] | ||
then | ||
pkg_manager=yum | ||
fi | ||
|
||
echo "Updating packages..." | ||
$pkg_manager update | ||
echo "Installing ansible, curl, unzip..." | ||
$pkg_manager install ansible curl unzip --yes | ||
|
||
ansible-galaxy collection install ansible.posix | ||
ansible-galaxy collection install community.general | ||
|
||
echo "Downloading Solana validator manager version $sv_manager_version" | ||
cmd="https://github.com/mfactory-lab/sv-manager/archive/refs/tags/$sv_manager_version.zip" | ||
echo "starting $cmd" | ||
curl -fsSL "$cmd" --output sv_manager.zip | ||
echo "Unpacking" | ||
unzip ./sv_manager.zip -d . | ||
|
||
mv sv-manager* sv_manager | ||
rm ./sv_manager.zip | ||
cd ./sv_manager || exit | ||
cp -r ./inventory_example ./inventory | ||
|
||
# shellcheck disable=SC2154 | ||
#echo "pwd: $(pwd)" | ||
#ls -lah ./ | ||
|
||
if [ ! -z $solana_version ] | ||
then | ||
SOLANA_VERSION="--extra-vars {\"agave_version\":\"$agave_version\"}" | ||
fi | ||
if [ ! -z $extra_vars ] | ||
then | ||
EXTRA_INSTALL_VARS="--extra-vars $extra_vars" | ||
fi | ||
if [ ! -z $tags ] | ||
then | ||
TAGS="--tags [$tags]" | ||
fi | ||
|
||
if [ ! -z $skip_tags ] | ||
then | ||
SKIP_TAGS="--skip-tags $skip_tags" | ||
fi | ||
|
||
ansible-playbook --connection=local --inventory ./inventory/$inventory --limit localhost playbooks/pb_config.yaml --extra-vars "{ \ | ||
'validator_name':'$VALIDATOR_NAME', \ | ||
'local_secrets_path': '$PATH_TO_VALIDATOR_KEYS', \ | ||
'swap_file_size_gb': $SWAP_SIZE, \ | ||
'ramdisk_size_gb': $RAM_DISK_SIZE, \ | ||
}" $SOLANA_VERSION $EXTRA_INSTALL_VARS $TAGS $SKIP_TAGS | ||
|
||
ansible-playbook --connection=local --inventory ./inventory/$inventory --limit localhost playbooks/pb_install_agave_validator.yaml --extra-vars "@/etc/sv_manager/sv_manager.conf" $SOLANA_VERSION $EXTRA_INSTALL_VARS $TAGS $SKIP_TAGS | ||
|
||
echo "### 'Uninstall ansible ###" | ||
|
||
$pkg_manager remove ansible --yes | ||
if [ "$inventory" = "mainnet.yaml" ] | ||
then | ||
echo "WARNING: solana is ready to go. But you must start it by the hand. Use \"systemctl start solana-validator\" command." | ||
fi | ||
|
||
|
||
echo "### Check your dashboard: https://solana.thevalidators.io/d/e-8yEOXMwerfwe/solana-monitoring?&var-server=$VALIDATOR_NAME" | ||
|
||
} | ||
|
||
|
||
while [ $# -gt 0 ]; do | ||
|
||
if [[ $1 == *"--"* ]]; then | ||
param="${1/--/}" | ||
declare ${param}="$2" | ||
# echo $1 $2 // Optional to see the parameter:value result | ||
fi | ||
|
||
shift | ||
done | ||
|
||
sv_manager_version=${sv_manager_version:-latest} | ||
|
||
echo "installing sv manager version $sv_manager_version" | ||
|
||
echo "This script will bootstrap a Solana validator node. Proceed?" | ||
select yn in "Yes" "No"; do | ||
case $yn in | ||
Yes ) install_validator "$sv_manager_version" "$extra_vars" "$solana_version" "$tags" "$skip_tags"; break;; | ||
No ) echo "Aborting install. No changes will be made."; exit;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: install solana validator | ||
hosts: all | ||
become: yes | ||
roles: | ||
- check_node | ||
- configure_ubuntu | ||
- agave_cli | ||
- solana_validator_bootstrap | ||
- monitoring | ||
vars: | ||
- agave: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: install solana validator | ||
hosts: all | ||
become: yes | ||
roles: | ||
- check_node | ||
- configure_ubuntu | ||
- solana_cli | ||
- solana_validator_bootstrap | ||
- monitoring | ||
vars: | ||
- jito: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: create download dir | ||
file: | ||
path: /tmp/solana | ||
state: directory | ||
owner: "{{ solana_user }}" | ||
group: "{{ solana_user }}" | ||
tags: | ||
- cli.install | ||
|
||
- name: install solana | ||
block: | ||
- name: download latest solana release installer | ||
get_url: | ||
url: "https://release.anza.xyz/v{{ agave_version | default('stable') }}/install" | ||
dest: /tmp/solana/ | ||
mode: 0755 | ||
|
||
- name: run solana installer | ||
shell: /tmp/solana/install | ||
become: yes | ||
become_user: "{{ solana_user }}" | ||
tags: | ||
- cli.install | ||
|
||
- name: remove installer | ||
file: | ||
path: /tmp/solana | ||
state: absent | ||
tags: | ||
- cli.install | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
- name: set force install fact | ||
set_fact: | ||
force: "{{ force | default('false') }}" | ||
tags: | ||
- cli | ||
- cli.install | ||
- cli.update | ||
|
||
- name: check solana cli installed | ||
stat: | ||
path: /home/solana/.local/share/solana/install/active_release/bin/agave-install | ||
register: solana_exists | ||
tags: | ||
- cli | ||
- cli.install | ||
- cli.update | ||
|
||
- name: install solana cli | ||
import_tasks: install.yaml | ||
tags: | ||
- cli | ||
- cli.install | ||
when: force == 'true' or not solana_exists.stat.exists | ||
|
||
- name: update solana cli | ||
import_tasks: update.yaml | ||
tags: | ||
- cli | ||
- cli.update | ||
when: force != 'true' and solana_exists.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- name: DEBUG | ||
debug: | ||
msg: "Updating Solana to {{ agave_version }}" | ||
|
||
- name: update solana (agave) | ||
shell: "agave-install init {{ agave_version }}" | ||
become: yes | ||
become_user: "{{ solana_user }}" | ||
environment: | ||
PATH: "{{ solana_home }}/.local/share/solana/install/active_release/bin" | ||
tags: | ||
- cli.update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters