browsertrix-crawler/docker-entrypoint.sh
Tessa Walsh b303af02ef
Add --title and --description CLI args to write metadata into datapackage.json (#276)
Multi-word values including spaces must be enclosed in double quotes.

Co-authored-by: Ilya Kreymer <ikreymer@users.noreply.github.com>
2023-04-04 10:46:03 -04:00

27 lines
636 B
Bash
Executable file

#!/bin/sh
# Get UID/GID from volume dir
VOLUME_UID=$(stat -c '%u' /crawls)
VOLUME_GID=$(stat -c '%g' /crawls)
# Get the UID/GID we are running as
MY_UID=$(id -u)
MY_GID=$(id -g)
# If we aren't running as the owner of the /crawls/ dir then add a new user
# btrix with the same UID/GID of the /crawls dir and run as that user instead.
if [ "$MY_GID" != "$VOLUME_GID" ] || [ "$MY_UID" != "$VOLUME_UID" ]; then
groupadd btrix
groupmod -o --gid $VOLUME_GID btrix
useradd -ms /bin/bash -g $VOLUME_GID btrix
usermod -o -u $VOLUME_UID btrix > /dev/null
su btrix -c '"$@"' -- argv0-ignore "$@"
else
exec "$@"
fi