5.6 KiB
CalDAV Server with Calcurse
Goal
- Set up a own caldav server which allows to sync calcurse with your other devices. If you want to run nextcloud anyways, you can also use its caldav server. This is a more light weight solution, which does not require a full php environment.
Software used
- A current debian install is assumed, using nginx as its sever. Tested on debian 11.
- Baikal
- Davx^5 Android
Install
- Make sure all the dependencies are installed
sudo apt-get install nginx php-fpm php-sqlite3 composer php-xml php-curl -y
- Go to your sources directory. Here it is assumed to be
/opt/src/and install Baikal. Default port is 9999, so adjust it to your wishes. Assumed to be 9999 throughout this write-up.
cd /opt/src
git clone https://github.com/sabre-io/baikal
cd baikal
composer install
- Make the baikal directory writable by the websever process. This is strictly necessary for
Specficandconfig.
chown -R www-data:www-data Specific config
I found an issue, that maybe got solved by owning the whole baikal directory. So in case you find yourself with an error related to write-permission denials, run
sudo chown -R www-data:www-data .
Server Config
- Create the corresponding nginx config for the page.
cd /etc/nginx/sites-available
touch baikal.site
- Copy the following config. Adjust the
root /opt/src/baikal/htmlpath for your install and make sure that the correct php-version. (Seephp --version).
server {
listen 9999 default_server;
root /opt/src/baikal/html;
dav_methods PUT DELETE MKCOL COPY MOVE;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
rewrite ^/.well-known/caldav /dav.php redirect;
rewrite ^/.well-known/carddav /dav.php redirect;
charset utf-8;
location ~ /(\.ht|Core|Specific|config) {
deny all;
return 404;
}
location ~ ^(.+.php)(.*)$ {
try_files $fastcgi_script_name =404;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; #Adjust here for your version
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /.ht {
deny all;
}
}
- Link the available site to the enabled ones
ln -s /etc/nginx/sites-available/baikal.site /etc/nginx/sites-enabled/
- Restart nginx after testing the config files
nginx -t
systemctl restart nginx
- Check if baikal is running on
<hostname/ip>:9999.
Baikal Config
-
Follow the setup guide, setting the time-zone, and enable the
basicauthentication type. If wanted, it is possible to send invite emails for upcoming events to its participants. If you are interested in this, check the web, as I did not go down that path. -
Continue and select the SQLite data base and continue. If you have specific reasons to use SQL, you can do this with
mysql -u root -p
and then create a new baikal data-base.
CREATE DATABASE baikal;
CREATE USER 'baikal'@'localhost' IDENTIFIED BY '<YOUR BEST PASSWORD123>';
GRANT ALL PRIVILEGES ON baikal.* TO 'baikal'@'localhost';
FLUSH PRIVILEGES;
Add your selection of host, name and username to the page and continue. We assume a SQLite database.
- We now log in to baikal using the admin user. Now we can create users. We create a
testuserunder the mail addresstest@testing.ts. Now we can adjust the default calender or add more calenders if we like. We can also enable or disable todo-sync or note-syncing.
Calcurse Config
- Make sure
calcurse-caldavis available as a command . - Copy the config and adjust
[General]
### Adjust here when you also want to sync todo's and notes! (cal, todo, note)
SyncFilter = cal
DryRun = No
Verbose = Yes
AuthMethod = basic
Hostname = IPADRESS:9999
#Path = /dav.php/calendars/<username>/<calender-name>
Path = /dav.php/calendars/test/default
InsecureSSL = No
# I run this on a local server, which does not have https enabled.
# If you enable https on the baikal page, which is highly recommended when running it open to the web, change this to Yes
HTTPS = No
[Auth]
#Username = <username>
Username = test
#Either use plaintext password (not recommended...) or add your password to your CLI password manager (pass) under baikal/username
#Password = testpassword1234
PasswordCommand = pass baikal/username
-
Save and run
calcurse-caldav --init=two-way. Other initialisation options exists and are explained here. This does the initial sync between your baikal instance and calcurse. -
For future sync, either
- set up a post-save and/or start hook running
calcurse-caldav - just run
calcurse-caldaveverytime you like to have things synced.
- set up a post-save and/or start hook running
Android
Some calendars have build in caldav support. For those follow their procedure. If not, we can use Davx^5. Get it from F-Droid and drop in your URL, username and password. Set up a sync period and select the calendar in your calendar app. In theory it is also possible to sync your address book.
Future:
- Use some other caldav server, which might be more light weight.
- Test the note and todo sync
- Test the address-book sync, maybe with abook