Skip to content

Deploying on Ubuntu and other Linux distros with systemd

Snawoot edited this page Sep 28, 2023 · 1 revision

Deploying on Ubuntu and other Linux distros with systemd

1. Install the binary

Put compiled dtlspipe binary to /usr/local/bin/dtlspipe

2. Create systemd unit

Put file with following contents into /etc/systemd/system/dtlspipe-server.service:

[Unit]
Description=dtlspipe server
Documentation=https://github.com/Snawoot/dtlspipe/
After=network.target network-online.target
Requires=network-online.target

[Service]
EnvironmentFile=/etc/default/dtlspipe-server
DynamicUser=yes
StateDirectory=dtlspipe
Environment=HOME=%S/dtlspipe
ExecStart=/usr/local/bin/dtlspipe $OPTIONS
TimeoutStopSec=5s
PrivateTmp=true
ProtectSystem=full

[Install]
WantedBy=default.target

3. Create configuration

Put file with following contents into /etc/default/dtlspipe-server:

OPTIONS=server 0.0.0.0:2815 127.0.0.1:56218
DTLSPIPE_PSK=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

where OPTIONS are corresponding command line arguments and DTLSPIPE_PSK is PSK. We pass it as an env variable to hide it from process command line in the process list like ps -ef.

Set actual listen address instead of 0.0.0.0:2815.

Set actual destination UDP endpoint instead of 127.0.0.1:56218.

4. Enable and start the service

Execute following commands as root:

systemctl daemon-reload
systemctl enable --now dtlspipe-server