Created by: ston1th 2021-09-02 22:37:53
Updated by: ston1th 2023-04-11 22:49:44
Visibility: Public

Radicale

Alternative: https://github.com/jelmer/xandikos

Install and Upgrade

# upgrade
rcctl stop radicale
rm -rf /var/radicale


pkg_add py3-setuptools
mkdir /var/radicale
python3 -m venv /var/radicale
export VIRTUAL_ENV="/var/radicale"
/var/radicale/bin/python3 -m pip install --upgrade pip

version="v3.1.8"
curl -sSL https://github.com/Kozea/Radicale/archive/refs/tags/${version}.tar.gz >/tmp/${version}.tar.gz
[[ "$(sha256 /tmp/${version}.tar.gz|cut -d" " -f4)" = "40078e0f05917c09664363a9e289a36d32e00d10a1d169ffc60b5c581deb4e77" ]] && {
/var/radicale/bin/pip3 --require-virtualenv install /tmp/${version}.tar.gz
rm -rf /tmp/${version}.tar.gz
} || echo "error: checksum mismatch"
cat <<"EOF"> /etc/rc.d/radicale
#!/bin/ksh

daemon="/var/radicale/bin/radicale"
daemon_user="_radicale"
daemon_logger="daemon.info"

. /etc/rc.d/rc.subr

pexp="/var/radicale/bin/python3 ${daemon}.*"
rc_bg=YES
rc_reload=NO

rc_cmd $1
EOF
chmod 555 /etc/rc.d/radicale
groupadd _radicale
useradd -g _radicale -d /var/empty -s /sbin/nologin _radicale
mkdir -p /etc/radicale

mkdir -p /var/db/radicale/collections
chmod 750 /var/db/radicale/collections
chown _radicale:_radicale /var/db/radicale/collections

# crypto partition (optional)
mkdir -p /mnt/db/radicale/collections
chmod 750 /mnt/db/radicale/collections
chown _radicale:_radicale /mnt/db/radicale/collections

cat <<EOF> /etc/radicale/config
[server]
hosts = 127.0.0.1:5232
[auth]
# type = http_x_remote_user
type = radicale_goacc_auth
goacc_url = https://accounts.example.com
[storage]
filesystem_folder = /var/db/radicale/collections
[web]
type = none
EOF

Example nginx config:

...
  root /var/www;
  location / {
    proxy_pass http://127.0.0.1:5232/;
    proxy_http_version 1.1;
    proxy_set_header X-Script-Name /;
    proxy_set_header X-Remote-User $remote_user;
    # Basic Auth - optional
    #auth_basic "Radicale - Password Required";
    #auth_basic_user_file /var/www/radicale_htpasswd;
  }
...

Create user (optional):

htpasswd /var/www/radicale_htpasswd <username>
chmod 640 /var/www/radicale_htpasswd
chgrp www /var/www/radicale_htpasswd
rcctl enable radicale
rcctl start radicale

Use the following base URL: https://dav.example.com

GoAcc Auth Plugin

export VIRTUAL_ENV="/var/radicale"
version="v0.1.0"
curl -sSL https://git.giftfish.de/ston1th/radicale_goacc_auth/archive/${version}.tar.gz >/tmp/${version}.tar.gz
[[ "$(sha256 /tmp/${version}.tar.gz|cut -d" " -f4)" = "b7e8659d8caafcac4f2ddf34f2c258458961948aaa1348dd6b4ec567d85ded73" ]] && {
/var/radicale/bin/pip3 --require-virtualenv install /tmp/${version}.tar.gz
rm -rf /tmp/${version}.tar.gz
} || echo "error: checksum mismatch"

Upgrade

python3 -m venv --upgrade /var/radicale
/var/radicale/bin/python3 -m pip install --upgrade pip