browsertrix-crawler/docker-entrypoint.sh
Ilya Kreymer bc4a95883d
clear out core dumps to avoid using up volume space: (#740)
- add 'ulimit -c' to startup script
- delete any './core' files that exist in working dir just in case
- fixes #738
2025-01-16 15:50:59 -08:00

30 lines
657 B
Bash
Executable file

#!/bin/sh
# disable core dumps
ulimit -c 0
# 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
exec gosu btrix:btrix "$@"
else
exec "$@"
fi