Skip to main content

DMRHub Server Installation

My server is created using an LXC on ProxMox based on Debian 12. The specs are as follows:

  • Disk Size 10G
  • RAM 4G
  • CPU 2 Cores

These are the steps I took to get a server up and running. The installation I loosely followed is on the GitHub Deployment Guide. Ensure the Debian installation is up to date before proceeding ( apt update && apt upgrade -y).

Install PostgreSQL

apt install postgresql postgresql-contrib -y

After it installs, ensure it's enabled:

systemctl enable postgresql
Create Database & User
su -postgres
# This will change you to the appropriate account, next open the psql prompt:
psql

Be sure to change the database name and username, including the password to suit your needs! The following commands should be run one by one, getting the correct response telling you they were created after each. I've updated the commands below to ensure UTF8 is used, as that was not specified in the docs, which caused a launch failure after restarting the server and discovering UTF8 was required!

CREATE DATABASE dmr WITH OWNER dmr ENCODING 'UTF8' TEMPLATE template0;
CREATE USER dmr WITH ENCRYPTED PASSWORD 'MyStrongAFp@$$w0rd';
GRANT ALL PRIVILEGES ON DATABASE dmr TO dmr;
\c dmr
GRANT ALL ON schema public TO dmr;
\q

Something I discovered later on, I needed to ensure the schema stuff was correctly applied, so I ran these following commands while still in the SQL prompt (I know my directions above include that, but for some reason it didn't stick). Run these one by one:

GRANT USAGE ON SCHEMA public TO dmr;
GRANT CREATE ON SCHEMA public TO dmr;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dmr;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dmr;

Install Redis Server

Get the prerequisite stuff set up first with the following:

apt install software-properties-common apt-transport-https curl ca-certificates -y

Using the APT Debian repository, install Redis:

apt install redis -y

With Redis installed, check it's all good with some verification:

apt-cache policy redis
#
# The command above should show you something like this, and if so, you are good:
#
redis:
  Installed: 5:7.0.15-1~deb12u1
  Candidate: 5:7.0.15-1~deb12u1
  Version table:
 *** 5:7.0.15-1~deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        500 http://security.debian.org bookworm-security/main amd64 Packages
        100 /var/lib/dpkg/status

Activate Redis:

systemctl enable redis-server --now

By default, just for notes and general information, Redis listens on port 6379. You can verify that with ps -ef | grep redis if you want to make sure. You can also enter the Redis CLI by redis-cli, and ping it with ping.

Something else I noticed (later down this guide) is in the environment variables, you can set  the Redis password. Now, I am not sure if one is set by default after installation, but what I found online is you can set yours (as there doesn't seem to be a default set already) by editing the conf file. Here is what I did:

cd /etc/redis
nano redis.conf
# Use your own password! - I just added it under a section near the top
requirepass yourSecurePassword
# Save the file and restart redis server:
systemctl restart redis-server

Install DMRHub

This is where things got interesting, as I am mostly an idiot. I absolutely deplore Docker (save the comments for another day please). That said, multiple binary releases are available for use without Docker. Here are the steps I took; there be dragons.

Per the linked deployment guide above, if not using docker: 

A system user needs to be created to securely run DMRHub and the environment variables need to be placed in a file for SystemD to read and set for DMRHub.

So here are the commands they provided, which I followed, one by one (make sure you are your root user, execute quit many times until you ensure you are at your root@user: prompt!)

mkdir /etc/dmrhub
groupadd --system dmrhub
useradd --home-dir /etc/dmrhub --no-create-home --no-user-group --system --shell /sbin/nologin dmrhub
chown dmrhub:dmrhub /etc/dmrhub
chmod 770 /etc/dmrhub
# And then
mkdir /var/log/DMRHub
chown dmrhub:dmrhub /var/log/DMRHub
chmod 755 /var/log/DMRHub

I'm not exactly sure where I should have downloaded the binary release, or exactly where to put it, but once all of those commands above were run, I moved into the /etc/dmrhub directory:

cd /etc/dmrhub
# Don't forget to chech the release version, and adjust the command below!
wget https://github.com/USA-RedDragon/DMRHub/releases/download/v1.0.60/DMRHub_1.0.60_linux_amd64.tar.gz 
tar -xzf DMRHub_1.0.60_linux_amd64.tar.gz

With that now extracted, we need to set the environment variables. The following command will write the contents to the env file:

cat <<EOF | tee /etc/dmrhub/env
LISTEN_ADDR=0.0.0.0
...
EOF

Now that the file is created, we need to set the appropriate file permissions as follows:

chown dmrhub:dmrhub /etc/dmrhub/env
chmod 660 /etc/dmrhub/env

So what that did was create the env file, with the LISTEN_ADDR in it for us, and update the file permissions. Reading around in the deployment guide, there are other environment variables that should be set, which wasn't very clear (or I am just that dumb). With that, here is a link to the list of environment variables to add to that file we just created. Add them to that env file using your favorite CLI editor, like nano: 

To add these, edit the env file with your favorite CLI editor (like nano): nano env and here is what I have set. There are other variables, I haven't dug into them, but I think what I have below will suffice for now:

LISTEN_ADDR=0.0.0.0
DMR_PORT=62031
HTTP_PORT=3005
REDIS_HOST=localhost:6379
REDIS_PASSWORD=useYourOwnPassword!
PG_HOST=localhost
PG_PORT=5432
PG_USER=dmrhub
PG_PASSWORD=useYourOwnPassword!
PG_DATABASE=dmrhub
SECRET=YourOwnPassword!
PASSWORD_SALT=YourOwnPassword!
CORS_HOSTS=http://localhost:$HTTP_PORT,http://127.0.0.1:$HTTP_PORT,https://mysub.domain.net
INIT_ADMIN_USER_PASSWORD=useYourOwnPassword!
TRUSTED_PROXIES=http://192.168.0.000,http://192.168.0.000 #add your own proxy IPs here!
NETWORK_NAME=MyCoolName #This sets the app's name
ALLOW_SCRAPING=NO

Next we need to copy DMRHub into the system path so it can be executed. I ran into an issue when executing the following, as there was nothing in /bin/DMRHub/ (everything was in /etc/DMRHub/. Here are the guide's exact directions:

sudo mv bin/DMRHub /usr/local/bin/
sudo chmod a+x /usr/local/bin/DMRHub

This failed for me, as stated above. So what I did was copy DMRHub from /etc/DMRHub/ to /usr/local/bin/

cp /etc/DMRHub/DMRHub /usr/local/bin/
# With the executable now in bin, I did the chmod on the file:
chmod a+x /usr/local/bin/DMRHub

Not knowing if that's the correct thing to do, I continued on with the deployment guide...

Install SystemD Unit File

The developer provides a SystemD unit file, which can be found here. I copied the contents, and pasted it into /etc/systemd/system and activated it, per the instructions.

nano /etc/systemd/system/dmrhub.service
# Paste the file contents in this new file you just created, then save it, close it!
systemtcl daemon-reload
systemctl enable --now dmrhub.service

Troubleshooting

I ran into some issues with getting things to work, the dmrhub.service failed to start properly, and I was able to figure out that it was my PSQL database (username/password/schema) causing the problem. Starting the service above with systemctl start dmrhub.service showed the exit (failed), and I was able to quickly view the problem by running journalctl -f -u dmrhub.service. According to the documentation, the service log can be found here, if you would rather: /var/log/DMRHub/DMRHub.error.log.

After correcting my DB issues, I simply restarted the service with systemctl restart dmrhub.service and got a green light on all. So I guess that's it, its installed and working now.