• systemd service files for MIS

    From Zip@21:1/202 to All on Saturday, August 24, 2019 09:37:33
    Hello!

    I thought I would share the systemd service files I have created for my
    Mystic BBS installation, in case anyone of you are running Mystic BBS on distros utilizing systemd. All comments are welcome, of course. :)

    First, /etc/systemd/system/mis.service:


    [Unit]
    Description=Mystic Internet Servers (MIS) for Mystic BBS

    # NOTE: We want the network to be up
    After=network-online.target

    # NOTE: We disable the unit start rate limiting, as hitting the limit would render "Restart=..." useless (require manual intervention/restart of the
    unit)!
    StartLimitIntervalSec=0

    [Service]
    Type=forking

    WorkingDirectory=/mystic
    Environment=mysticbbs=/mystic
    ExecStart=/mystic/mis root /mystic daemon
    PIDFile=/mystic/semaphore/mis.bsy
    ExecStop=/mystic/mis root /mystic shutdown

    # NOTE: We need to allow some extra time for the PIDFile to be created before checking for it, as it appears to be created by the FORKED process, not the PARENT process!
    ExecStartPost=/usr/bin/timeout -k 1 5 /bin/bash -c "while :; do [ -e /mystic/semaphore/mis.bsy ] && break; /bin/sleep 1; done; exit 0"

    # NOTE: We should ALWAYS be running; ONLY systemd should start/stop the program!
    Restart=always
    RestartSec=30

    # NOTE: Safeguard against unclean shutdowns
    ExecStartPre=-/bin/rm -f /mystic/semaphore/mis.bsy
    ExecStopPost=-/bin/rm -f /mystic/semaphore/mis.bsy

    # NOTE: These MUST be overridden by /etc/systemd/system/mis.service.d/*.conf
    as there are no sensible defaults!
    User=OVERRIDE-THIS
    Group=OVERRIDE-THIS

    [Install]
    WantedBy=multi-user.target


    For those with other paths on their systems, cryptlib support (or not), or wishing to override some of the settings (e.g. the user/group specification), but still wishing to let mis.service remain "untouched" (perhaps if it would ship with some packaging of Mystic BBS in the future), you can create a
    drop-in file which overrides some of the settings.

    /etc/systemd/system/mis.service.d/local.conf ("local" could be anything but must end with ".conf"):


    [Service]

    User=bbs
    Group=bbs

    WorkingDirectory=/home/bbs/mystic
    Environment=mysticbbs=/home/bbs/mystic
    ExecStart=
    ExecStart=/home/bbs/mystic/mis root /home/bbs/mystic daemon PIDFile=/home/bbs/mystic/semaphore/mis.bsy
    ExecStop=
    ExecStop=/home/bbs/mystic/mis root /home/bbs/mystic shutdown

    # NOTE: We need to allow some extra time for the PIDFile to be created before checking for it, as it appears to be created by the FORKED process, not the PARENT process!
    ExecStartPost=
    ExecStartPost=/usr/bin/timeout -k 1 5 /bin/bash -c "while :; do [ -e /home/bbs/mystic/semaphore/mis.bsy ] && break; /bin/sleep 1; done; exit 0"

    # NOTE: Safeguard against unclean shutdowns
    ExecStartPre=
    ExecStartPre=-/bin/rm -f /home/bbs/mystic/semaphore/mis.bsy
    ExecStopPost=
    ExecStopPost=-/bin/rm -f /home/bbs/mystic/semaphore/mis.bsy

    # NOTE: For SSL/TLS support
    Environment=LD_LIBRARY_PATH=/home/bbs/cryptlib


    As you see from my example local.conf, I'm using different paths, have specified the BBS user/group of my choice, and have added the cryptlib support environment variable pointing to my directory with "libcl.so" in.

    Don't forget to run 'systemctl daemon-reload' for systemd to pick up any changes and the drop-in configuration.

    Hope this helps someone wishing to run MIS via systemd. :)

    Best regards
    Zip

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: Star Collision BBS, Uppsala, Sweden (21:1/202)