You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
11 KiB

---
title: MMDVM hotspot on Archlinux
10 months ago
summary: I wrote down the installation of a forked DStarGateway with a slim
dashboard based on Javascript on a Raspberry Pi 2.
10 months ago
date: 2024-01-29T09:41:00+0100
10 months ago
#lastmod:
categories:
- amateur-radio
tags:
- archlinux
- dstar
- hotspot
- linux
- mmdvm
- raspberry-pi
# showBreadcrumbs: true
# showDate: false
# showReadingTime: false
# showWordCount: false
# showPagination: false
# feed_exclude: true
# site_exclude: true
# some help
#
# highlighting with highlights
#
# use table, as inline creates a padding around
# and it pushes the text more to the right side (end of screen)
#
# ~~~html {linenos=table,hl_lines="3-6"}
# ~~~html {linenos=inline,hl_lines="1,3-6"}
draft: true
---
## Installation ala wiki pages
I usually setup any Raspberry Pi without screen and keyboard but I make use of
the [serial console](https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts).
![Raspi 2 with wires connected to GPIO Pins GND, RXD and TXD](setup_console.jpg "I haven't changed a thing of the initial configuration")
### Preparations (microSD card)
Partition the microSD card.
~~~console
$ sudo fdisk /dev/sda
~~~
~~~
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 411647 409600 200M c W95 FAT32 (LBA)
/dev/sda2 411648 15759359 15347712 7.3G 83 Linux
~~~
Format filesystems.
~~~console
$ sudo mkfs.vfat /dev/sda1
$ sudo mkfs.ext4 /dev/sda2
~~~
I am curerntly in `~/mnt`.
~~~console
$ mkdir boot root
$ sudo mount /dev/sda1 boot
$ sudo mount /dev/sda2 root
$ wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
$ sudo bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C root
$ sync
$ sudo mv root/boot/* boot/
$ sudo umount boot root
~~~
So, place the microSD card in the Raspberry Pi and boot it up (with the serial console connected).
### First start
There are the following two users pre-defined:
| Username | Password |
|------------| -----------|
| _root_ | _root_ |
| _alarm_ | _alarm_ |
I prefer my username as _dominic_, so I changed it:
~~~console
# usermod -l dominic -d /home/dominic -m alarm
# groupmod -n dominic alarm
~~~
{{< alert circle-info >}}
The user _alarm_ may come from **A**rch**L**inux **ARM**.
{{< /alert >}}
So the first real thing is upgrading the system. We start as this:
~~~console
# pacman-key --init
# pacman-key --populate archlinuxarm
# pacman -Syu
~~~
Some general system administration tasks as time setup network setup etc...
I'm using NetworkManager on the Raspi so I install it
~~~console
# pacman -S networkmanager
# nmcli device wifi connect {network-ssid} --ask
~~~
Now we may login via ssh.
## Installation of DStarGateway
I prefer compiling as normal user so I login as _dominic_. We will need some packages.
~~~console
$ sudo pacman -S --needed base-devel wget boost man-db gtest
~~~
I hope I got all that we need, if you run into errors, just install the missing ones :wink:
~~~console
$ mkdir git && cd git
$ git clone https://github.com/F4FXL/DStarGateway.git
$ cd DStarGateway
$ make
~~~
This ran for 38 minutes -- I will not forget to add `-j4` the next time :face_with_rolling_eyes:
You would now typically install the files but this is the part that made me stop for a while.
Whatever I was doing, it won't work automated. I'm not a developer, but to me this looks like as
if `make -C` enters the directory before it runs the top-level Makefile so the `export ...` lines
never get executed and the Makefiles in the sub-directories will never know about them. I didn't
want to dive deeper into this and decided to just install the rest by hand.
~~~console
$ sudo make install
~~~
It will break, but at least install the binary files into `/usr/local/bin`. Also install the
hostfiles (will need the program _wget_).
~~~console
$ sudo make newhostfiles
~~~
Copy the systemd unit files to the right directory per hand:
~~~console
$ sudo cp debian/* /usr/lib/systemd/system/
~~~
{{< alert >}}
Inspect them because you may edit some paths.
{{< /alert >}}
Also have a look at the configuration files in `/usr/local/etc/`.
Enable the services, but I don't start them yet (except for a short test) because
the hotspot will connect to the DSTAR reflector but we can't talk or hear anything.
Once they are enabled, they will autostart at the next reboot.
To enable the services:
~~~console
$ sudo systemctl enable dstargateway.service
$ sudo systemctl enable dgwtimeserver.service
~~~
Because the `make install` did not finish before, I have to manually install the
`Data` folder contents (AMBE files, Hostfiles). I could not get this to work the
way it was described in the repository, but I installed them this way:
Move to the `Data` directory and add the following line on top of the file:
~~~make
export DATA_DIR=/usr/local/share/dstargateway.d/
~~~
Then rund `sudo make install` within the `Data` directory again and all should be fine.
## Installation of MMDVMHost
Also this requires special packages, although I think those are for the new
FM features -- that a hotspot won't use at all...
~~~console
$ sudo pacman -S libsamplerate
~~~
~~~console
$ git clone git@github.com:g4klx/MMDVMHost.git
$ cd MMDVMHost
$ make -j4
$ sudo make install-service
~~~
That would fail, but we can do it by hand.
Setup the user _mmdvm_:
~~~console
$ sudo useradd --user-group -M --system mmdvm --shell /bin/false
$ sudo usermod --groups uucp --append mmdvm
~~~
So we run the command one more time:
~~~console
$ sudo make install-service
~~~
Binaries are installed and the systemd unit files too.
Modify the configuration file `/etc/MMDVM.ini`.
Enable the service:
~~~console
$ sudo systemctl daemon-reload
$ sudo systemctl enable mmdvmhost.service
~~~
## Setup the UART
We can't start MMDVMHost right away (well, we can, but it will not work yet).
We need to disable the serial console because we need the UART at the GPIO pins
for our modem hardware.
Disable the service, that accesses the serial console:
~~~console
$ sudo systemctl disable serial-getty@ttyAMA0.service
~~~
Open `/boot/cmdline.txt` and remove `console=serial0,115200` from the line. Save
and reboot.
10 months ago
## Configuration
10 months ago
### DStarGateway
10 months ago
### MMDVMHost
10 months ago
### dgwtimeserver
10 months ago
## Install a dashboard
10 months ago
I will install the [dashboard from John Hays (K7VE)](https://github.com/johnhays/dsgwdashboard)
as my first look at it looked promising (using Javascript (which is executed
on the client and not the server) may reduce the load on the webserver).
[Past installations of dashboards]({{< ref "/posts/2022/26-raspberry-pi-4-64bit-dual-hat-hotspot-without-pi-star" >}})
did usually include a form of request limitation because the many websocket requests
of other dashboards put too much pressure on the small Raspberry Pies :exploding_head:
10 months ago
I will not install this as per instructions, because I don't like when these kind
of applications (simple dashboards for example) have to be run as the _root_ user.
I will therefore create a new user called _dashboard_ as which the "webserver"
(which is a NodeJS application) will run.
10 months ago
10 months ago
We need a few packages for this:
10 months ago
~~~console
10 months ago
$ sudo pacman -S nodejs npm
10 months ago
~~~
10 months ago
Create and impersonate our new user:
10 months ago
10 months ago
~~~console
$ sudo useradd --user-group -m --system dashboard --shell /bin/bash
$ sudo su - dashboard
~~~
10 months ago
10 months ago
Now we are the user _dashboard_ and we will install the dashboard:
10 months ago
~~~console
10 months ago
$ git@github.com:johnhays/dsgwdashboard.git
$ cd dsgwdashboard
$ node -v
$ npm install -save
10 months ago
~~~
10 months ago
Create and install some self-signed certificates into the `dsgwdashboard`
directory because the server needs them to start. I personally would like
to have the possibility to only serve the pages via plain old HTTP
(without SSL/TLS) because I run most of my pages through a reverse-proxy
that takes care of all the certification.
10 months ago
10 months ago
If you don't need to use HTTPS you may find this patch interesting:
~~~patch
diff --git a/index.js b/index.js
index 0c71092..502933e 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,4 @@
-const https = require("https");
+const http = require("http");
const fs = require("fs");
const ini = require("ini");
const lineReader = require('line-reader');
@@ -32,12 +32,8 @@ updatelinks();
let serverPort = inifile.config.port;
-const server = https
+const server = http
.createServer(
- {
- key: fs.readFileSync("key.pem"),
- cert: fs.readFileSync("cert.pem"),
- },
app
)
.listen(serverPort, ()=>{
~~~
10 months ago
Next we will modify the `dashboard.ini` file because we will change the
port from 443 to 8443. Why? Because[^1]!
~~~ini
[config]
dgwconfig=/usr/local/etc/dstargateway.cfg
host=hotspot.oe7drt.net
port=8443
10 months ago
~~~
10 months ago
{{< alert circle-info >}}
This might be confusing now, the host above does not listen to port 8443 because
there is a reverse-proxy in-between (and actually a firewall/router too).
{{< /alert >}}
10 months ago
10 months ago
This configuration is now as slim as I could make, removing encryption on the dashboard
made it even better in terms of performance and maintainability as we don't have to
worry about our certificates on this host and no direct port-forwarding to this host
has been made -- but our dashboard can still be accesses from the internet in encrypted
form.
10 months ago
The actual path of this host and how it will be routed:
10 months ago
{{< mermaid >}}
%%{init: {"flowchart": {"htmlLabels": false}} }%%
graph LR;
A([Internet user]):::usr -- "`**HTTPS**`" -->B["`router/firewall
_hotspot.oe7drt.net_`"]:::fw;
B-- "`**HTTPS**`" -->C["`reverse-proxy
_proxy.lan_`"]:::rev;
C-- "`**HTTP**`" -->D["`hotspot dashboard
_hotspot.lan_`"]:::dash;
classDef usr stroke:#faa
classDef fw stroke:#f55
classDef rev stroke:#9f9
classDef dash stroke:#0f0
{{< /mermaid >}}
10 months ago
We will disable the shell for the _dashboard_ user because we normally
won't have to login as _dashboard_ user again.
10 months ago
~~~console
10 months ago
$ sudo chsh -s /bin/false dashboard
10 months ago
~~~
10 months ago
[^1]: Ports below <kbd>1024</kbd> can only be used as the _root_ user. Those are socalled
[privileged ports](https://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html).
To run the program as non-root user we need to set the port to something
above <kbd>1024</kbd>.
## DSTAR Registration
A DSTAR registration is mandatory if you want to be transmitted on
original ICOM repeaters. Otherwise your transmission will not be
forwarded properly and you may look for errors for a long time...
I registered in 2020 at <https://regist.dstargateway.org/> but there
is one important thing to add to the webui there: do not choose long
passwords (like those from a password manager) because it will get
cut off somewhere and it took me quite a while to find that error.
{{< alert skull-crossbones >}}
**I can't believe that there are still websites in 2024 that limit
the lenght of a password!**
{{< /alert >}}
I do have 12 characters now, I usually use 20 or more.