mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
make install: install the systemd unit bbs.service
bbs.service.sample becomes bbs.service.in. make builds bbs.service from it with the path of BINDIR, and make install puts it in SYSTEMD_UNIT_DIR ($(PREFIX)/lib/systemd/system), as D-Modem does for dmodem-ari.service. The unit now waits for network-online.target and, when they are there, the database servers and dmodem-login-authd. SupplementaryGroups=asterisk is a comment, because the unit does not start on a host without that group. Running.md gives the steps after make install. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRV8YPyMUdSM1QgsczH
This commit is contained in:
10 files changed
+105
-21
No files matched your search
@@ -7,3 +7,4 @@
|
||||
/.site/
|
||||
/site/
|
||||
/docs/wiki/index.md
|
||||
/bbs.service
|
||||
@@ -1,20 +1,32 @@
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
# where make install puts bbs.service: $(PREFIX)/lib/systemd/system, which
|
||||
# systemd reads for /usr/local and /usr (the same as D-Modem's units)
|
||||
SYSTEMD_UNIT_DIR ?= $(PREFIX)/lib/systemd/system
|
||||
GO ?= go
|
||||
# go3270 is the suite's fork, github.com/D-Modem/go3270 (go.mod): fetch it
|
||||
# from GitHub directly, not through the public proxy and checksum database
|
||||
export GOPRIVATE ?= github.com/D-Modem/*
|
||||
|
||||
all: bbs
|
||||
all: bbs bbs.service
|
||||
|
||||
bbs:
|
||||
$(GO) build -o bbs ./cmd/bbs
|
||||
|
||||
# the systemd unit, with the path of the installed program
|
||||
bbs.service: bbs.service.in Makefile
|
||||
sed -e 's|@BINDIR@|$(BINDIR)|g' bbs.service.in > $@
|
||||
|
||||
test:
|
||||
$(GO) vet ./...
|
||||
$(GO) test -race ./...
|
||||
|
||||
install: bbs
|
||||
install -D -m 0755 bbs $(DESTDIR)$(PREFIX)/bin/bbs
|
||||
# the program, the unit (always: changes go in drop-ins, systemctl edit
|
||||
# bbs), and bbs.conf if there is none. It does not run systemctl: then
|
||||
# systemctl daemon-reload && systemctl enable --now bbs
|
||||
install: bbs bbs.service
|
||||
install -D -m 0755 bbs $(DESTDIR)$(BINDIR)/bbs
|
||||
install -D -m 0644 bbs.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/bbs.service
|
||||
@if [ ! -e $(DESTDIR)/etc/bbs/bbs.conf ]; then \
|
||||
install -D -m 0640 bbs.conf.sample $(DESTDIR)/etc/bbs/bbs.conf; \
|
||||
fi
|
||||
@@ -45,6 +57,6 @@ ruffle:
|
||||
@ls ruffle/ruffle.js
|
||||
|
||||
clean:
|
||||
rm -f bbs
|
||||
rm -f bbs bbs.service
|
||||
|
||||
.PHONY: all bbs test install clean doors-image proto phone-data ruffle
|
||||
@@ -59,7 +59,7 @@ bbs -config /etc/bbs/bbs.conf serve
|
||||
```
|
||||
|
||||
[bbs.conf.sample](bbs.conf.sample) has all the options.
|
||||
[bbs.service.sample](bbs.service.sample) runs bbs under systemd.
|
||||
`make install` also installs [bbs.service](bbs.service.in), which runs bbs under systemd.
|
||||
|
||||
## Documentation
|
||||
|
||||
|
||||
+1
-1
@@ -1107,7 +1107,7 @@ address = 127.0.0.1:2513
|
||||
;require = 20
|
||||
|
||||
; finger: who is on ("finger @host"), and who a user is ("finger name@host").
|
||||
; Port 79 needs CAP_NET_BIND_SERVICE (bbs.service.sample)
|
||||
; Port 79 needs CAP_NET_BIND_SERVICE (bbs.service)
|
||||
;[finger]
|
||||
;address = :79
|
||||
;online = yes
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
# bbs.service: the BBS under systemd (docs/wiki/Running.md).
|
||||
# make install puts this unit in $(PREFIX)/lib/systemd/system, a directory
|
||||
# that systemd reads for /usr/local and /usr. SYSTEMD_UNIT_DIR selects a
|
||||
# different one.
|
||||
# Then: systemctl daemon-reload && systemctl enable --now bbs
|
||||
# To change the options, the user or the groups: systemctl edit bbs
|
||||
[Unit]
|
||||
Description=BBS for telnet, TN3270 and modem callers
|
||||
After=network.target
|
||||
Documentation=https://github.com/D-Modem/bbs/wiki/Running
|
||||
Wants=network-online.target
|
||||
# the database server, when the database is not SQLite; and the auth socket
|
||||
# of dmodem-login, when auth_socket is set. After= on a unit that is not
|
||||
# installed does nothing
|
||||
After=network-online.target postgresql.service mysql.service mariadb.service dmodem-login-authd.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/bbs -config /etc/bbs/bbs.conf serve
|
||||
ExecStart=@BINDIR@/bbs -config /etc/bbs/bbs.conf serve
|
||||
# systemctl reload bbs: bbs.conf read again, what may change while callers
|
||||
# are on put in force (the log says what waits for a restart)
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
@@ -13,8 +24,10 @@ Group=bbs
|
||||
# itself (docs/wiki/Running.md): then no User= and Group= here, nor
|
||||
# AmbientCapabilities, and RuntimeDirectory's directory is root's (put
|
||||
# unix sockets where the user may write, or give them a socket_group)
|
||||
# for [listen menu]'s socket_group = asterisk
|
||||
SupplementaryGroups=asterisk
|
||||
# for [listen menu]'s socket_group = asterisk. The unit does not start if
|
||||
# the group is not there, so it is a comment here: put it in a drop-in
|
||||
# (systemctl edit bbs) on a host with Asterisk
|
||||
#SupplementaryGroups=asterisk
|
||||
# for DOS doors in Docker (README, "Doors"): the docker group is as good as
|
||||
# root, so think twice; rootless Docker or Podman is the safer way
|
||||
#SupplementaryGroups=asterisk docker
|
||||
+17
-1
@@ -3,7 +3,8 @@ This page shows how to build bbs from source. You must have Go 1.26 or later.
|
||||
```
|
||||
make # or: go build ./cmd/bbs
|
||||
make test
|
||||
make install # installs /usr/local/bin/bbs, and /etc/bbs/bbs.conf if there is none
|
||||
make install # installs /usr/local/bin/bbs, the systemd unit bbs.service,
|
||||
# and /etc/bbs/bbs.conf if there is none
|
||||
```
|
||||
|
||||
bbs does not use cgo. Thus, you do not have to configure a C compiler. All
|
||||
@@ -24,4 +25,19 @@ export GOPRIVATE=github.com/D-Modem/* # the Makefile sets this for you
|
||||
git config --global url."git@github.com:".insteadOf "https://github.com/" # or use a token
|
||||
```
|
||||
|
||||
`make install` uses these variables:
|
||||
|
||||
| Variable | Default | What it sets |
|
||||
| --- | --- | --- |
|
||||
| `PREFIX` | `/usr/local` | The base of the other directories |
|
||||
| `BINDIR` | `$(PREFIX)/bin` | The directory of the bbs program. The `ExecStart=` line of bbs.service uses it |
|
||||
| `SYSTEMD_UNIT_DIR` | `$(PREFIX)/lib/systemd/system` | The directory of bbs.service. systemd reads units from `/usr/local/lib/systemd/system` and `/usr/lib/systemd/system` |
|
||||
| `DESTDIR` | empty | A directory before all paths, for packages |
|
||||
|
||||
`make install` replaces bbs.service each time. Thus, do not edit the
|
||||
installed unit. Put your changes in a drop-in (`systemctl edit bbs`).
|
||||
`make install` does not replace an existing `/etc/bbs/bbs.conf`.
|
||||
`make install` does not run `systemctl`. Refer to
|
||||
[Running](Running#under-systemd) for the subsequent steps.
|
||||
|
||||
**See also:** [Running](Running), [Development](Development)
|
||||
@@ -762,7 +762,7 @@ Multi Relay Chat: the BBSes' chat network. Its rooms are the chat rooms beginni
|
||||
|
||||
## `[finger]`
|
||||
|
||||
finger: who is on ("finger @host"), and who a user is ("finger name@host"). Port 79 needs CAP_NET_BIND_SERVICE (bbs.service.sample)
|
||||
finger: who is on ("finger @host"), and who a user is ("finger name@host"). Port 79 needs CAP_NET_BIND_SERVICE (bbs.service)
|
||||
|
||||
| key | default | live | what it does |
|
||||
|---|---|---|---|
|
||||
|
||||
@@ -184,7 +184,7 @@ change. Then it prints what changed and when the change applies.
|
||||
|
||||
## Changing it while callers are on
|
||||
|
||||
`systemctl reload bbs` (`ExecReload` in bbs.service.sample, which sends
|
||||
`systemctl reload bbs` (`ExecReload` in bbs.service, which sends
|
||||
SIGHUP) makes the BBS read the file again. If the BBS cannot start with
|
||||
the new file, nothing changes, and the log gives the reason. If it can,
|
||||
the keys below apply immediately. The log lists the other changes, which
|
||||
@@ -207,10 +207,11 @@ idle timeout. The Configuration screen of the sysop applies the file
|
||||
itself when it writes it. It tells which changes applied and which
|
||||
wait.
|
||||
|
||||
The `ProtectSystem=strict` of bbs.service.sample prevents writes to /etc
|
||||
The `ProtectSystem=strict` of bbs.service prevents writes to /etc
|
||||
by the service. For the Configuration screen inside the BBS to save, give
|
||||
the service `ReadWritePaths=/etc/bbs` (a commented line in
|
||||
bbs.service.sample), and give the file to the bbs user. `bbs config`
|
||||
bbs.service, which you put in a drop-in with `systemctl edit bbs`), and
|
||||
give the file to the bbs user. `bbs config`
|
||||
that runs as root operates in both cases.
|
||||
|
||||
> **WARNING: IF THE BBS CAN WRITE ITS CONFIGURATION, ALL SYSOPS CAN MAKE
|
||||
|
||||
@@ -9,7 +9,7 @@ Each server is disabled until you put its section in the configuration.
|
||||
|
||||
The usual ports of finger and gopher are below 1024. Thus, run the BBS
|
||||
with `AmbientCapabilities=CAP_NET_BIND_SERVICE` (refer to
|
||||
[bbs.service.sample](https://github.com/D-Modem/bbs/blob/HEAD/bbs.service.sample)),
|
||||
[bbs.service](https://github.com/D-Modem/bbs/blob/HEAD/bbs.service.in)),
|
||||
or use a different port.
|
||||
|
||||
## Finger
|
||||
|
||||
+46
-5
@@ -23,12 +23,52 @@ The database can also be PostgreSQL, MySQL or MariaDB. Refer to
|
||||
|
||||
## Under systemd
|
||||
|
||||
[bbs.service.sample](https://github.com/D-Modem/bbs/blob/HEAD/bbs.service.sample)
|
||||
runs the BBS under systemd as its own user. The database is in
|
||||
`make install` installs the unit
|
||||
[bbs.service](https://github.com/D-Modem/bbs/blob/HEAD/bbs.service.in) in
|
||||
`/usr/local/lib/systemd/system` (refer to [Building](Building)). The unit
|
||||
runs the BBS under systemd as the user `bbs`. The database is in
|
||||
`/var/lib/bbs` and the sockets are in `/run/bbs`. `systemctl reload bbs`
|
||||
applies the settings that you can change while callers are on (refer to
|
||||
[Configuration](Configuration#changing-it-while-callers-are-on)).
|
||||
|
||||
Do these steps one time, as root, after `make install`:
|
||||
|
||||
1. Make the user `bbs`:
|
||||
|
||||
```
|
||||
useradd --system --home-dir /var/lib/bbs --shell /usr/sbin/nologin bbs
|
||||
```
|
||||
|
||||
2. Let the user `bbs` read the configuration:
|
||||
|
||||
```
|
||||
chown root:bbs /etc/bbs/bbs.conf
|
||||
chmod 0640 /etc/bbs/bbs.conf
|
||||
```
|
||||
|
||||
3. Load the unit, then start the BBS now and at each boot:
|
||||
|
||||
```
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now bbs
|
||||
```
|
||||
|
||||
Do not edit the installed unit, because the next `make install` replaces
|
||||
it. To change the unit, use `systemctl edit bbs`. That command writes a
|
||||
drop-in in `/etc/systemd/system/bbs.service.d`. The unit has commented
|
||||
lines for these changes:
|
||||
|
||||
- `SupplementaryGroups=asterisk`: for `socket_group = asterisk`. The unit
|
||||
does not start if the group is not on the host. Thus, this line is not
|
||||
active by default.
|
||||
- `AmbientCapabilities=CAP_NET_BIND_SERVICE`: for ports below 1024.
|
||||
- `ReadWritePaths=/etc/bbs`: for the Configuration screen of the sysop
|
||||
(refer to [Configuration](Configuration)).
|
||||
|
||||
The unit starts after the network is online. It also starts after
|
||||
PostgreSQL, MySQL, MariaDB and the auth socket of dmodem-login
|
||||
(`dmodem-login-authd.service`), if they are on the host.
|
||||
|
||||
## Running as a user of its own
|
||||
|
||||
Ports below 1024 (23 for telnet, 79 for finger, 70 for gopher) must have
|
||||
@@ -36,7 +76,7 @@ root or the `CAP_NET_BIND_SERVICE` capability. There are two methods to
|
||||
give these ports to the BBS without root:
|
||||
|
||||
- systemd starts the BBS as its own user with that capability
|
||||
(`User=bbs` and `AmbientCapabilities=` in bbs.service.sample).
|
||||
(`User=bbs` and `AmbientCapabilities=` in bbs.service).
|
||||
- You start the BBS as root, and the BBS then stops its root access:
|
||||
|
||||
```
|
||||
@@ -73,7 +113,8 @@ The user must have these permissions:
|
||||
- Write in the locations of the database and the files.
|
||||
- Run the program.
|
||||
|
||||
Under systemd, do not use `User=` with this method. bbs.service.sample
|
||||
tells you how.
|
||||
Under systemd, do not use `User=` with this method. The comments in
|
||||
bbs.service tell you how. Put the changes in a drop-in (`systemctl edit
|
||||
bbs`), and set `User=` and `Group=` to empty values there.
|
||||
|
||||
**See also:** [Configuration](Configuration), [Administration](Administration)
|
||||
Reference in new issue
Block a user