COLOR 64 BBS v8.1a - SYSTEMD SERVICES
Linux LTK Build

------------------------------------------------------------
OVERVIEW
------------------------------------------------------------

This document describes OPTIONAL systemd service files that can
be used to automatically start and manage components of the
Color 64 BBS under Linux.

Using systemd is NOT REQUIRED. The BBS can be run entirely using
the provided shell scripts.

Systemd services are intended for sysops who want:
- Automatic startup at boot
- Automatic restart on failure
- Hands-off operation on always-on systems

------------------------------------------------------------
WHAT SHOULD (AND SHOULD NOT) USE SYSTEMD
------------------------------------------------------------

RECOMMENDED FOR SYSTEMD:
- tcpser (long-running daemon, no UI)

OPTIONAL / ADVANCED:
- VICE / x64sc (requires X session or headless configuration)

NOT RECOMMENDED:
- vicebuild.sh
- setup scripts
- interactive menus or editors

------------------------------------------------------------
TCPSer SYSTEMD SERVICE (RECOMMENDED)
------------------------------------------------------------

The following example runs tcpser as a USER service. It does NOT
run as root.

This example assumes:
- tcpser binary is available as /usr/local/bin/tcpser
- BBS files are located in the user's home directory
- Port and speed match your BBS configuration

------------------------------------------------------------
FILE: ~/.config/systemd/user/tcpser.service
------------------------------------------------------------

[Unit]
Description=TCPSer Modem Emulator for Color 64 BBS
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/tcpser -p 8502 -l 4 -v 25237 -s 38400 \
  -A answer.txt -C connect.txt -N noanswer.txt -B busy.txt
WorkingDirectory=%h/color64_v81a_ltk
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

------------------------------------------------------------
INSTALLING THE TCPSer SERVICE
------------------------------------------------------------

1) Create the user systemd directory (if it does not exist):

   mkdir -p ~/.config/systemd/user

2) Create the service file:

   nano ~/.config/systemd/user/tcpser.service

3) Paste the service definition above and SAVE.

4) Reload systemd user services:

   systemctl --user daemon-reload

5) Enable tcpser to start automatically:

   systemctl --user enable tcpser

6) Start the service now:

   systemctl --user start tcpser

------------------------------------------------------------
CHECKING TCPSer STATUS AND LOGS
------------------------------------------------------------

Check status:

   systemctl --user status tcpser

View logs:

   journalctl --user -u tcpser

------------------------------------------------------------
STOPPING OR DISABLING TCPSer
------------------------------------------------------------

Stop the service:

   systemctl --user stop tcpser

Disable automatic start:

   systemctl --user disable tcpser

------------------------------------------------------------
OPTIONAL: VICE SYSTEMD SERVICE (ADVANCED)
------------------------------------------------------------

Running VICE (x64sc) under systemd is OPTIONAL and intended only
for advanced users.

WARNING:
- Requires an active X session or properly configured headless
  environment
- NOT recommended for first-time sysops
- Debugging display issues can be non-trivial

------------------------------------------------------------
FILE: ~/.config/systemd/user/color64-vice.service
------------------------------------------------------------

[Unit]
Description=VICE Emulator for Color 64 BBS
After=network.target tcpser.service

[Service]
Type=simple
ExecStart=/usr/local/bin/x64sc \
  -config Config/config.ini \
  -cartcrt Bins/ltk.crt \
  -ltkimage0 DiskImages/ltkernal30-disk0.dlk \
  -ltkimage1 DiskImages/ltkernal30-disk1.dlk \
  -ltkimage2 DiskImages/ltkernal30-disk2.dlk
WorkingDirectory=%h/color64_v81a_ltk
Restart=on-failure
Environment=DISPLAY=:0

[Install]
WantedBy=default.target

------------------------------------------------------------
INSTALLING THE VICE SERVICE
------------------------------------------------------------

1) Verify that x64sc runs normally from a terminal first.
2) Ensure your DISPLAY variable is correct (:0 is common).
3) Create the service file:

   nano ~/.config/systemd/user/color64-vice.service

4) Reload systemd user services:

   systemctl --user daemon-reload

5) Enable the service (optional):

   systemctl --user enable color64-vice

6) Start the service:

   systemctl --user start color64-vice

------------------------------------------------------------
TROUBLESHOOTING
------------------------------------------------------------

SERVICE STARTS THEN STOPS:
- Check logs with journalctl --user -u servicename
- Verify paths in ExecStart are correct
- Verify WorkingDirectory exists

PERMISSION DENIED:
- Ensure the service is a USER service, not system-wide
- Ensure files are readable/executable by your user

VICE DOES NOT DISPLAY:
- Verify DISPLAY variable
- Verify X session is active
- Consider running VICE manually instead

------------------------------------------------------------
REMOVING SERVICES
------------------------------------------------------------

Stop and disable the service:

   systemctl --user stop servicename
   systemctl --user disable servicename

Delete the service file:

   rm ~/.config/systemd/user/servicename.service

Reload systemd:

   systemctl --user daemon-reload

------------------------------------------------------------
END OF SYSTEMD-SERVICES.TXT
------------------------------------------------------------
