Last active
November 22, 2021 14:07
-
-
Save thephez/f401d72d43b51b54601e2ab18349f7cf to your computer and use it in GitHub Desktop.
Vultr boot startup script - mn-bootstrap prep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Based on instructions from | |
# https://docs.dash.org/en/stable/masternodes/setup-testnet.html | |
# | |
# See https://www.vultr.com/docs/vultr-startup-scripts-quickstart-guide | |
# for details of using Vultr startup scripts | |
# Add new user | |
USERNAME=yourusernamehere # Username to create | |
# Update packages | |
apt-get update && apt-get -y upgrade | |
# Add new user | |
adduser --disabled-password --gecos "" $USERNAME | |
echo "NOTE: Must set password via 'passwd $USERNAME' as root" | |
usermod -aG sudo $USERNAME | |
mkdir -p /home/$USERNAME/.ssh | |
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh | |
# Copy SSH key to created user and set ownership | |
# NOTE: For this to work you must add SSH Keys in my.vultr.com | |
# See https://www.vultr.com/docs/deploy-a-new-server-with-an-ssh-key | |
cp /root/.ssh/authorized_keys /home/$USERNAME/.ssh/authorized_keys | |
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh/ | |
# Setup firewall | |
ufw allow ssh/tcp | |
ufw limit ssh/tcp | |
ufw allow 19999/tcp | |
ufw allow 26656/tcp | |
ufw allow 3000/tcp | |
ufw allow 3010/tcp | |
ufw allow 20001/tcp | |
ufw allow 20101/tcp | |
ufw allow 20201/tcp | |
ufw allow 20301/tcp | |
ufw logging on | |
ufw enable | |
# Setup swap | |
fallocate -l 4G /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
grep -qxF '/swapfile none swap sw 0 0' /etc/fstab || echo '/swapfile none swap sw 0 0' >> /etc/fstab | |
# Fail2ban | |
#apt install fail2ban | |
# mn-bootstrap dependency install | |
apt install -y git build-essential | |
apt install -y apt-transport-https ca-certificates curl gnupg lsb-release | |
## Node LTS | |
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash - | |
sudo apt install -y nodejs | |
## Remove packaged version of Docker | |
apt-get remove docker docker.io containerd runc -y | |
## Install current Docker | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | |
bionic stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
apt-get update | |
apt-get install -y docker-ce docker-ce-cli containerd.io | |
## Docker-compose install | |
curl -L "https://github.com/docker/compose/releases/download/1.28.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
# Add user to docker group | |
usermod -aG docker $USERNAME | |
newgrp docker | |
systemctl enable docker | |
systemctl enable containerd | |
# Perform actions as user | |
su $USERNAME | |
HOME=/home/$USERNAME | |
cd /home/$USERNAME | |
## Install mn-bootstrap (defaults to dev branch) | |
git clone https://github.com/dashevo/mn-bootstrap.git | |
cd mn-bootstrap | |
git checkout v0.19-dev | |
# npm ci | |
# sudo npm link | |
## Fix folder/file ownership | |
chown -R $USERNAME:$USERNAME /home/$USERNAME/mn-bootstrap* | |
# After logging in, run this to start local network: | |
# bin/mn setup local --node-count=3 -v # verbose | |
# or | |
# bin/mn setup local --node-count=3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment