forked from nodesbond/penumbra_guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
penumbra_nodes_bond_installer.sh
149 lines (119 loc) · 4.38 KB
/
penumbra_nodes_bond_installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
apt-get install -y git git-lfs tmux bc
# Check if running interactively
if [ -z "$PS1" ]; then
echo "Setting default PS1 as the script is not running interactively."
export PS1='\h:\w\$ '
fi
# Temporarily change the home directory to avoid sourcing .bashrc
ORIGINAL_HOME=$HOME
export HOME=/tmp
# Author: nodes.bond
# Penumbra Version: v0.80.7
# Go Version: 1.21.1
# Cometbft Version: v0.37.5
set -euo pipefail
# Check Ubuntu Version
UBUNTU_VERSION=$(lsb_release -sr)
if (( $(echo "$UBUNTU_VERSION < 22" | bc -l) )); then
echo "This script requires Ubuntu version 22 or higher. Your version is $UBUNTU_VERSION."
exit 1
fi
# Set default GOPATH, GOROOT and update PATH
export GOPATH=${GOPATH:-"$HOME/go"}
export GOROOT=${GOROOT:-"/usr/local/go"}
export PATH="$PATH:$GOROOT/bin:$GOPATH/bin"
# Remove previous versions of Penumbra and related modules
echo "Removing old versions of Penumbra and related modules..."
sudo rm -rf /root/penumbra /root/cometbft
# Rename existing Penumbra directory
if [ -d "/root/penumbra" ]; then
mv /root/penumbra /root/penumbra_old
fi
# Explicitly set the tmux temporary directory
export TMUX_TMPDIR="/root/.tmux"
mkdir -p "$TMUX_TMPDIR"
# Ensure the tmux server is running correctly
tmux start-server
# Handle non-empty pcli directory
PCLI_DIR="/root/.local/share/pcli"
if [ -d "$PCLI_DIR" ]; then
if [ "$(ls -A $PCLI_DIR)" ]; then
echo "The pcli directory at $PCLI_DIR is not empty."
echo "Existing contents will be removed to continue with a clean initialization."
rm -rf ${PCLI_DIR:?}/* # Using parameter expansion to avoid catastrophic deletion
fi
fi
# Update package list and install dependencies
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev clang git-lfs tmux libclang-dev curl
sudo apt-get install tmux
# Check and install Go if not present
if ! command -v go > /dev/null; then
echo "Go is not installed. Installing Go..."
wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz
sudo tar -xvf go1.21.1.linux-amd64.tar.gz -C /usr/local
export PATH=$PATH:/usr/local/go/bin
fi
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
# Clone and set up Penumbra
mkdir -p /root/penumbra
cd /root/penumbra
git clone https://github.com/penumbra-zone/penumbra .
git fetch
git checkout v0.80.7
cargo build --release --bin pcli
cargo build --release --bin pd
# Install and set up CometBFT
cd /root
git clone https://github.com/cometbft/cometbft.git
cd cometbft
git checkout v0.37.5
go mod tidy
# Compile the cometbft executable
go build -o cometbft ./cmd/cometbft
# Move the compiled executable to a specific directory inside /root/cometbft if not already there
if [ ! -f /root/cometbft/cometbft ]; then
mv cometbft /root/cometbft/
else
echo "Executable already in place."
fi
# Prepare for node operation
make install
ulimit -n 4096
# Set up node configuration
echo "Enter the name of your node:"
read MY_NODE_NAME
# Attempt to automatically determine the external IP address
IP_ADDRESS=$(curl -4s ifconfig.me)
# If the IP address is empty, prompt the user to enter it manually
if [ -z "$IP_ADDRESS" ]; then
echo "Could not automatically determine the server's IP address."
echo "Please enter your server's external IP address manually:"
read IP_ADDRESS
fi
# Validate the IP address format
if [[ ! $IP_ADDRESS =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid IP address format. Please enter a valid IP address."
exit 1
fi
# Continue with using the IP_ADDRESS in further commands
echo "Using IP address: $IP_ADDRESS"
# Join the Penumbra network
./penumbra/target/release/pd network join --moniker "$MY_NODE_NAME" --external-address "$IP_ADDRESS:26656" http://void.s9.gay:26657
# Handle non-empty pcli directory
PCLI_DIR="/tmp/.local/share/pcli"
if [ -d "$PCLI_DIR" ]; then
if [ "$(ls -A $PCLI_DIR)" ]; then
echo "The pcli directory at $PCLI_DIR is not empty."
echo "Existing contents will be removed to continue with a clean initialization."
rm -rf ${PCLI_DIR:?}/* # Using parameter expansion to avoid catastrophic deletion
fi
fi
echo "export PATH=\$PATH:/root/penumbra/target/release" >> $HOME/.profile
source $HOME/.profile
# Restore original home directory after detaching from TMUX
export HOME=$ORIGINAL_HOME
echo "Installation is complete. Run the tmux window to start the node."