From 42f22e16308b1f9519f2b083011883b2a5bdf1c7 Mon Sep 17 00:00:00 2001 From: Christoph Schranz Date: Sat, 22 Feb 2020 15:15:27 +0100 Subject: [PATCH] hardcopy instead of symlink --- fix-permissions | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) mode change 120000 => 100644 fix-permissions diff --git a/fix-permissions b/fix-permissions deleted file mode 120000 index 0a2245a..0000000 --- a/fix-permissions +++ /dev/null @@ -1 +0,0 @@ -.build/fix-permissions \ No newline at end of file diff --git a/fix-permissions b/fix-permissions new file mode 100644 index 0000000..659b276 --- /dev/null +++ b/fix-permissions @@ -0,0 +1,35 @@ +#!/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 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