aboutsummaryrefslogtreecommitdiffstats
path: root/services/radicale/fs/sbin/cmd.sh
blob: 4d09e75dbec837c9ccadca3472f536bc20c67445 (plain)
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
#!/bin/sh
set -eu

conf=/etc/radicale/conf.ini

if [ ! -d /data/collections/.git ]; then
	# Initialize git repository (for storage)
	echo "Starting server..."
	/venv/bin/radicale --config "$conf" --logging-level error &
	radicale_pid=$!
	echo "Waiting for server to start..."
	until curl -sf http://127.0.0.1:5232; do sleep 1; done
	echo "Server started"

	cd /data/collections
	git init --initial-branch=radicale
	git config user.name radicale
	git config user.email radicale@domain.tld
	cat <<EOF >.gitignore
.Radicale.cache
.Radicale.lock
.Radicale.tmp-*
EOF
	git add -A && (git diff --cached --quiet || git commit -m "Initialization commit")

	echo "Restarting server..."
	kill "$radicale_pid"
	wait "$radicale_pid"
else
	echo "Initialization skipped"
fi

exec /venv/bin/radicale --config "$conf"