Radicale
Radicale copied to clipboard
Default git hook does not work out of the box
Hi,
Enabling
hook = ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
leads to:
[7fa9f2c42ae8] DEBUG: Running hook
[7fa9f2c42ae8] DEBUG: Captured stderr hook:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'radicale@9009506c3d73.(none)')
[7fa9f2c42ae8] ERROR: An exception occurred during MKCOL request on '/myuser/0527aa01-08d0-01d4-4793-692bece1feeb/': Command '([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by "myuser)' returned non-zero exit status 128.
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 332, in __call__
status, headers, answers = self._handle_request(environ)
File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 505, in _handle_request
environ, base_prefix, path, user)
File "/usr/lib/python3.6/site-packages/radicale/__init__.py", line 721, in do_MKCOL
return client.CREATED, {}, None
File "/usr/lib/python3.6/contextlib.py", line 88, in __exit__
next(self.gen)
File "/usr/lib/python3.6/site-packages/radicale/storage.py", line 1587, in acquire_lock
raise subprocess.CalledProcessError(p.returncode, p.args)
subprocess.CalledProcessError: Command '([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by "myuser)' returned non-zero exit status 128.
Workaround is to run
git config user.email "[email protected]"
in the collections folder.
Would be great if you could fix that!
Even though I iniitially did the "git init" in the collections dir, when I run:
sudo -u radicale git config user [email protected]
I get:
fatal: not in a git directory
# ls -al
total 20
drwxrwx--- 4 radicale radicale 4096 Oct 13 22:18 .
drwxrwx--- 3 radicale radicale 4096 Oct 13 21:19 ..
-rw-r----- 1 radicale radicale 0 Oct 13 22:35 .Radicale.lock
drwxrwx--- 7 radicale radicale 4096 Oct 13 21:24 .git
-rwxrwx--- 1 radicale alarm 47 Oct 13 21:26 .gitignore
drwxr-x--- 4 radicale radicale 4096 Oct 13 22:23 collection-root
@ikwyl6 you initialized the git repository in the wrong directory. It has to be one directory "up", e.g. /var/lib/radicale/
if your path is /var/lib/radicale/collections
.
This is a documentation issue and I'm working on it (expect the PR soon)
@mpasternak I've already did a PR (https://github.com/Kozea/Radicale/pull/883)
@mookie- I commented it!
@mookie- this is how I would do that: https://github.com/Kozea/Radicale/pull/913 https://github.com/Kozea/Radicale/pull/914
@mpasternak You are right, this is much better. Thank you! I'll close my PR.
Hi, i has some trouble too and messed with configuration. I solved it for me by:
vim /etc/radicale/config
[storage]
filesystem_folder = /var/lib/radicale/collections
hook = ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
cd /var/lib/radicale/collections
git init
vim .gitignore
.Radicale.cache
.Radicale.lock
.Radicale.tmp-*
cd /var/lib
chown -R radicale:radicale radicale/
sudo -u radicale git config user.name YourName
sudo -u radicale git config user.email [email protected]
service radicale restart
#make some new entry in calendar and then check radicale log and git commit history
tail -f /etc/radicale/radicale.log
cd /var/lib/radicale/collections
git log
regards, Mario
@vmario89 this is great, feel free to submit a pull request to my branch and I'll merge it so Kozea devs can merge just that PR. #913 #914
Hi, I solved this in another way if anyone's interested.
I'm using a docker-compose.yml
file to set up radicale (note the 2 GIT_* entries). This is slightly stripped, as I use an nginx/lets encrypt proxy also.
version: "3.7"
services:
radicale:
image: <user>/radicale
build: ./
container_name: radicale
restart: always
environment:
GIT_NAME: <user>
GIT_EMAIL: <email>
volumes:
- radicale:/data
- ./config:/etc/radicale:ro
ports:
- 5232
volumes:
radicale:
driver_opts:
type: none
o: bind
device: /mnt/ssd-data/docker-data/radicale
I'm using a slightly modified Dockerfile
(added git + a user other than root)
FROM alpine:latest
# Version of Radicale (e.g. 2.0.0)
ARG VERSION=master
ARG USER=radicale
# Install dependencies
RUN apk add --no-cache \
python3 \
python3-dev \
build-base \
libffi-dev \
ca-certificates \
openssl \
git
# Install Radicale
RUN wget --quiet https://github.com/Kozea/Radicale/archive/${VERSION}.tar.gz --output-document=radicale.tar.gz && \
tar xzf radicale.tar.gz && \
pip3 install ./Radicale-${VERSION}[md5,bcrypt] && \
rm -r radicale.tar.gz Radicale-${VERSION}
# Install dependencies for Radicale<2.1.9
RUN pip3 install passlib[bcrypt]
# Remove build dependencies
RUN apk del \
python3-dev \
build-base \
libffi-dev
RUN adduser -HD ${USER}
RUN mkdir /data && chown ${USER}.${USER} /data
USER radicale
# Run Radicale (Configure it here or provide a "config" file!)
CMD ["radicale", "--hosts", "0.0.0.0:5232"]
My config
[server]
hosts = 0.0.0.0:5232
[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
htpasswd_encryption = bcrypt
delay = 1
[storage]
filesystem_folder = /data/collections
hook = /etc/radicale/git.sh
Note the git.sh
which I'm calling in the hook here. It calls a small shell script which fixes all the git stuff so you don't need to do anything when booting up the docker container
#!/bin/sh
cd /data/collections
if [ ! -d .git ]; then
git init
git config user.name "$GIT_NAME"
git config user.email "$GIT_EMAIL"
echo -e ".Radicale.cache\n.Radicale.lock\n.Radicale.props\n.Radicale.tmp-*" > .gitignore
fi
git add -A
git diff --cached --quiet || git commit -m "Update"
You may want to add, that configuring user.name
and user.email
is not only for having nice names in the commit log, but that git breaks when they are unset.
And it would be good to merge it soon. I had the issue for months until I found the problem myself after quite a bit of debugging (and came here after I wanted to create an issue about it).
So the issue here is a small typo at the end of the line in the documentation. The current line is:
hook = ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by "%(user)s)
The line is missing a quote sign at the end, and should escape the quotation sign in the commit message. It should look like this to work:
hook = ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by \"%(user)s\"")
Maybe I should have a look at a PR (new or present), but in case some one else ends up here looking for the same thing, the above might help.
Maybe I should have a look at a PR (new or present), but in case some one else ends up here looking for the same thing, the above might help.
doc fixed now, thank you!