mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-25 15:31:22 +02:00
autodetect when running inside docker and provide hints
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COMMAND="$*"
|
||||
|
||||
# Autodetect UID,GID of host user based on ownership of files in the data volume
|
||||
DATA_DIR="${DATA_DIR:-/data}"
|
||||
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
||||
@@ -18,8 +16,19 @@ if [[ "$USID" != 0 && "$GRID" != 0 ]]; then
|
||||
chown "$USID":"$GRID" "$DATA_DIR/*" > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# run django as the new archivebox user
|
||||
# any files touched will have the same uid,gid
|
||||
# inside docker and outside docker on the host
|
||||
gosu "$ARCHIVEBOX_USER" bash -c "$COMMAND"
|
||||
# e.g. "archivebox server"
|
||||
# Run commands as the new archivebox user in Docker.
|
||||
# Any files touched will have the same uid & gid
|
||||
# inside Docker and outside on the host machine.
|
||||
if [[ "$1" == /* || "$1" == "echo" || "$1" == "archivebox" ]]; then
|
||||
# arg 1 is a binary, execute it verbatim
|
||||
# e.g. "archivebox init"
|
||||
# "/bin/bash"
|
||||
# "echo"
|
||||
gosu "$ARCHIVEBOX_USER" bash -c "$*"
|
||||
else
|
||||
# no command given, assume args were meant to be passed to archivebox cmd
|
||||
# e.g. "add https://example.com"
|
||||
# "manage createsupseruser"
|
||||
# "server 0.0.0.0:8000"
|
||||
gosu "$ARCHIVEBOX_USER" bash -c "archivebox $*"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user