2022-02-25 08:03:42 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-06-07 11:33:55 +00:00
|
|
|
# This is important in order to provide enough locked memory to dragonfly
|
|
|
|
# when running on kernels < 5.12.
|
|
|
|
# This line should reside before `set -e` so it could fail silently
|
|
|
|
# in case the container runs in non-privileged mode.
|
|
|
|
ulimit -l 65000 2> /dev/null
|
|
|
|
|
2022-02-25 08:03:42 +00:00
|
|
|
set -e
|
|
|
|
|
2022-04-08 05:54:53 +00:00
|
|
|
# first arg is `-some-option`
|
2022-02-25 08:03:42 +00:00
|
|
|
if [ "${1#-}" != "$1" ]; then
|
2022-04-08 05:54:53 +00:00
|
|
|
# override arguments by prepending "dragonfly --logtostderr" to them.
|
2024-08-22 08:33:29 +00:00
|
|
|
set -- dragonfly --logtostderr "$@"
|
2022-02-25 08:03:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# allow the docker container to be started with `--user`
|
|
|
|
if [ "$1" = 'dragonfly' -a "$(id -u)" = '0' ]; then
|
2024-08-22 08:33:29 +00:00
|
|
|
# find all the files in the WORKDIR including the dir itself that do not
|
|
|
|
# have dfly user on them and chmod them to dfly.
|
|
|
|
find . \! -user dfly -exec chown dfly '{}' +
|
|
|
|
# runs this script under user dfly
|
|
|
|
exec setpriv --reuid=dfly --regid=dfly --clear-groups -- "$0" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
um="$(umask)"
|
|
|
|
if [ "$um" = '0022' ]; then
|
|
|
|
umask 0077 # restrict access permissions only to the owner
|
2022-02-25 08:03:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec "$@"
|