2. Download the binary for the architecture you want and save it in a new
directory.
### Option 3: Compiling manually
1. Clone the repo with `git clone https://github.com/mautrix/$bridge.git mautrix-$bridge`
2. Enter the directory (`cd mautrix-$bridge`)
3. Run `./build.sh` to fetch Go dependencies and compile
([`build.sh`] will simply call `go build` with some additional flags).
* If you want end-to-bridge encryption, make sure you have a C/C++ compiler
and the Olm dev headers (`libolm-dev` on debian-based distros) installed.
* If not, use `./build.sh -tags nocrypto` to disable encryption.
* Note: signal's build.sh script doesn't support extra arguments yet,
so you have to use build-go.sh manually after building libsignal-ffi.a.
* As an experimental feature, you can also use `-tags goolm` to use a pure
Go reimplementation of libolm. Encryption can be supported without a C
compiler or Olm dev headers with this method.
For mautrix-signal, if you don't want to compile libsignal yourself, you can
download a precompiled `libsignal_ffi.a` from the mau.dev CI and place it in
`/usr/local/lib` (or some other directory set in `LIBRARY_PATH`). Download links:
[Linux amd64](https://mau.dev/tulir/gomuks-build-docker/-/jobs/artifacts/master/raw/libsignal_ffi.a?job=libsignal%20linux%20amd64),
[Linux arm64](https://mau.dev/tulir/gomuks-build-docker/-/jobs/artifacts/master/raw/libsignal_ffi.a?job=libsignal%20linux%20arm64),
[macOS arm64](https://mau.dev/tulir/gomuks-build-docker/-/jobs/artifacts/master/raw/libsignal_ffi.a?job=libsignal%20macos%20arm64)
[`build.sh`]: https://github.com/mautrix/$bridge/blob/main/build.sh
## Step 2: Configuring and running
1. Use `./mautrix-$bridge -e` to generate an example config and save it to
`config.yaml`.
* Alternatively, you can find pregenerated examples at
(remember to choose
the appropriate version at the top if you're not using latest).
* Discord is still using the legacy architecture which doesn't have the `-e`
flag, so just manually copy `example-config.yaml` from the repo to `config.yaml`.
2. Update the config to your liking. See the [initial bridge config](../general/initial-config.md)
page for recommendations.
3. Generate the appservice registration file by running `./mautrix-$bridge -g`.
* You can use the `-c` and `-r` flags to change the location of the config
and registration files. They default to `config.yaml` and
`registration.yaml` respectively.
4. Register the bridge on your homeserver (see [Registering appservices]).
5. Run the bridge with `./mautrix-$bridge`.
6. After the bridge is running, refer to the bridge-specific Authentication page
to start using it.
[Registering appservices]: ../general/registering-appservices.md
## Updating
If you compiled manually, pull changes with `git pull` and recompile with
`./build.sh`.
If you downloaded a prebuilt executable, simply download a new one and replace
the old one.
Finally, start the bridge again.
## systemd service
1. Create a user for the bridge:
```shell
$ sudo adduser --system mautrix-$bridge --home /opt/mautrix-$bridge
```
2. Follow the normal setup instructions above.
Make sure you use that user and home directory for the bridge.
4. Create a systemd service file at `/etc/systemd/system/mautrix-$bridge.service`:
```ini
[Unit]
Description=mautrix-$bridge bridge
[Service]
Type=exec
User=mautrix-$bridge
WorkingDirectory=/opt/mautrix-$bridge
ExecStart=/opt/mautrix-$bridge/mautrix-$bridge
Restart=on-failure
RestartSec=30s
# Optional hardening to improve security
ReadWritePaths=/opt/mautrix-$bridge
NoNewPrivileges=yes
# This may cause issues with libsignal.
# Should be safe for other bridges
#MemoryDenyWriteExecute=true
PrivateDevices=yes
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=strict
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictRealtime=true
LockPersonality=true
ProtectKernelLogs=true
ProtectKernelTunables=true
ProtectHostname=true
ProtectKernelModules=true
PrivateUsers=true
ProtectClock=true
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service
[Install]
WantedBy=multi-user.target
```