summaryrefslogtreecommitdiff
path: root/scripts/fix-permissions
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2019-02-28 14:46:07 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2019-02-28 14:46:07 -0500
commit8c37ac76900b06794d99e2a7124af21b8093d7fe (patch)
tree6acd8189d73e78f4cf16b9390f88135472fb6e00 /scripts/fix-permissions
parentc4ec0592116720e53dfb8b2e327a2bf223701105 (diff)
downloaddocker-pipeline-nb-8c37ac76900b06794d99e2a7124af21b8093d7fe.tar.gz
Tack Jupyter scripts on top
Diffstat (limited to 'scripts/fix-permissions')
-rwxr-xr-xscripts/fix-permissions35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/fix-permissions b/scripts/fix-permissions
new file mode 100755
index 0000000..7e27f51
--- /dev/null
+++ b/scripts/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 u+s,g+s {} \;
+done