-
Notifications
You must be signed in to change notification settings - Fork 4
Quality of Life Updates #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,108 @@ | ||
| #!/bin/bash | ||
| echo "setting up the validator key" | ||
| # This script builds a Canopy node. | ||
| echo " ____ _ _ _ ___ ______ __" | ||
| echo " / ___| / \ | \ | |/ _ \| _ \ \ / /" | ||
| echo "| | / _ \ | \| | | | | |_) \ V / " | ||
| echo "| |___ / ___ \| |\ | |_| | __/ | | " | ||
| echo " \____/_/ \_\_| \_|\___/|_| |_| " | ||
| echo | ||
| echo "Welcome to Canopy Setup!" | ||
| echo | ||
|
|
||
| CONFIG_FILE=setup.conf | ||
|
|
||
| # Default canopy branch to build, can be overridden in config file | ||
| BRANCH=beta-0.1.3 | ||
ezeike marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Function to show current setup configuration | ||
| show_config() { | ||
| echo "Loaded setup configuration:" | ||
| echo | ||
| echo "SETUP_TYPE: $SETUP_TYPE" | ||
| echo "DOMAIN: $DOMAIN" | ||
| echo "ACME_EMAIL: $ACME_EMAIL" | ||
| echo "BRANCH: $BRANCH" | ||
| echo | ||
| } | ||
|
|
||
| # Function to save config to a file | ||
| save_config() { | ||
|
||
| echo "SETUP_TYPE=${SETUP_TYPE}" > "${CONFIG_FILE}" | ||
| echo "DOMAIN=${DOMAIN}" >> "${CONFIG_FILE}" | ||
| echo "ACME_EMAIL=${ACME_EMAIL}" >> "${CONFIG_FILE}" | ||
| echo "BRANCH=${BRANCH}" >> "${CONFIG_FILE}" | ||
| echo "Setup configuration saved to ${CONFIG_FILE}" | ||
| } | ||
| # Function to load config from a file | ||
| load_config() { | ||
| config_file="${CONFIG_FILE}" | ||
| if [[ -f "${config_file}" ]]; then | ||
| source "${config_file}" | ||
| else | ||
| echo "Config file ${config_file} not found" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| if [[ -f "$CONFIG_FILE" ]]; then | ||
| should_load_config() { | ||
| # Auto-load if AUTOLOAD is present | ||
| if grep -q "AUTOLOAD=yes\|AUTOLOAD=true" $CONFIG_FILE; then | ||
| return 0 | ||
| fi | ||
| # Ask user for confirmation | ||
| read -p "Load previous setup configuration? (Y/n): " LOAD_CONFIG | ||
| echo | ||
| [[ "$LOAD_CONFIG" != "n" && "$LOAD_CONFIG" != "N" ]] | ||
| } | ||
| if should_load_config; then | ||
| load_config | ||
| show_config | ||
| fi | ||
| fi | ||
|
|
||
| # Function to read SETUP, DOMAIN and ACME_EMAIL configuration options from user | ||
| read_variables() { | ||
| # Ask user for setup type | ||
| echo "Please select setup type:" | ||
| echo "1) simple (only contains the node containers)" | ||
| echo "2) full (contains the node containers and the monitoring stack)" | ||
| read -p "Enter your choice (1 or 2): " SETUP_CHOICE | ||
| # Validate and set SETUP | ||
| while [[ "$SETUP_CHOICE" != "1" && "$SETUP_CHOICE" != "2" ]]; do | ||
| echo "Invalid choice. Please enter 1 for simple or 2 for full." | ||
| read -p "Enter your choice (1 or 2): " SETUP_CHOICE | ||
| done | ||
| if [[ "$SETUP_CHOICE" == "1" ]]; then | ||
| SETUP_TYPE="simple" | ||
| else | ||
| SETUP_TYPE="full" | ||
| fi | ||
| # Ask for domain input | ||
| read -p "Please enter the domain [default: localhost]: " DOMAIN | ||
| if [[ -z "$DOMAIN" ]]; then | ||
| DOMAIN="localhost" | ||
| fi | ||
| # Ask for email input | ||
| read -p "Please enter email to validate the domain against [default: [email protected]]: " ACME_EMAIL | ||
| if [[ -z "$ACME_EMAIL" ]]; then | ||
| ACME_EMAIL="[email protected]" | ||
| fi | ||
| } | ||
|
|
||
| # Prompt user for variables if SETUP_TYPE is not present | ||
| if [[ -z "$SETUP_TYPE" ]]; then | ||
| # Read variables from user | ||
| read_variables | ||
| # Save them to $CONFIG_FILE | ||
| save_config | ||
| fi | ||
|
|
||
| # Remove any previous canopy-config container still around | ||
| docker stop canopy-config > /dev/null 2>&1 | ||
| docker rm canopy-config > /dev/null 2>&1 | ||
|
|
||
| echo "Setting up the validator key" | ||
| docker pull canopynetwork/canopy && \ | ||
| docker run --user root -it -p 50000:50000 -p 50001:50001 -p 50002:50002 -p 50003:50003 -p 9001:9001 --name canopy-config --volume ${PWD}/canopy_data/node1/:/root/.canopy/ canopynetwork/canopy && \ | ||
| docker stop canopy-config && docker rm canopy-config && \ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add an example of this file in the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do if we like this approach.