-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare_radicale.sh
executable file
·155 lines (123 loc) · 2.89 KB
/
prepare_radicale.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
cd `dirname $0`
. ./common.sh
usage="
Prepares the radicale calendar server
Usage:
$(basename $0) [--cal-user <user>:<password>]
[--help] [--debug] [--log <output file>]
where
--cal-user <user>:<password> - Username and password of first calendar user
--debug - Flag that sets debugging mode.
--log - Path to the log file that will log all meaningful commands
Example2:
$(basename $0) --debug
"
if [ -z "$1" ]; then
echo "$usage" >&2
exit 0
fi
set -x
repo_server="http://cran.us.r-project.org"
deb_folder='/tmp'
install_lib=auto
rstudio_server=0
rstudio=0
user="$USER"
while [[ $# > 0 ]]
do
key="$1"
shift
case $key in
--debug)
debug=1
;;
--log)
log=$1
shift
;;
--help)
echo "$usage"
exit 0
;;
--cal-user)
cal_user=$1
shift
;;
-*)
echo "Error: Unknown option: $1" >&2
echo "$usage" >&2
exit 1
;;
esac
done
install_apt_packages python3-pip apache2-utils git
install_pip3_packages radicale[bcrypt]
#logmkdir /var/lib/radicale/collections root
make_service_user radicale /var/lib/radicale/collections
make_sure_git_exists /var/lib/radicale/collections radicale
textfile /var/lib/radicale/collections/.git ".Radicale.cache
.Radicale.lock
.Radicale.tmp-*" radicale
textfile /etc/radicale/config "[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
# encryption method used in the htpasswd file
htpasswd_encryption = bcrypt
# Average delay after failed login attempts in seconds
delay = 1
[server]
hosts = 0.0.0.0:5232
max_connections = 20
# 1 Megabyte
max_content_length = 10000000
# 10 seconds
timeout = 10
[storage]
filesystem_folder = /var/lib/radicale/collections
hook = git add -A && (git diff --cached --quiet || git commit -m \"Changes by \"%(user)s)
" radicale
if [ -n "$cal_user" ]; then
pattern='^([^:]+):(.*)$'
if [[ "$cal_user" =~ $pattern ]]; then
cal_user=${BASH_REMATCH[1]}
cal_password=${BASH_REMATCH[2]}
else
errcho "Wrong format of --cal_user argument. Please use \"user:pa\$\$word\"."
exit 1
fi
if [ ! -f /etc/radicale/users ]; then
infix=" -c "
else
infix=""
fi
if ! grep -Exq "^${cal_user}:}" /etc/radicale/users; then
logexec sudo htpasswd -B $infix -b /etc/radicale/users $cal_user $cal_password
fi
fi
textfile /etc/gitconfig "[user]
email = radicale@localhost
name = Radicale server" root
custom_systemd_service radicale "[Unit]
Description=A simple CalDAV (calendar) and CardDAV (contact) server
After=network.target
Requires=network.target
[Service]
ExecStart=/usr/bin/env python3 -m radicale
Restart=on-failure
User=radicale
# Deny other users access to the calendar data
UMask=0027
# Optional security settings
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
NoNewPrivileges=true
ReadWritePaths=/var/lib/radicale/collections
[Install]
WantedBy=multi-user.target
"