-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Install script] Support multiple networks #941
base: main
Are you sure you want to change the base?
Conversation
sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" \$HOME/.poktroll/config/config.toml | ||
sed -i -e "s|^external_address *=.*|external_address = \"$EXTERNAL_IP:26656\"|" \$HOME/.poktroll/config/config.toml |
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.
[linter-name (fail-on-found)] reported by reviewdog 🐶
sed -i -e "s|^external_address =.|external_address = "$EXTERNAL_IP:26656"|" $HOME/.poktroll/config/config.toml
# Detect external IP address | ||
EXTERNAL_IP=$(curl -s https://api.ipify.org) | ||
print_color $YELLOW "Detected external IP address: $EXTERNAL_IP" | ||
read -p "Is this your correct external IP address? (Y/n): " confirm_ip |
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.
Is anyone going to say no? Considering just commenting this out altogether
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.
I suspect there might be cases when the discovered IP address is not correct and requires adjustment.
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.
Very nice bash
ing sir! 😎 💥 Super easy to read. 🤩
# DEV_NOTE: For testing purposes, you can change the branch name before merging to master. | ||
GENESIS_BRANCH="master" |
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.
# DEV_NOTE: For testing purposes, you can change the branch name before merging to master. | |
GENESIS_BRANCH="master" | |
# DEV_NOTE: For testing purposes, you can change the branch name before merging to master. | |
POCKET_NETWORK_GENESIS_BRANCH="master" |
read -p "Enter the chain-id (default: poktroll): " CHAIN_ID | ||
CHAIN_ID=${CHAIN_ID:-"poktroll"} | ||
# Update URLs to use the branch constant | ||
BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${GENESIS_BRANCH}/shannon/$NETWORK" |
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.
BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${GENESIS_BRANCH}/shannon/$NETWORK" | |
BASE_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/${POCKET_NETWORK_GENESIS_BRANCH}/shannon/$NETWORK" |
1) NETWORK="testnet-alpha" ;; | ||
2) NETWORK="testnet-beta" ;; | ||
3) NETWORK="mainnet" ;; | ||
*) print_color $RED "Invalid choice. Exiting."; exit 1 ;; |
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.
*) print_color $RED "Invalid choice. Exiting."; exit 1 ;; | |
*) print_color $RED "Invalid network choice. Exiting."; exit 1 ;; |
*) print_color $RED "Invalid choice. Exiting."; exit 1 ;; | ||
esac | ||
|
||
print_color $GREEN "You have chosen to install the $NETWORK network." |
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.
print_color $GREEN "You have chosen to install the $NETWORK network." | |
print_color $GREEN "Installing the $NETWORK network." |
if [ \$? -ne 0 ]; then | ||
echo "Failed to download or extract binary" | ||
exit 1 | ||
fi | ||
chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld | ||
ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld |
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.
Unrelated to these changes and likely out of scope but as this is the first time I'm reading this file, forgive my curiosity. 😅
ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld | |
ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/.local/bin/poktrolld |
My understanding is that this aligns with the XDG user directory specification, which has wide adoption [1, 2].
I'm noticing that we seem to be creating this $HOME/bin
directory. I'm wondering if it would be worth using an existing & conventional directory which is already included in the $PATH on most modern distros (except alpine, according to chatGPT). We could then remove the append to the $HOME/.profile
:
- echo 'export PATH=\$HOME/bin:\$PATH' >> \$HOME/.profile
[1] https://unix.stackexchange.com/questions/316765/which-distributions-have-home-local-bin-in-path
[2] https://askubuntu.com/questions/14535/whats-the-local-folder-for-in-my-home-directory
configure_ufw() { | ||
if command -v ufw &> /dev/null; then | ||
print_color $YELLOW "ufw is installed." | ||
read -p "Do you want to open port 26656 for p2p communication? (Y/n): " open_port |
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.
Wdyt about printing a line about how to undo this in the future?
ufw allow 26656 | ||
print_color $GREEN "Port 26656 opened successfully." | ||
else | ||
print_color $YELLOW "Port 26656 not opened." |
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.
Does landing in this conditional branch really guarantee that the port is not open? If not, I would suggest we rephrase the message to be more precise (e.g. "Firewall rules not modified"
).
print_color $YELLOW "ufw is installed." | ||
read -p "Do you want to open port 26656 for p2p communication? (Y/n): " open_port | ||
if [[ $open_port =~ ^[Yy] ]]; then | ||
ufw allow 26656 |
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.
I think we need to check the existing rules and only add one if it's not already present; otherwise, it seems that duplicate rules accumulate. See this chatGPT convo.
print_color $YELLOW "Port 26656 not opened." | ||
fi | ||
else | ||
print_color $YELLOW "ufw is not installed. Skipping port configuration." |
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.
print_color $YELLOW "ufw is not installed. Skipping port configuration." | |
print_color $YELLOW "ufw is not installed. Skipping firewall configuration." |
Summary
Allows to support multiple networks in the installation script.
Issue
Type of change
Select one or more from the following:
consensus-breaking
label if so. See [Infra] Automatically add theconsensus-breaking
label #791 for detailsTesting
make docusaurus_start
; only needed if you make doc changesmake go_develop_and_test
make test_e2e
devnet-test-e2e
label to the PR.Sanity Checklist