Installing on OpenBSD 7.6 - Kozea/Radicale GitHub Wiki

Introduction

OpenBSD 7.6 has ports for Radicale 1.x and 2.x but not for 3.x. Given the recent fairly active development of Radicale a port for Radicale 3.x would become outdated rapidly. As an alternative here are step-by-step instructions for installing Radicale 3.x on OpenBSD 7.6.

Limitations:

  • These instructions only cover the OpenBSD specific issues of installing Radicale itself. You may also want to set up TLS and/or a reverse proxy, authentication, etc. Please refer to the Radicale documentation, such as https://radicale.org/v3.html or other parts of this wiki, for these aspects of setting up the service.
  • At the time of writing Radicale 3.3.0 was the latest version. Other versions are untested.
  • Use at your own risk.

Prerequisites

  • A fresh installation of OpenBSD 7.6 is assumed.
  • The OpenBSD host needs to be able to access the Internet to install ports and to access the pip repository.
  • Sufficient disk space to install Python, the virtual Python environment and Radicale is assumed. (The needed space is not excessive, so in most cases this will be a non-issue.)
  • You will need access as root, either directly or by using doas(1) on the host. These instructions assume direct root access as indicated by the # prompt. A $ prompt indicates that no root access is required for the command.
  • A text editor of your choice or the capability to edit files elsewhere and transfer them to the host are also required. vi(1) and mg(1) are included in the OpenBSD base installation and other editors such as Emacs or nano are available as ports. (In theory you could get by without an editor. But that would involve complicated and tedious alternatives.) Note that text files follow the *NIX line ending convention, i.e. ending lines with a single LF (ASCII/UTF-8 0x0a, U+000a) character. The character encoding should be ASCII or UTF-8 (which are identical for anything described here).

These instructions may also work on OpenBSD 7.5 and on future versions. But this is untested.

Installing Radicale

  1. Add the ports for Python and pip (unless they are already installed):
    # pkg_add python py3-pip
  2. Create a virtual Python environment to avoid mixing pkg_add(1) and pip managed code:
    # python3 -m venv /usr/local/lib/radicale
  3. [Optional] Update pip in the virtual Python environment to silence warnings when using pip:
    # /usr/local/lib/radicale/bin/pip install --upgrade pip
  4. Install Radicale into the virtual Python environment:
    # /usr/local/lib/radicale/bin/pip install radicale
  5. Create a user and group for running Radicale:
    # useradd -g =uid -L daemon -c 'Radicale user' -s /sbin/nologin -u 672 -d /nonexistent _radicale
    Note: This is the same user and group that is installed by the Radicale 2.x port. If you feel that it is too dangerous to reuse the same name and UID/GID then feel free to use different values, but make sure you adjust the following instructions accordingly.
  6. Create a directory for the Radicale configuration:
    # mkdir /etc/radicale
  7. Create at least a minimal configuration file /etc/radicale/config to override the default storage location /var/lib/… which doesn't exist on OpenBSD:
[storage]
filesystem_folder = /var/db/radicale/collections

Of course you will probably want to add your own configuration settings to this file as well.

  1. Create the storage location and set its owner/group to the user/group created above:
    # install -o _radicale -g _radicale -d /var/db/radicale
  2. Create an rc.d(8) service script for Radicale as /etc/rc.d/radicale3 and make it executable:
#!/bin/ksh
 
daemon='/usr/local/lib/radicale/bin/radicale'
daemon_user='_radicale'
daemon_logger='daemon.info'
 
. /etc/rc.d/rc.subr
 
pexp=".* ${daemon}.*"
rc_reload=NO
rc_configtest=NO
rc_bg=YES
 
rc_cmd $1

# chmod 755 /etc/rc.d/radicale3

  1. [Optional] Enable the service to start at system boot:
    # rcctl enable radicale3
  2. Start the Radicale service:
    # rcctl start radicale3

Logging

Radicale logs can be found in /var/log/daemon. You can configure syslogd(8) to place the logs into their own log file, e.g. by following these additional steps:

  1. Add the following to the top of /etc/syslogd.conf:
!!radicale3
daemon.info						/var/log/radicale
!*
  1. Create the log file:
    # touch /var/log/radicale
  2. Reload the syslogd(8) configuration:
    # rcctl reload syslogd
  3. [Optional] Set up log rotation for the Radicale log file by adding something like the following to /etc/newsyslog.conf:
    /var/log/radicale 644 7 250 * Z

Managing the service

FYI only (this is general OpenBSD knowledge, not specific to Radicale). See rcctl(8) for details.

Stop the service

# rcctl stop radicale3

Check the service

# rcctl check radicale3

# rcctl ls started

Restart the service/reload the configuration

# rcctl restart radicale3

Disable launching the service a system boot

# rcctl disable radicale3

Updating Radicale

Once installed as described above there may come a time when you want to update Radicale to the newest version.

  1. Stop the Radicale service:
    # rcctl stop radicale3
  2. Update Radicale in the virtual Python environment:
    # /usr/local/lib/radicale/bin/pip install --upgrade radicale
  3. Make any required changes to the configuration if the new version requires any changes.
  4. Start the Radicale service:
    # rcctl start radicale3

Other

Check which version of Radicale is installed:
$ /usr/local/lib/radicale/bin/pip show radicale