====== Hub on Linux ======

The hub must run as **the same user as Synchronet**, because it makes users with Synchronet's ''jsexec''. These steps assume that user is ''sbbs'' and Synchronet is in ''/sbbs''. First [[doorhub:running_a_hub#prepare_the_door_bbs|prepare the door BBS]].

===== Install =====

Unzip ''doorhub-0.1.0-linux-x64.zip'' (or ''-linux-arm64'') and:

<code bash>
sudo mkdir /opt/doorhub
sudo cp doorhub /opt/doorhub/
sudo chown -R sbbs: /opt/doorhub
sudo chmod 700 /opt/doorhub
sudo ln -s /opt/doorhub/doorhub /usr/local/bin/doorhub
sudo -u sbbs doorhub init
</code>

''init'' makes ''/opt/doorhub/hub.json'' and the host key, and prints the key's fingerprint:

<code>
Created /opt/doorhub/hub.json
Host key: SHA256:dJxkWMLh0S5bYYye72Yp0GsnfuJ0PZWjTMkXCcb9YGg
Next: doorhub set public_host <name>, add doors and BBSes, then doorhub serve
</code>

Give that fingerprint to member sysops so they can check it the first time their connector connects.

===== Configure =====

If Synchronet isn't in ''/sbbs'':

<code bash>
sudo -u sbbs doorhub set jsexec /path/to/sbbs/exec/jsexec
sudo -u sbbs doorhub set sbbs_ctrl /path/to/sbbs/ctrl
</code>

Name the hub and set the address members will use:

<code bash>
sudo -u sbbs doorhub set hub_name "Example Door Hub"
sudo -u sbbs doorhub set public_host hub.example.com
</code>

Add games ([[doorhub:games|Games]]) and members ([[doorhub:member_bbses|Member BBSes]]). All settings are on the [[doorhub:settings|Settings]] page.

===== Run =====

Try it in the foreground (Ctrl+C stops it):

<code bash>
sudo -u sbbs doorhub serve
</code>

<code>
2026/11/09 11:30:36 Example Door Hub 0.1.0 listening on :2022 (key SHA256:dJxkWMLh0S5b...)
</code>

==== As a service ====

The package has ''doorhub.service''. Edit ''User'' and ''Group'' (and the paths, if you used another folder):

<code ini>
[Unit]
Description=Door Hub (shared door games server)
After=network.target sbbs.service

[Service]
Type=simple
User=sbbs
Group=sbbs
Environment=DOORHUB_DIR=/opt/doorhub
WorkingDirectory=/opt/doorhub
ExecStart=/opt/doorhub/doorhub serve
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
</code>

<code bash>
sudo cp doorhub.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now doorhub
systemctl status doorhub
journalctl -u doorhub -f        # the log
</code>

To keep a log file as well, add these two lines under ''[Service]'':

<code ini>
StandardOutput=append:/opt/doorhub/doorhub.log
StandardError=append:/opt/doorhub/doorhub.log
</code>

===== Day to day =====

The admin commands work while the hub is running, and changes apply at once (except ''listen''). Run them as the hub's user so files keep the right owner:

<code bash>
sudo -u sbbs doorhub bbs list
sudo -u sbbs doorhub door list
</code>

The folder is ''/opt/doorhub'' unless you add ''-d folder'' or set the ''DOORHUB_DIR'' environment variable.

===== Updating =====

<code bash>
sudo cp doorhub /opt/doorhub/doorhub.new
sudo mv /opt/doorhub/doorhub.new /opt/doorhub/doorhub
sudo systemctl restart doorhub
</code>

A restart ends games in progress, so pick a quiet time. Connectors reconnect by themselves.

===== Firewall =====

If the machine runs a firewall, allow the hub's port. For ufw: ''sudo ufw allow 2022/tcp''. See [[doorhub:internet_and_security|Internet and security]] for the router side.
