Skip to content

Instantly share code, notes, and snippets.

@DawnBreather
Created May 13, 2024 20:08
Show Gist options
  • Save DawnBreather/3b33e8b26897e333422dc4f9ed8adb87 to your computer and use it in GitHub Desktop.
Save DawnBreather/3b33e8b26897e333422dc4f9ed8adb87 to your computer and use it in GitHub Desktop.
install.solv[object Object]
#!/bin/bash
set -e
# Constants and configurable variables
export NODE_VERSION="20.11.1"
# This ensures the entire script is downloaded
{
set -e # exit immediately if a command exits with a non-zero status
usage() {
cat 1>&2 <<EOF
Custom Install Script
Creates a new user 'solv', adds the user to the sudo group, logs in as 'solv',
installs pnpm, node $NODE_VERSION, and sets it as the global version.
Additionally, installs the @epics-dao/solv package globally.
USAGE:
custom-install-script.sh [FLAGS]
FLAGS:
-h, --help Prints help information
EOF
}
tune_system_for_solana(){
# Skip execution if the system is already tuned
if [ -f /etc/sysctl.d/21-solana-validator.conf ] && [ -f /etc/security/limits.d/90-solana-nofiles.conf ]; then
echo "System already tuned for Solana, skipping..."
return
fi
echo -e "\033[0;32mTuning system...\033[0m"
sudo bash -c "cat >/etc/sysctl.d/21-solana-validator.conf <<EOF
# Increase UDP buffer sizes
net.core.rmem_default = 134217728
net.core.rmem_max = 134217728
net.core.wmem_default = 134217728
net.core.wmem_max = 134217728
# Increase memory mapped files limit
vm.max_map_count = 1000000
# Increase number of allowed open file descriptors
fs.nr_open = 1000000
EOF"
sudo bash -c "cat >/etc/security/limits.d/90-solana-nofiles.conf <<EOF
# Increase process file descriptor count limit
* - nofile 1000000
EOF"
echo -e "\033[0;32mDone!\033[0m"
echo -e "Restart the server with the command: \033[0;32mreboot now\033[0m"
}
# create_user() {
# if getent passwd solv >/dev/null 2>&1; then
# echo "User 'solv' already exists, skipping..."
# else
# echo "Creating user 'solv'..."
# sudo useradd -m -s /bin/bash solv
# sudo usermod -aG sudo solv
# fi
# }
setup_firewall() {
echo "Configuring firewall"
echo "yes" | sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 53
sudo ufw allow 8899
sudo ufw allow 8899/udp
sudo ufw allow 8000:8898/udp
sudo ufw allow 8000:8898/tcp
sudo ufw allow 8900:10000/tcp
sudo ufw allow 8900:10000/udp
sudo ufw reload
}
install_rustup() {
# sudo su - solv <<EOF_SOLV
set -e
echo "Installing rustup..."
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo 'export PATH="\$HOME/.cargo/env:\$PATH"' >> ~/.profile
source ~/.cargo/env
rustup component add rustfmt
rustup update
# EOF_SOLV
}
install_pnpm_and_packages() {
# Install packages required for building native dependencies
sudo apt update
sudo apt install libudev-dev build-essential libssl-dev pkg-config -y
# sudo su - solv <<EOF_SOLV
set -e
echo "Installing pnpm..."
curl -fsSL https://get.pnpm.io/install.sh | sh -
echo "Setting pnpm environment variables..."
PNPM_HOME="/home/solv/.local/share/pnpm"
export PNPM_HOME
PATH="\$PNPM_HOME:\$PATH"
export PATH
echo "Sourcing ~/.bashrc in case it's needed..."
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
echo "Installing node $NODE_VERSION..."
pnpm env use $NODE_VERSION --global
echo "Installing @epics-dao/solv..."
pnpm add -g @epics-dao/solv
echo "Installing pm2..."
pnpm add -g pm2
echo "Sourcing ~/.bashrc in case it's needed..."
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
# Use the full path to solv if it's not found
echo "Setting up Solana CLI..."
/home/solv/.local/share/pnpm/solv i
/home/solv/.local/share/pnpm/solv get aa
# Install Solana Foundation Delegation Program CLI
cargo install solana-foundation-delegation-program-cli
solana-foundation-delegation-program --version
# Generate Solana keys
source ~/.profile
#solv setup --key
solv setup
# EOF_SOLV
}
main() {
for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
*)
;;
esac
done
tune_system_for_solana
# create_user
setup_firewall
install_rustup
install_pnpm_and_packages
# sudo su - solv
}
main "$@"
} # this ensures the entire script is downloaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment