Skip to content

Instantly share code, notes, and snippets.

@wschwab
Last active October 18, 2023 16:56
Show Gist options
  • Save wschwab/991db1b5a9fcb05d623761ced7ce6cd7 to your computer and use it in GitHub Desktop.
Save wschwab/991db1b5a9fcb05d623761ced7ce6cd7 to your computer and use it in GitHub Desktop.
Fresh Erigon install (includes Go installation)
# modified from https://gist.github.com/quickchase/c3d0c53213b16af6b9e4c509eb94fc4b
# use at your own risk since I'm not very experienced at this
# ASSUMING YOU ARE ROOT
# This script assumes prior usage of the Lighthouse install script
# It assumes that you've already created the user and activated the firewall, etc.
# Install needed stuff and useful stuff
apt update && apt install -y git build-essential
# Open Erigon ports - ufw installed with Lighthouse
ufw allow 30303 # peering
ufw allow 42069 # Snap Sync (Bittorrent)
echo "y" | ufw enable
# Install Go
VERSION='1.21.3'
wget https://golang.org/dl/go${VERSION}.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go${VERSION}.linux-amd64.tar.gz
ln -s /usr/local/go/bin/go /usr/local/bin/go
rm go${VERSION}.linux-amd64.tar.gz
# Username to install under
USERNAME=eth
# Clone Erigon
cd /home/${USERNAME}/
sudo -u ${USERNAME} mkdir github
cd github/
sudo -u ${USERNAME} git clone https://github.com/ledgerwatch/erigon.git
cd erigon/
# Checkout version we want to build
sudo -u ${USERNAME} git checkout v2022.08.01
# Build it
sudo -u ${USERNAME} make
# Copy binary to /usr/local/bin
cp build/bin/erigon /usr/local/bin/
# Generate systemd service file
cat << EOF > /etc/systemd/system/erigon.service
[Unit]
Description=erigon
[Service]
WorkingDirectory=/home/${USERNAME}
ExecStart=/usr/local/bin/erigon \\
--datadir="/home/${USERNAME}/datadir" \\
--chain="mainnet" \\
--snapshots="true" \\
--authrpc.jwtsecret="/home/${USERNAME}/jwtsecret" \\
--http \\
--http.addr="0.0.0.0" \\
--http.compression \\
--http.vhosts="*" \\
--http.corsdomain="*" \\
--http.api="eth,admin,debug,net,trace,web3,erigon" \\
--ws \\
--ws.compression \\
--rpc.gascap="600000000"
User=${USERNAME}
Group=${USERNAME}
RestartKillSignal=SIGINT
Restart=always
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target
EOF
# Enable and start Erigon service
systemctl enable erigon.service
systemctl start erigon.service
# Use this command to tail the logs
# journalctl -fu erigon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment