From 19f7c907e08a4cd69ffecd32167a17a31f2a8566 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 16 Feb 2021 01:22:36 -0500 Subject: [PATCH] exec archivebox from docker entrypoint script to avoid nesting pid under bash --- archivebox/config.py | 1 + bin/docker_entrypoint.sh | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/archivebox/config.py b/archivebox/config.py index 9079f063..41e8c34c 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -1086,5 +1086,6 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG, sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME assert sql_index_path.exists(), ( f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)') + except KeyboardInterrupt: raise SystemExit(2) diff --git a/bin/docker_entrypoint.sh b/bin/docker_entrypoint.sh index 65a4c1f6..c924e788 100755 --- a/bin/docker_entrypoint.sh +++ b/bin/docker_entrypoint.sh @@ -3,6 +3,7 @@ DATA_DIR="${DATA_DIR:-/data}" ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}" + # Set the archivebox user UID & GID if [[ -n "$PUID" && "$PUID" != 0 ]]; then usermod -u "$PUID" "$ARCHIVEBOX_USER" > /dev/null 2>&1 @@ -11,6 +12,7 @@ if [[ -n "$PGID" && "$PGID" != 0 ]]; then groupmod -g "$PGID" "$ARCHIVEBOX_USER" > /dev/null 2>&1 fi + # Set the permissions of the data dir to match the archivebox user if [[ -d "$DATA_DIR/archive" ]]; then # check data directory permissions @@ -33,11 +35,11 @@ if [[ "$1" == /* || "$1" == "echo" || "$1" == "archivebox" ]]; then # e.g. "archivebox init" # "/bin/bash" # "echo" - gosu "$ARCHIVEBOX_USER" bash -c "$*" + exec 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 $*" + exec gosu "$ARCHIVEBOX_USER" bash -c "archivebox $*" fi