UNS node management useful script collection

Here are some commands and scripts I use to manage my UNS nodes. Share yours if you have some useful stuff! :face_with_hand_over_mouth:

Node management

Check UNS node version

docker-compose logs uns | head -n 100 | grep "uns-core "

Upgrade UNS node version

docker-compose pull && docker-compose stop && docker-compose up -d --build --remove-orphans

Change the forger secret

Update your docker-compose.yml file with a new forger secret.

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

Quickly spin up a fresh new UNS node (Relay or Forger)

This script will install all you need to quickly run a new Relay or Forger node on a new fresh system.
You should run this script as a normal user, not root!
Your user should be in the sudoers file though, which is the default on Ubuntu (see How to create a sudo user if not on Ubuntu).

Check the script here: https://gist.github.com/rigwild/fd10669144860f90e12358e461244756

Note: Running this is safe, the downloaded scripts are from a git commit, you will always get the same install script (always check before running a script from the internet anyway).

# 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
'

Logging

Show the last 100 lines of a node’s logs

docker-compose logs --tail 100

Disk space management

Check disk usage

You can use df to check your global used/available disk space.

df -h

Check UNS node database disk usage

Check the size of the postgres database (currently sitting at 3.3GB).

docker exec -it postgres-livenet bash
# <uns_livenet>: CORE_DB_DATABASE in your `docker-compose.yml` file
psql -U uns -d uns_livenet 
\l+
                                                                List of databases
    Name     | Owner | Encoding |  Collate   |   Ctype    | Access privileges |  Size   | Tablespace |                Description
-------------+-------+----------+------------+------------+-------------------+---------+------------+--------------------------------------------
 postgres    | uns   | UTF8     | en_US.utf8 | en_US.utf8 |                   | 7717 kB | pg_default | default administrative connection database
 template0   | uns   | UTF8     | en_US.utf8 | en_US.utf8 | =c/uns           +| 7577 kB | pg_default | unmodifiable empty database
             |       |          |            |            | uns=CTc/uns       |         |            |
 template1   | uns   | UTF8     | en_US.utf8 | en_US.utf8 | =c/uns           +| 7577 kB | pg_default | default template for new databases
             |       |          |            |            | uns=CTc/uns       |         |            |
 uns_livenet | uns   | UTF8     | en_US.utf8 | en_US.utf8 |                   | 3351 MB | pg_default |
(4 rows)

or directly by checking the size with Docker

docker system df --verbose
Images space usage:

REPOSITORY                 TAG         IMAGE ID       CREATED       SIZE      SHARED SIZE   UNIQUE SIZE   CONTAINERS
universalnamesystem/core   livenet     3f4de23b97d9   3 days ago    576.8MB   0B            576.8MB       1
postgres                   11-alpine   24747a501d54   12 days ago   156.3MB   0B            156.3MB       1

Containers space usage:

CONTAINER ID   IMAGE                              COMMAND                  LOCAL VOLUMES   SIZE      CREATED          STATUS          NAMES
24f097423070   universalnamesystem/core:livenet   "/sbin/tini -- /opt/…"   0               70.5kB    31 minutes ago   Up 30 minutes   uns-livenet
e768401cf462   postgres:11-alpine                 "docker-entrypoint.s…"   1               1.17kB    31 minutes ago   Up 30 minutes   postgres-livenet

Local Volumes space usage:

VOLUME NAME         LINKS     SIZE
uns_node_postgres   1         3.623GB

Build cache usage: 0B

CACHE ID   CACHE TYPE   SIZE      CREATED   LAST USED   USAGE     SHARED

Free up some Docker unused disk space

Free up some disk space by clearing your docker images that are not tagged (old UNS node/postgres versions), this can clear a lot of space.

docker rmi $(docker images -a --filter=dangling=true -q)
7 Likes

Thank you for this summary!

very usefull. thanks @rigwild

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.