Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Docker: review fix: if end-user host-mounts the export directory

Sven Fischer4c05a511c253
diff --git a/Dockerfile b/Dockerfile
index 1133835bb..f661012b5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -38,7 +38,6 @@ RUN groupadd -g 1000 paperless \
# Set export directory
ENV PAPERLESS_EXPORT_DIR /export
RUN mkdir -p $PAPERLESS_EXPORT_DIR
-RUN chown -Rh paperless:paperless $PAPERLESS_EXPORT_DIR
# Setup entrypoint
COPY scripts/docker-entrypoint.sh /sbin/docker-entrypoint.sh
diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh
index 7a5e26897..d3894fb78 100644
--- a/scripts/docker-entrypoint.sh
+++ b/scripts/docker-entrypoint.sh
@@ -15,26 +15,28 @@ map_uidgid() {
}
set_permissions() {
- # Set permissions for consumption directory
- chgrp paperless "$PAPERLESS_CONSUMPTION_DIR" || {
- echo "Changing group of consumption directory:"
- echo " $PAPERLESS_CONSUMPTION_DIR"
- echo "failed."
- echo ""
- echo "Either try to set it on your host-mounted directory"
- echo "directly, or make sure that the directory has \`o+x\`"
- echo "permissions and the files in it at least \`o+r\`."
- } >&2
- chmod g+x "$PAPERLESS_CONSUMPTION_DIR" || {
- echo "Changing group permissions of consumption directory:"
- echo " $PAPERLESS_CONSUMPTION_DIR"
- echo "failed."
- echo ""
- echo "Either try to set it on your host-mounted directory"
- echo "directly, or make sure that the directory has \`o+x\`"
- echo "permissions and the files in it at least \`o+r\`."
- } >&2
-
+ # Set permissions for consumption and export directory
+ for i in PAPERLESS_CONSUMPTION_DIR PAPERLESS_EXPORT_DIR; do
+ cur_dir_name=$(sed -e's/PAPERLESS_//; s/_DIR//' <<< $i | tr '[:upper:]' '[:lower:]')
+ chgrp paperless "${!i}" || {
+ echo "Changing group of ${cur_dir_name} directory:"
+ echo " ${!i}"
+ echo "failed."
+ echo ""
+ echo "Either try to set it on your host-mounted directory"
+ echo "directly, or make sure that the directory has \`o+x\`"
+ echo "permissions and the files in it at least \`o+r\`."
+ } >&2
+ chmod g+x "${!i}" || {
+ echo "Changing group permissions of ${cur_dir_name} directory:"
+ echo " ${!i}"
+ echo "failed."
+ echo ""
+ echo "Either try to set it on your host-mounted directory"
+ echo "directly, or make sure that the directory has \`o+x\`"
+ echo "permissions and the files in it at least \`o+r\`."
+ } >&2
+ done
# Set permissions for application directory
chown -Rh paperless:paperless /usr/src/paperless
}