mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-26 14:10:20 +00:00
fix: Dont change GID nor UID when the owner of the volume is the root user
This commit is contained in:
parent
aa2b534624
commit
f50b44d51c
1 changed files with 8 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
||||||
DATA_DIR="${DATA_DIR:-/data}"
|
DATA_DIR="${DATA_DIR:-/data}"
|
||||||
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
||||||
|
|
||||||
|
echo $ARCHIVEBOX_USER
|
||||||
# Autodetect UID and GID of host user based on ownership of files in the volume
|
# Autodetect UID and GID of host user based on ownership of files in the volume
|
||||||
USID=$(stat --format="%u" "$DATA_DIR")
|
USID=$(stat --format="%u" "$DATA_DIR")
|
||||||
GRID=$(stat --format="%g" "$DATA_DIR")
|
GRID=$(stat --format="%g" "$DATA_DIR")
|
||||||
|
@ -13,7 +14,11 @@ COMMAND="$@"
|
||||||
# e.g. ./manage.py runserver
|
# e.g. ./manage.py runserver
|
||||||
|
|
||||||
chown "$USID":"$GRID" "$DATA_DIR"
|
chown "$USID":"$GRID" "$DATA_DIR"
|
||||||
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
|
|
||||||
usermod -u $USID $ARCHIVEBOX_USER
|
if [ $USID -ne 0 ] && [ $GRID -ne 0 ]
|
||||||
groupmod -g $GRID $ARCHIVEBOX_USER
|
then
|
||||||
|
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
|
||||||
|
usermod -u $USID $ARCHIVEBOX_USER
|
||||||
|
groupmod -g $GRID $ARCHIVEBOX_USER
|
||||||
|
fi
|
||||||
gosu $ARCHIVEBOX_USER bash -c "$COMMAND"
|
gosu $ARCHIVEBOX_USER bash -c "$COMMAND"
|
||||||
|
|
Loading…
Reference in a new issue