Skip to content

Instantly share code, notes, and snippets.

@rigwild
Last active January 11, 2021 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rigwild/fd10669144860f90e12358e461244756 to your computer and use it in GitHub Desktop.
Save rigwild/fd10669144860f90e12358e461244756 to your computer and use it in GitHub Desktop.
Install a UNS node on a fresh new system (Ubuntu). Run with a normal user with sudo permission - See https://uns.network/
# Run the following as a normal user with sudo permission
bash -c '
wget -q https://gist.githubusercontent.com/rigwild/fd10669144860f90e12358e461244756/raw/65f18b4a004ddf79fb17d31c2329ae7362e8bf0c/install_uns_node_script.sh
chmod u+x install_uns_node_script.sh
./install_uns_node_script.sh
'
# See https://gist.github.com/rigwild/fd10669144860f90e12358e461244756
# Check if script is ran by root user -> exit
if [[ $EUID -eq 0 ]]; then echo "This script should not be ran by root!"; exit 1; fi
##############
# VM INSTALL #
##############
sudo apt update
# Upgrade and skip the GUI popups - See https://askubuntu.com/questions/146921/how-do-i-apt-get-y-dist-upgrade-without-a-grub-config-prompt
sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install linux-generic
# Install common packages
sudo apt install \
build-essential \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
# Install docker
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y
# Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -aG docker $USER
sudo service docker start
####################
# UNS NODE INSTALL #
####################
mkdir ~/uns_node
cd ~/uns_node
# Create UNS node docker compose file
echo 'version: "2"
services:
postgres:
image: "postgres:11-alpine"
container_name: postgres-livenet
restart: always
#ports:
#- "127.0.0.1:5432:5432" # uncomment this if you want to connect locally on DB
volumes:
- "postgres:/var/lib/postgresql/data"
networks:
- core
environment:
POSTGRES_DB: uns_livenet # Must match with CORE_DB_DATABASE below
POSTGRES_USER: uns # Must match with CORE_DB_USERNAME below
POSTGRES_PASSWORD: passwordQHZDHdzdZ5d455zzQ
uns:
image: universalnamesystem/core:livenet
container_name: uns-livenet # Can be anything
restart: always
environment:
UNS_NET: livenet
FORGER_SECRET:
CORE_DB_HOST: postgres
CORE_DB_PORT: 5432
CORE_DB_DATABASE: uns_livenet
CORE_DB_USERNAME: uns
CORE_DB_PASSWORD: passwordQHZDHdzdZ5d455zzQ
ports:
- "4001:4001"
#- "4003:4003"
cap_add:
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
networks:
- core
tty: true
links:
- postgres
depends_on:
- postgres
volumes:
postgres:
networks:
core:' > docker-compose.yml
# Create multiple useful scripts
echo "docker-compose up --build -d" > start_node.sh
echo "docker-compose stop" > stop_node.sh
echo "docker-compose down -v" > clear_node.sh
echo "docker-compose logs uns | head -n 100 | grep \"uns-core \"" > node_version.sh
echo "docker-compose logs --tail 50" > show_logs.sh
echo "while sleep 1; do ./show_logs.sh; done" > repeat_show_logs.sh
echo "docker-compose pull && docker-compose stop && docker-compose up -d --build" > update_node.sh
echo "docker-compose pull && docker-compose down -v && docker-compose up -d --build" > update_node_destroy.sh
echo 'read -p "Enter your UNS forger passphrase (empty for a relay) [Default: \"\"]: " UNS_TEMP_PASSPHRASE
sed -i "s/FORGER_SECRET:.*/FORGER_SECRET: $UNS_TEMP_PASSPHRASE/g" docker-compose.yml' > update_forger_passphrase.sh
chmod u+x *.sh
echo ""
echo "Use the script \"node_version.sh\" to get the UNS node version."
echo "Use the script \"start_node.sh\" to start the UNS node."
echo "Use the script \"stop_node.sh\" to stop the UNS node."
echo "Use the script \"repeat_show_logs.sh\" to get the 50 last docker logs lines every seconds."
echo "Use the script \"update_node.sh\" to update the UNS node without destroying the container."
echo "Use the script \"update_node_destroy.sh\" to update the UNS node and fully reset its container."
echo "Use the script \"clear_node.sh\" to clear the UNS node container."
echo "Use the script \"update_forger_passphrase.sh\" to update the UNS forger secret."
echo ""
echo "UNS node is ready, scripts are installed at \"~/uns_node\", use \"start_node.sh\" to start the UNS node!"
echo "*** You must log out and log back in to finish the Docker install!!!***"
echo ""
./update_forger_passphrase.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment