fix entrypoint chowning
This commit is contained in:
parent
a677ef7113
commit
019c012951
1 changed files with 7 additions and 9 deletions
|
@ -1,20 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DATA_DIR="${DATA_DIR:-/data}"
|
export DATA_DIR="${DATA_DIR:-/data}"
|
||||||
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
export ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
||||||
|
|
||||||
export PUID=${PUID:-911}
|
export PUID=${PUID:-911}
|
||||||
export PGID=${PGID:-911}
|
export PGID=${PGID:-911}
|
||||||
|
|
||||||
# Set the archivebox user UID & GID
|
# Set the archivebox user UID & GID
|
||||||
usermod -o -u "$PUID" "$ARCHIVEBOX_USER" > /dev/null 2>&1
|
|
||||||
groupmod -o -g "$PGID" "$ARCHIVEBOX_USER" > /dev/null 2>&1
|
groupmod -o -g "$PGID" "$ARCHIVEBOX_USER" > /dev/null 2>&1
|
||||||
|
usermod -o -u "$PUID" "$ARCHIVEBOX_USER" > /dev/null 2>&1
|
||||||
|
|
||||||
export PUID="$(id -u archivebox)"
|
export PUID="$(id -u archivebox)"
|
||||||
export PGID="$(id -g archivebox)"
|
export PGID="$(id -g archivebox)"
|
||||||
|
|
||||||
chown $ARCHIVEBOX_USER:$ARCHIVEBOX_USER "$DATA_DIR"
|
|
||||||
|
|
||||||
# Check the permissions of the data dir (or create if it doesn't exist)
|
# Check the permissions of the data dir (or create if it doesn't exist)
|
||||||
if [[ -d "$DATA_DIR/archive" ]]; then
|
if [[ -d "$DATA_DIR/archive" ]]; then
|
||||||
if touch "$DATA_DIR/archive/.permissions_test_safe_to_delete" 2>/dev/null; then
|
if touch "$DATA_DIR/archive/.permissions_test_safe_to_delete" 2>/dev/null; then
|
||||||
|
@ -36,7 +33,8 @@ fi
|
||||||
|
|
||||||
# force set the ownership of the data dir contents to the archivebox user and group
|
# force set the ownership of the data dir contents to the archivebox user and group
|
||||||
# this is needed because Docker Desktop often does not map user permissions from the host properly
|
# this is needed because Docker Desktop often does not map user permissions from the host properly
|
||||||
chown $ARCHIVEBOX_USER:$ARCHIVEBOX_USER "$DATA_DIR"/*
|
chown $PUID:$PGID "$DATA_DIR"
|
||||||
|
chown $PUID:$PGID "$DATA_DIR"/*
|
||||||
|
|
||||||
# Drop permissions to run commands as the archivebox user
|
# Drop permissions to run commands as the archivebox user
|
||||||
if [[ "$1" == /* || "$1" == "bash" || "$1" == "sh" || "$1" == "echo" || "$1" == "cat" || "$1" == "archivebox" ]]; then
|
if [[ "$1" == /* || "$1" == "bash" || "$1" == "sh" || "$1" == "echo" || "$1" == "cat" || "$1" == "archivebox" ]]; then
|
||||||
|
@ -44,11 +42,11 @@ if [[ "$1" == /* || "$1" == "bash" || "$1" == "sh" || "$1" == "echo" || "$1" ==
|
||||||
# e.g. "docker run archivebox /venv/bin/archivebox-alt init"
|
# e.g. "docker run archivebox /venv/bin/archivebox-alt init"
|
||||||
# "docker run archivebox /bin/bash -c '...'"
|
# "docker run archivebox /bin/bash -c '...'"
|
||||||
# "docker run archivebox echo test"
|
# "docker run archivebox echo test"
|
||||||
exec gosu "$ARCHIVEBOX_USER" bash -c "$*"
|
exec gosu "$PUID" bash -c "$*"
|
||||||
else
|
else
|
||||||
# handle "docker run archivebox add ..." by running args as archivebox $subcommand
|
# handle "docker run archivebox add ..." by running args as archivebox $subcommand
|
||||||
# e.g. "docker run archivebox add https://example.com"
|
# e.g. "docker run archivebox add https://example.com"
|
||||||
# "docker run archivebox manage createsupseruser"
|
# "docker run archivebox manage createsupseruser"
|
||||||
# "docker run archivebox server 0.0.0.0:8000"
|
# "docker run archivebox server 0.0.0.0:8000"
|
||||||
exec gosu "$ARCHIVEBOX_USER" bash -c "archivebox $*"
|
exec gosu "$PUID" bash -c "archivebox $*"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue