From 8e9e6d37fc9acfb11a2d18ea761d45ba12e765ef Mon Sep 17 00:00:00 2001 From: Ludwig Behm Date: Thu, 19 Oct 2023 23:29:05 +0200 Subject: [PATCH] add nextcloud public calendar export --- .gitignore | 1 + bin/calendar-events-exporter.sh | 5 +++++ etc/systemd/calendar-events-exporter.service | 12 ++++++++++++ etc/systemd/calendar-events-exporter.timer | 9 +++++++++ 4 files changed, 27 insertions(+) create mode 100644 .gitignore create mode 100755 bin/calendar-events-exporter.sh create mode 100644 etc/systemd/calendar-events-exporter.service create mode 100644 etc/systemd/calendar-events-exporter.timer diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b735195 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +events.json diff --git a/bin/calendar-events-exporter.sh b/bin/calendar-events-exporter.sh new file mode 100755 index 0000000..7ed5745 --- /dev/null +++ b/bin/calendar-events-exporter.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +curl -sH "Accept: application/calendar+json" "https://cloud.kraut.space/remote.php/dav/public-calendars/2EkPGt3PF6WwYsA3?export&expand=1&start=$(date -d "" +%s)&end=$(date -d "next month" +%s)" \ + | jq -r '.[2] | map({_type: .[0]} + (.[1] | map({key: .[0], value: .[3]}) | from_entries))' \ + > ./events.json diff --git a/etc/systemd/calendar-events-exporter.service b/etc/systemd/calendar-events-exporter.service new file mode 100644 index 0000000..6f5e28d --- /dev/null +++ b/etc/systemd/calendar-events-exporter.service @@ -0,0 +1,12 @@ +[Unit] +Description=Dumps calendar events from nextcloud into usable json +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/bash /var/www/kraut.space/bin/calendar-events-exporter.sh + +User=www-data +Group=www-data + +WorkingDirectory=/var/www/kraut.space diff --git a/etc/systemd/calendar-events-exporter.timer b/etc/systemd/calendar-events-exporter.timer new file mode 100644 index 0000000..56ee0eb --- /dev/null +++ b/etc/systemd/calendar-events-exporter.timer @@ -0,0 +1,9 @@ +[Unit] +Description=timer for automatic refresh of calendar export + +[Timer] +# execute at the second minute of every hour, and repeat every 5 minutes +OnCalendar=*:2/5 + +[Install] +WantedBy=timers.target