3 systemd unit
Jelle Kaufmann edited this page 2020-11-04 13:00:19 +01:00

systemd unit example:

Located in /etc/systemd/system/mautrix-whatsapp.service

[Unit]
Description=mautrix-whatsapp bridge
After=network.target

[Service]
Type=exec
User=mautrix-whatsapp
WorkingDirectory=/opt/mautrix-whatsapp
ExecStart=/opt/mautrix-whatsapp/mautrix-whatsapp
Restart=on-failure
RestartSec=30s

# Optional hardening to improve security
ReadWritePaths=/opt/mautrix-whatsapp
NoNewPrivileges=yes
MemoryDenyWriteExecute=true
PrivateDevices=yes
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=strict
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictRealtime=true
LockPersonality=true
ProtectKernelLogs=true
ProtectControlGroups=true
ProtectKernelTunables=true
ProtectHostname=true
ProtectKernelModules=true
PrivateUsers=true
ProtectClock=true
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service

[Install]
WantedBy=multi-user.target

You may need to adjust the User the bridge is running as, the WorkingDirectory/ReadWritePaths to the folder containing config.yaml and ExecStart to the path where the binary is located.

After creating or modifying the unit you need to run systemctl daemon-reload.

Enable (and immediately start) the service using systemctl enable --now mautrix-whatsapp.