-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add systemd support, via an optional module, to avoid adding systemd dependencies to the core. This allows the BBS to be easily managed as a service, like most other daemon services, and automatically started and restarted if needed. Apart from helping ensure BBS uptime, the service file also automatically ensures the BBS can run on privileged ports which non-root users normally would not be able to bind to. Apart from crafting the appropriate service file, some minor changes were needed to allow this: * Add an event for restart, allowing a SIGUSR2 sent to the BBS to trigger a configuration reload (via reload handlers) * Don't prompt for confirmation on SIGTERM, only on SIGINT. This ensures systemd can stop the BBS successfully when it sends SIGTERM to stop. Only SIGINT is expected to be used interactively anyways. * Since systemd starts the BBS as the run user directly, rather than the BBS starting as root and dropping privileges after certain key operations, these key operations need to be done in the service file using ExecStartPre. Additionally, these key operations can fail in bbs.c if their failure is harmless (since the operation was already performed), so recognizing that, some of these checks are a little more careful now about aborting startup.
- Loading branch information
1 parent
0ea87e3
commit 5c5c52b
Showing
13 changed files
with
236 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# LBBS service file | ||
# If you use this, it's recommended you add require = mod_systemd.so to /etc/lbbs/modules.conf | ||
|
||
[Unit] | ||
Description=LBBS bulletin board system daemon | ||
After=network.target | ||
|
||
[Service] | ||
# If you have a newer version of systemd (>= 253, as reported by systemctl --version) | ||
# then you can use the newer 'notify-reload' type and 'ReloadSignal'. | ||
# Otherwise, use 'notify' and 'ExecReload' for compatibility. | ||
#Type=notify-reload | ||
Type=notify | ||
|
||
# SIGHUP is ignored since remote console disconnects trigger it. | ||
# Therefore, we pick another unused signal to use for reload. | ||
# SIGTERM is implicitly used for shutdown so it's not specified here. | ||
#ReloadSignal=SIGUSR2 | ||
|
||
NotifyAccess=main | ||
Environment=HOME=/home/bbs | ||
WorkingDirectory=/home/bbs | ||
User=bbs | ||
Group=bbs | ||
|
||
# Only one of these two prestart commands is needed. | ||
# The first one doesn't seem to work as reliably, but the latter is less secure. | ||
#ExecStartPre=+setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/lbbs | ||
ExecStartPre=+sysctl net.ipv4.ip_unprivileged_port_start=18 | ||
|
||
# Since ExecStart will start with the BBS user's privileges (not root), | ||
# tasks that the BBS normally does prior to dropping privileges, | ||
# if started as root, won't succeed. Thus, we do them beforehand. | ||
ExecStartPre=+install -d -m 0755 -o bbs -g bbs /var/run/lbbs | ||
ExecStartPre=+install -d -m 0744 -o bbs -g bbs /var/log/lbbs | ||
|
||
ExecStart=/usr/sbin/lbbs -gcb | ||
|
||
# Only needed if Type is notify, not needed if notify-reload | ||
ExecReload=kill -USR2 $MAINPID | ||
|
||
LimitCORE=infinity | ||
Restart=on-failure | ||
RestartSec=5 | ||
PrivateTmp=false | ||
|
||
# Since logs are already saved to disk, there's normally no need for output | ||
# For debugging (e.g. on startup failure), it may be helpful to remove this | ||
# (to enable logging by systemd) | ||
StandardOutput=null | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.