From d41814b502d70e01feaaca84b5441fdc65c6c154 Mon Sep 17 00:00:00 2001 From: Jan Kieseler Date: Thu, 22 Aug 2024 14:51:50 +0200 Subject: [PATCH] docker update --- docker/fix-permissions | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 docker/fix-permissions diff --git a/docker/fix-permissions b/docker/fix-permissions new file mode 100755 index 0000000..d540462 --- /dev/null +++ b/docker/fix-permissions @@ -0,0 +1,33 @@ +#!/bin/bash +# Set permissions on a directory +# After any installation, if a directory needs to be (human) user-writable, run this script on it. +# It will make everything in the directory owned by the group ${NB_GID} and writable by that group. +# Deployments that want to set a specific user id can preserve permissions +# by adding the `--group-add users` line to `docker run`. + +# Uses find to avoid touching files that already have the right permissions, +# which would cause a massive image explosion + +# Right permissions are: +# group=${NB_GID} +# AND permissions include group rwX (directory-execute) +# AND directories have setuid,setgid bits set + +set -e + +for d in "$@"; do + find "${d}" \ + ! \( \ + -group "${NB_GID}" \ + -a -perm -g+rwX \ + \) \ + -exec chgrp "${NB_GID}" -- {} \+ \ + -exec chmod g+rwX -- {} \+ + # setuid, setgid *on directories only* + find "${d}" \ + \( \ + -type d \ + -a ! -perm -6000 \ + \) \ + -exec chmod +6000 -- {} \+ +done \ No newline at end of file