lifecycle: fix check_if_root not working without docker

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-09 15:56:12 +02:00
parent 01c5235e82
commit 4ee2f951da

View file

@ -9,16 +9,18 @@ function check_if_root {
return
fi
SOCKET="/var/run/docker.sock"
GROUP="authentik"
if [[ -e "$SOCKET" ]]; then
# Get group ID of the docker socket, so we can create a matching group and
# add ourselves to it
DOCKER_GID=$(stat -c '%g' $SOCKET)
getent group $DOCKER_GID || groupadd -f -g $DOCKER_GID docker
usermod -a -G $DOCKER_GID authentik
GROUP="authentik:docker"
fi
# Fix permissions of backups and media
chown -R authentik:authentik /media /backups
chpst -u authentik:authentik:docker env HOME=/authentik $1
chpst -u authentik:$GROUP env HOME=/authentik $1
}
if [[ "$1" == "server" ]]; then