]> source.dussan.org Git - gitea.git/commitdiff
Launch Gitea with custom UID/GID for 'git' user (fixes #2286) (#2791)
authorHenrik Bengtsson <hb@aroma-project.org>
Sun, 5 Nov 2017 02:40:31 +0000 (19:40 -0700)
committerLunny Xiao <xiaolunwen@gmail.com>
Sun, 5 Nov 2017 02:40:31 +0000 (10:40 +0800)
docker/usr/bin/entrypoint

index a450d20607daf7302bf04c5b3d1ae409336fa209..b374c5aed756b94ae72c572b14eb17f00e421d71 100755 (executable)
@@ -1,5 +1,16 @@
 #!/bin/sh
 
+## Change GID for USER?
+if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
+    sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
+    sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd
+fi
+
+## Change UID for USER?
+if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
+    sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
+fi
+
 for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do
     mkdir -p ${FOLDER}
 done