Skip to content

Commit

Permalink
Make permission fixing optional (but default) (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
siliconfeces authored Oct 7, 2023
1 parent 9305a38 commit 0397d25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion tools/build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 \
# Enable automatic http proxy detection for mojo
MOJO_PROXY=1 \
# Allow Mojo to automatically pick up the X-Forwarded-For and X-Forwarded-Proto headers
MOJO_REVERSE_PROXY=1
MOJO_REVERSE_PROXY=1 \
# Attempt to fix file permissions automatically
LRR_AUTOFIX_PERMISSIONS=1

RUN \
if [ $(getent group ${LRR_GID}) ]; then \
Expand Down
21 changes: 14 additions & 7 deletions tools/build/docker/s6/cont-init.d/01-lrr-setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

USER_ID=${LRR_UID}
GROUP_ID=${LRR_GID}
FIX_PERMS=${LRR_AUTOFIX_PERMISSIONS:-1}

echo "Starting LANraragi with UID/GID : $USER_ID/$GROUP_ID"

#Update the koyomi user, using the specified uid/gid.
#This solves permission problems on the content folder if the Docker user sets the same uid as the owner of the folder.
usermod -o -u $USER_ID koyomi
groupmod -o -g $GROUP_ID koyomi

#Ensure LRR folder is writable
chown koyomi /home/koyomi/lanraragi
chmod u+rwx /home/koyomi/lanraragi

#Crash with an error if content folder doesn't exist
if [ ! -d "/home/koyomi/lanraragi/content" ]; then
Expand All @@ -24,10 +22,19 @@ fi
chown -R koyomi /home/koyomi/lanraragi/database
chmod -R u+rwx /home/koyomi/lanraragi/database

#Ensure thumbnail folder is writable
chown -R koyomi /home/koyomi/lanraragi/content/thumb
find /home/koyomi/lanraragi/content/thumb -type f -exec chmod u+rw {} \;
find /home/koyomi/lanraragi/content/thumb -type d -exec chmod u+rwx {} \;
if [ "$FIX_PERMS" -eq 1 ]; then
echo "Fixing permissions, hold on!"
#Ensure thumbnail folder is writable
chown -R koyomi /home/koyomi/lanraragi/content/thumb
find /home/koyomi/lanraragi/content/thumb -type f -exec chmod u+rw {} \;
find /home/koyomi/lanraragi/content/thumb -type d -exec chmod u+rwx {} \;

# Ensure the rest of the content folder is at least readable
find /home/koyomi/lanraragi/content -name thumb -prune -o -type f -exec chmod u+r {} \;
find /home/koyomi/lanraragi/content -name thumb -prune -o -type d -exec chmod u+rx {} \;
else
echo "Not touching permissions"
fi

#Ensure log folder is writable
mkdir /home/koyomi/lanraragi/log
Expand Down

0 comments on commit 0397d25

Please sign in to comment.