@@ -66,6 +66,14 @@ echo "**** Create the symbolic link for the /lychee-tmp folder ****"
6666 rm -r /var/www/html/Lychee/storage/tmp && \
6767 ln -s /lychee-tmp /var/www/html/Lychee/storage/tmp
6868
69+ echo " **** Create user and use PUID/PGID ****"
70+ PUID=${PUID:- 1000}
71+ PGID=${PGID:- 1000}
72+ if [ ! " $( id -u " www-data" ) " -eq " $PUID " ]; then usermod -o -u " $PUID " " www-data" ; fi
73+ if [ ! " $( id -g " www-data" ) " -eq " $PGID " ]; then groupmod -o -g " $PGID " " www-data" ; fi
74+ echo -e " \tUser UID :\t$( id -u " www-data" ) "
75+ echo -e " \tUser GID :\t$( id -g " www-data" ) "
76+
6977cd /var/www/html/Lychee
7078
7179if [ " $DB_CONNECTION " = " sqlite" ] || [ -z " $DB_CONNECTION " ]
@@ -135,15 +143,6 @@ touch -a /conf/custom.js
135143 rm /var/www/html/Lychee/public/dist/custom.js && \
136144 ln -s /conf/custom.js /var/www/html/Lychee/public/dist/custom.js
137145
138- echo " **** Create user and use PUID/PGID ****"
139- PUID=${PUID:- 1000}
140- PGID=${PGID:- 1000}
141- if [ ! " $( id -u " $USER " ) " -eq " $PUID " ]; then usermod -o -u " $PUID " " $USER " ; fi
142- if [ ! " $( id -g " $USER " ) " -eq " $PGID " ]; then groupmod -o -g " $PGID " " $USER " ; fi
143- echo -e " \tUser UID :\t$( id -u " $USER " ) "
144- echo -e " \tUser GID :\t$( id -g " $USER " ) "
145- usermod -a -G " $USER " www-data
146-
147146echo " **** Make sure Laravel's log exists ****" && \
148147touch /logs/laravel.log
149148
@@ -152,10 +151,8 @@ if [ -n "$SKIP_PERMISSIONS_CHECKS" ] && [ "${SKIP_PERMISSIONS_CHECKS,,}" = "yes"
152151else
153152 echo " **** Set Permissions ****"
154153 # Set ownership of directories, then files and only when required. See LycheeOrg/Lychee-Docker#120
155- find /sym /uploads /logs /lychee-tmp -type d \( ! -user " $USER " -o ! -group " $USER " \) -exec chown -R " $USER " :" $USER " \{\} \;
156- find /conf/.env /sym /uploads /logs /lychee-tmp \( ! -user " $USER " -o ! -group " $USER " \) -exec chown " $USER " :" $USER " \{\} \;
157- # Laravel needs to be able to chmod user.css and custom.js for no good reason
158- find /conf/user.css /conf/custom.js /logs/laravel.log \( ! -user " www-data" -o ! -group " $USER " \) -exec chown www-data:" $USER " \{\} \;
154+ find /var/www/html/Lychee /sym /uploads /logs /lychee-tmp -type d \( ! -user " www-data" -o ! -group " www-data" \) -exec chown -R " www-data" :" www-data" \{\} \;
155+ find /conf/.env /sym /uploads /logs /lychee-tmp /conf/user.css /conf/custom.js /logs/laravel.log \( ! -user " www-data" -o ! -group " www-data" \) -exec chown " www-data" :" www-data" \{\} \;
159156 find /sym /uploads /logs /lychee-tmp -type d \( ! -perm -ug+w -o ! -perm -ugo+rX -o ! -perm -g+s \) -exec chmod -R ug+w,ugo+rX,g+s \{\} \;
160157 find /conf/user.css /conf/custom.js /conf/.env /sym /uploads /logs /lychee-tmp \( ! -perm -ug+w -o ! -perm -ugo+rX \) -exec chmod ug+w,ugo+rX \{\} \;
161158fi
0 commit comments