mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 14:33:17 +00:00

* Run in Docker as User This follows a similar pattern to pywb to run as the user that owns the crawls directory. bump version to 0.7.0-beta.6 Closes #170
27 lines
643 B
Bash
Executable file
27 lines
643 B
Bash
Executable file
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
# Get UID/GID from volume dir
|
|
VOLUME_UID=$(stat -c '%u' /crawls)
|
|
VOLUME_GID=$(stat -c '%g' /crawls)
|
|
|
|
MY_UID=$(id -u)
|
|
MY_GID=$(id -g)
|
|
|
|
# Run as custom user
|
|
if [ "$MY_GID" != "$VOLUME_GID" ] || [ "$MY_UID" != "$VOLUME_UID" ]; then
|
|
# create or modify user and group to match expected uid/gid
|
|
groupadd --gid $VOLUME_GID archivist || groupmod -o --gid $VOLUME_GID archivist
|
|
useradd -ms /bin/bash -u $VOLUME_UID -g $VOLUME_GID archivist || usermod -o -u $VOLUME_UID archivist
|
|
|
|
cmd="cd $PWD; $@"
|
|
|
|
# run process as new archivist user
|
|
su archivist -c "$cmd"
|
|
|
|
# run as current user (root)
|
|
else
|
|
exec $@
|
|
fi
|
|
|