docmachine-containers/docker/entrypoint.sh

54 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-10-10 09:21:36 +00:00
#!/bin/sh
2021-11-30 13:02:48 +00:00
set -u
set -e
2021-10-10 09:21:36 +00:00
ARGS="$*"
echo "Arguments: $ARGS"
2021-11-30 13:02:48 +00:00
EXT_UID=${EXT_UID:-999}
EXT_GID=${EXT_GID:-999}
2021-12-21 15:39:51 +00:00
# Create missing directories
mkdir -p _cache
mkdir -p _build
mkdir -p .marp
mkdir -p /home/appuser
2021-12-21 15:39:51 +00:00
2021-12-06 13:59:59 +00:00
# Create user with given ID if needed
2021-11-30 14:16:01 +00:00
if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/group ; then
groupadd -g "$EXT_GID" appuser
2021-11-30 14:01:01 +00:00
fi
2021-12-06 13:59:59 +00:00
# Create group with given ID if needed
2021-11-30 14:16:01 +00:00
if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/passwd ; then
useradd -r -u "$EXT_UID" -g appuser appuser
2021-11-30 14:01:01 +00:00
fi
2021-11-30 13:02:48 +00:00
chown -R "$EXT_UID:$EXT_GID" _cache
chown -R "$EXT_UID:$EXT_GID" _build
chown -R "$EXT_UID:$EXT_GID" .marp
chown -R "$EXT_UID:$EXT_GID" /home/appuser
2024-09-22 23:39:46 +00:00
chown -R "$EXT_UID:$EXT_GID" slides
chown -R "$EXT_UID:$EXT_GID" docs
2021-11-30 20:58:34 +00:00
2022-01-28 17:41:34 +00:00
# Patch mkdocs configuration
# set -x
2022-01-28 17:41:34 +00:00
if [ -f mkdocs-patch.yml ]; then
# patch reference mkdocs with user-provided options
yq eval-all '. as $item ireduce ({}; . * $item)' \
mkdocs-source.yml \
mkdocs-patch.yml \
> mkdocs.yml
else
# use reference mkdocs only (no options)
ln -s mkdocs-source.yml mkdocs.yml
2022-01-28 17:41:34 +00:00
fi
# set +x
2022-01-28 17:41:34 +00:00
2024-09-22 23:03:10 +00:00
if [ "$1" = "supershell" ]; then
exec bash
else
exec gosu "$EXT_UID:$EXT_GID" make "$@"
fi