lots of updates, things working
[distro-setup] / radicale-setup
1 #!/bin/bash -l
2
3 [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
4
5
6 # davdroid setup instructions at the bottom
7
8 # main docs:
9 # http://radicale.org/user_documentation/
10 # https://davdroid.bitfire.at/configuration/
11
12 # note on debugging: if radicale can't bind to the address,
13 # in the log it just says "Starting Radicale". If you run
14 # it in the foreground, it will give more info. Background
15 # plus debug does not help.
16 # sudo -u radicale radicale -D -f
17
18 # created password file with:
19 # htpasswd -c /etc/davpass dav
20
21 d=/etc/systemd/system/radicale.service.d
22 mkdir -p $d
23 sudo dd of=$d/override.conf <<'EOF'
24 [Unit]
25 # this unit is configured to start and stop whenever openvpn-client@mail.service
26 # does
27 After=network.target
28 BindsTo=openvpn-client@mail.service
29 After=openvpn-client@mail.service
30
31 [Install]
32 RequiredBy=openvpn-client@mail.service
33 EOF
34 ser daemon-reload # not sure this is needed
35
36 pi-nostart radicale
37
38 # I moved /var/lib/radicale after it's initialization.
39 # I did a sudo -u radicale git init in the collections subfolder
40 # after it gets created, per the git docs.
41 lnf -T /o/radicale /var/lib/radicale
42
43 # from https://www.williamjbowman.com/blog/2015/07/24/setting-up-webdav-caldav-and-carddav-servers/
44
45 # more config is for li in distro-end
46
47 # coment in this file says this is needed for it to run on startup
48 sed -ri 's/^\s*#+\s*(ENABLE_RADICALE\s*=\s*yes\s*)/\1/' /etc/default/radicale
49
50 setini() {
51 key="$1" value="$2" section="$3"
52 file="/etc/radicale/config"
53 sed -ri "/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d};/ *\[$section\]/a $key = $value" "$file"
54 }
55
56 # comments say default is 0.0.0.0:5232
57 setini hosts 10.8.0.4:5232 server
58
59 if [[ $HOSTNAME == $MAIL_HOST ]]; then
60 sgo radicale
61 fi
62
63 # disable power management feature, set to 240 min sync interval,
64 # so it shouldn't be bad.
65
66 # davdroid from f-druid.
67 # login with url and user name
68 # username ian,
69 # url https://cal.iankelling.org
70 # username ian
71 # pass, see password manager
72 #
73 # add account dialog:
74 #
75 # set account name as ian@iankelling.org, per help text below the
76 # field.
77 #
78 # switch to groups are per-contact categories,
79 # per https://davdroid.bitfire.at/configuration/radicale/
80 #
81 #
82 # After setting up account, I added one address book, named
83 # ianaddr. calender was already created, named ian. checked boxes under
84 # both. synced.
85 #
86 # To restore from old phone to new phone, I wiped all data out, then copied over the newly created files. I think
87 #
88 # ignorable background info:
89 #
90 # opentasks uses the calendar file.
91 #
92 # The address book I created got a uuid as a name for the file. Note
93 # the .props file says if it's a calendar or addressbook.
94 #
95 # When debugging, tailed /var/log/radicale/radicale.log and apache log,
96 # both show the requests happening. Without creating the address book,
97 # after creating a contact, a sync would delete it.
98 #
99 # Address books correspond to .props files in the radicale dir.
100 #
101 # Some background is here,
102 # https://davdroid.bitfire.at/faq/entry/cant-manage-groups-on-device/
103 # which shows separate vcard option is from rfc 6350, the other is 2426,
104 # radicale page says it implements the former not the latter,
105 # which conflicts with the documentation of which to select, but whatever.
106 # http://radicale.org/technical_choices/
107 # https://davdroid.bitfire.at/faq/entry/cant-manage-groups-on-device/
108 #
109 # Note, url above says only cayanogenmod 13+ and omnirom can manage groups.
110
111 # Note, radicale had built-in git support to track changes, but they
112 # removed it in 2.0.