mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-09-12 01:24:45 +08:00
fix docker permissions, check if group id already exists before adding a group
Signed-off-by: Adrian Gebhart <adrian@pestotoast.de>
This commit is contained in:
parent
9d4bbd0d2c
commit
e333427f94
1 changed files with 14 additions and 3 deletions
17
Containers/mastercontainer/start.sh
Normal file → Executable file
17
Containers/mastercontainer/start.sh
Normal file → Executable file
|
@ -15,9 +15,20 @@ elif ! mountpoint -q "/mnt/docker-aio-config"; then
|
|||
exit 1
|
||||
elif ! sudo -u www-data test -r /var/run/docker.sock; then
|
||||
echo "Trying to fix docker.sock permissions internally..."
|
||||
GROUP="$(stat -c '%g' /var/run/docker.sock)"
|
||||
groupadd -g "$GROUP" docker && \
|
||||
usermod -aG docker www-data
|
||||
|
||||
DOCKER_GROUP=$(stat -c '%G' /var/run/docker.sock)
|
||||
DOCKER_GROUP_ID=$(stat -c '%g' /var/run/docker.sock)
|
||||
# check if a group with the same group id of /var/run/docker.socket already exists in the container
|
||||
if grep -q "^$DOCKER_GROUP:" /etc/group; then
|
||||
#if yes, add www-data to that group
|
||||
echo "Adding internal www-data to group $DOCKER_GROUP"
|
||||
usermod -aG "$DOCKER_GROUP" www-data
|
||||
else
|
||||
#if the group doesn't exist, create it
|
||||
echo "Creating docker group internally with id $DOCKER_GROUP_ID"
|
||||
groupadd -g "$DOCKER_GROUP_ID" docker
|
||||
usermod -aG docker www-data
|
||||
fi
|
||||
if ! sudo -u www-data test -r /var/run/docker.sock; then
|
||||
echo "Docker socket is not readable by the www-data user. Cannot continue."
|
||||
exit 1
|
||||
|
|
Loading…
Add table
Reference in a new issue