Initial commit

This commit is contained in:
2020-06-27 15:56:54 +02:00
commit c3200c91db
65 changed files with 2701 additions and 0 deletions
@@ -0,0 +1,3 @@
function radicale
~/.local/bin/radicale --config ~/radicale/config $argv
end
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
########################################################################
# 2018-11-25 Lukas Bestle <project-shell@lukasbestle.com>
########################################################################
# Concats a directory of ICS files to a single ICS file for sharing
#
# Usage: radicale_to_ics <directory> <output.ics> [<calname>]
#
# <directory> Directory with ICS files (e.g. from Radicale)
# <output.ics> Output path for the concatenated ICS file
# <calname> Optional name of the ICS file
# (displayed in clients)
########################################################################
directory="$1"
output="$2"
calname="$3"
if [[ -z "$output" ]]; then
# Print help
echo -e "\033[1mUsage:\033[0m \033[34mradicale_to_ics\033[0m <directory> <output.ics> [<calname>]"
exit 1
fi
# Place temporary file right next to the output file
# Will be moved when done with processing
tmp="$output.tmp"
# iCalendar header
echo "BEGIN:VCALENDAR" > "$tmp"
echo "VERSION:2.0" >> "$tmp"
echo "X-WR-TIMEZONE:Europe/Berlin" >> "$tmp"
echo "CALSCALE:GREGORIAN" >> "$tmp"
echo "METHOD:PUBLISH" >> "$tmp"
# Add calendar name if given
if [[ -n "$calname" ]]; then
echo "X-WR-CALNAME:$calname" >> "$tmp"
fi
# Concat all event files in the given directory
# unless the directory is empty
if [[ "$(ls "$directory")" ]]; then
for file in "$directory"/*; do
# Extract all VEVENT elements (supports multiple per input file)
sed '/^BEGIN:VEVENT/, /^END:VEVENT/!d' "$file" >> "$tmp"
done
fi
# Add iCalendar footer
echo "END:VCALENDAR" >> "$tmp"
# Move to final destination
mv "$tmp" "$output"
+24
View File
@@ -0,0 +1,24 @@
# The user "lukas" can read and write any collection
[admin]
user: lukas
collection: .*
permissions: RrWw
# Allow reading root collection for authenticated users (required for the web interface)
[root]
user: .+
collection:
permissions: R
# Allow reading and writing principal collection (same as user name)
[principal]
user: .+
collection: {user}
permissions: RW
# Allow reading and writing calendars and address books that are direct
# children of the principal collection
[calendars]
user: .+
collection: {user}/[^/]+
permissions: rw
@@ -0,0 +1,3 @@
.Radicale.cache
.Radicale.lock
.Radicale.tmp-*
+8
View File
@@ -0,0 +1,8 @@
---
- name: Reread service config
command: supervisorctl reread
- name: Restart Radicale
supervisorctl:
name: radicale
state: restarted
+63
View File
@@ -0,0 +1,63 @@
---
- name: Add DAV domain to Uberspace config
import_role:
name: snapstromegon.uberspace_web_domain
vars:
domain: dav.bstl.xyz
- name: Copy config to home directory
copy:
src: home/
dest: "{{ ansible_env.HOME }}/"
mode: preserve
tags: radicale-update
notify: Restart Radicale
- name: Copy service config
template:
src: service.ini.j2
dest: "{{ ansible_env.HOME }}/etc/services.d/radicale.ini"
notify: Reread service config
- name: Copy app config
template:
src: config.j2
dest: "{{ ansible_env.HOME }}/radicale/config"
tags: radicale-update
notify: Restart Radicale
- name: Set up Radicale users
template:
src: users.j2
dest: "{{ ansible_facts.env.HOME }}/radicale/users"
tags: radicale-update
notify: Restart Radicale
- name: Configure web backend
import_role:
name: snapstromegon.uberspace_web_backend
vars:
route: dav.bstl.xyz
http:
port: 8080
- name: Install and update Radicale
pip:
name: radicale[bcrypt]
state: latest
extra_args: --user
executable: pip3.8
tags: radicale-update
notify: Restart Radicale
- name: Initialize storage repository
command:
chdir: "{{ ansible_env.HOME }}/radicale/storage"
cmd: git init
creates: "{{ ansible_env.HOME }}/radicale/storage/.git"
- name: Set up garbage collection cronjob
cron:
name: "Garbage-collection"
special_time: weekly
job: git --git-dir {{ ansible_env.HOME }}/radicale/storage/.git gc
+16
View File
@@ -0,0 +1,16 @@
[server]
hosts = 0.0.0.0:8080
[auth]
type = htpasswd
htpasswd_filename = {{ ansible_env.HOME }}/radicale/users
htpasswd_encryption = bcrypt
realm = bstl DAV - Password Required
[rights]
type = from_file
file = {{ ansible_env.HOME }}/radicale/rights
[storage]
filesystem_folder = {{ ansible_env.HOME }}/radicale/storage
hook = git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
+4
View File
@@ -0,0 +1,4 @@
[program:radicale]
command={{ ansible_env.HOME }}/.local/bin/radicale --config {{ ansible_env.HOME }}/radicale/config
autostart=yes
autorestart=yes
+3
View File
@@ -0,0 +1,3 @@
{% for username, password in dav_users.items() %}
{{ username }}:{{ password }}
{% endfor %}