This is an old revision of the document!
Table of Contents
Start Synchronet BBS from Systemd
If you run modern GNU/Linux distributions, you can found Systemd as init system (like Debian, Fedora and others).
Instead of use the old /etc/init.d/sbbs.service init script, you can create a systemd services unit file:
Create and edit the follow files (please correct your ExecStart path and User/Group as you need):
[Unit] Description=Synchronet BBS service Documentation=man:sbbs After=syslog.target network.target [Service] Type=forking Environment=SBBSROOT=/sbbs SBBSCTRL=/sbbs/ctrl User=sbbs Group=sbbs PermissionsStartOnly=true ExecStartPre=/sbin/setcap 'cap_net_bind_service=+ep' /sbbs/src/sbbs3/gcc.linux.x64.exe.release/sbbs ExecStart=/sbbs/exec/sbbs d ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=30 [Install] WantedBy=multi-user.target
Some points in this config:
- After. If you are using syslog with sbbs, so it is nice to put that requirement before systemd tries to launch sbbs.
- Type. If you are to run SBBS in daemonized mode, the main executable will exit after the daemon is called. This could confuse systemd into thinking the process is finished. If you use “Type=forking” you tell systemd that the process you launch will execute another process.
- Environment. In order to avoid having multiple files, you can embed the variables inside the service file.
- PermissionsStartOnly. This one tells systemd to execute ExecStartPre as root, but ExecStart as the user and group declared in User,Group.
- ExecStartPre. For some weird reason, capabilities are frequently lost from the sbbs executable. It is possible to mitigate the effect by running setcap just before the daemon is ran. The binding won't fail anymore using this. Please notice you can't point a symlink here, so modify the architecture directory to the right path (gcc.linux.x64.exe.release or gcc.linux.exe.release).
- ExecStart. If you don't want to get syslog entries duplicated you will have to run SBBS in daemonized mode, so the “d” parameter is used. Syslog is implicit when daemonized, so there is no need for additional parameters.
- RestartSec. It's advisable to wait some secs before attempting restarting in case of failure, just to give some time for binding release.
- Modify the environment variables to match your SBBS setup
- Modify User and Group. If you run this as root you don't need the ExecStartPre line.
- Modify the ExecStart and ExecStartPre paths to match your Synchronet setup.
- Place this file in the correct location. For Ubuntu 16.04 you should place it in /lib/systemd/system
- Enable the service with “systemctl enable sbbs”
- To run the service without restarting “systemctl start sbbs”
Running systemctl status sbbs will show:
● sbbs.service - Synchronet BBS service Loaded: loaded (/lib/systemd/system/sbbs.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2016-12-15 20:20:43 CET; 16s ago Docs: man:sbbs Process: 12364 ExecStart=/sbbs/exec/sbbs d (code=exited, status=0/SUCCESS) Process: 12356 ExecStartPre=/sbin/setcap cap_net_bind_service=+ep /sbbs/src/sbbs3/gcc.linux.x64.exe.release/sbbs (code=exited, status Main PID: 12374 (sbbs) Tasks: 11 Memory: 30.1M CPU: 223ms CGroup: /system.slice/sbbs.service └─12374 /sbbs/exec/sbbs d Dec 15 20:23:25 HISPAMSX sbbs: term Node 1 Telnet ------- [----------] Dec 15 20:23:31 HISPAMSX sbbs: term Node 1 Terminal not detected, reducing inactivity hang-up timeout to 75 seconds Dec 15 20:23:36 HISPAMSX sbbs: term Node 1 Unknown User 'Enable' Dec 15 20:24:02 HISPAMSX sbbs: term Node 1 disconnected Dec 11 20:24:03 HISPAMSX sbbs: term Node 1 thread terminated (0 node threads remain, 71 clients served)
[Unit] Description=Synchronet BBS Documentation=man:sbbs After=network.target [Service] Restart=on-failure EnvironmentFile=-/etc/default/sbbs ExecStart=/sbbs/exec/sbbs nd ExecReload=/bin/kill -HUP $MAINPID User=root Group=root [Install] WantedBy=multi-user.target
Finally, you must execute systemd daemon-reload for tell systemd te reload the unit file
Test your setup:
# systemctl status sbbs ● sbbs.service - Synchronet BBS Loaded: loaded (/etc/systemd/system/sbbs.service; enabled) Active: active (running) since lun 2016-11-21 14:39:53 ART; 24min ago Docs: man:sbbs Process: 14393 ExecStart=/sbbs/exec/sbbs nd (code=exited, status=0/SUCCESS) Main PID: 14393 (sbbs) CGroup: /system.slice/sbbs.service └─14393 /sbbs/exec/sbbs nd nov 21 14:39:53 scarlet systemd: Started Synchronet BBS.
Debian (alternative using tmux)
You can use Tmux to still the Synchronet BBS console running on a screen that can be attached when you need
[Unit] Description=Synchronet BBS Documentation=man:sbbs After=network.target [Service] Restart=on-failure Type=forking KillMode=none EnvironmentFile=-/etc/default/sbbs ExecStart=/usr/bin/tmux new-session -d -s sbbs '/sbbs/exec/sbbs nd' ExecStop=/usr/bin/tmux send-keys -t sbbs 'q' C-m 'exit' C-m User=root Group=root [Install] WantedBy=multi-user.target
Using tmux, Synchronet start in a session (called sbbs), you can attach to the running console using tmux attach -t sbbs