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