mostly fix mail bugs
[distro-setup] / radicale-setup
1 #!/bin/bash -l
2
3 [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
4
5 # davdroid setup instructions at the bottom
6
7 # main docs:
8 # http://radicale.org/user_documentation/
9 # https://davdroid.bitfire.at/configuration/
10
11
12 # created password file with:
13 # htpasswd -c /etc/nginx/caldav/htpasswd ian
14
15
16 # python-dulwich, to track changes with git, per
17 # http://radicale.org/user_documentation/#idgit-support
18 pi nginx python-dulwich radicale
19
20 # I moved /var/lib/radicale after it's initialization.
21 # I did a sudo -u radicale git init in the collections subfolder
22 # after it gets created, per the git docs.
23 lnf -T /o/radicale /var/lib/radicale
24
25 acme-tiny -n cal.iank.pw
26
27 # from https://www.williamjbowman.com/blog/2015/07/24/setting-up-webdav-caldav-and-carddav-servers/
28 mkdir /etc/nginx/caldav
29 touch /etc/nginx/caldav/htpasswd
30 chmod 640 /etc/nginx/caldav/htpasswd
31 chgrp www-data /etc/nginx/caldav/htpasswd
32 nginx-site -f 5232 - cal.iank.pw <<'EOF'
33 auth_basic "Not currently available";
34 auth_basic_user_file /etc/nginx/caldav/htpasswd;
35 EOF
36
37 # coment in this file says this is needed for it to run on startup
38 sed -ri 's/^\s*#+\s*(ENABLE_RADICALE\s*=\s*yes\s*)/\1/' /etc/default/radicale
39 sgo radicale
40
41 setini() {
42 key="$1" value="$2" section="$3"
43 file="/etc/radicale/config"
44 sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key = $value" "$file"
45 }
46
47 # comments say default is 0.0.0.0:5232
48 setini hosts 127.0.0.1:5232 server
49
50 # davdroid from f-droid. username ian,
51 # url https://iank.pw/radicale/ian.
52 # I disabled power management feature, it's got 240 min sync interval,
53 # so it shouldn't be bad.
54 #
55
56 # when setting up davdroid, switch to groups are per-contact categories,
57 # per https://davdroid.bitfire.at/configuration/radicale/
58 #
59 # set account name as ian@iankelling.org, per help text below the
60 # field.
61 #
62 # After setting up account, I added one address book, named
63 # ian. calender was already created, named ian. checked boxes under
64 # both. synced.
65 #
66 # ignorable background info:
67 #
68 # When debugging, tailed /var/log/radicale/radicale.log and nginx log,
69 # both show the requests happening. Without creating the address book,
70 # after creating a contact, a sync would delete it.
71 #
72 # Address books correspond to .props files in the radicale dir.
73 #
74 # Some background is here,
75 # https://davdroid.bitfire.at/faq/entry/cant-manage-groups-on-device/
76 # which shows separate vcard option is from rfc 6350, the other is 2426,
77 # radicale page says it implements the former not the latter,
78 # which conflicts with the documentation of which to select, but whatever.
79 # http://radicale.org/technical_choices/
80 # https://davdroid.bitfire.at/faq/entry/cant-manage-groups-on-device/
81 #
82 # Note, url above says only cayanogenmod 13+ and omnirom can manage groups.