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
|
2021-12-21 16:25:50 +00:00
|
|
|
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
|
2021-11-30 14:01:01 +00:00
|
|
|
groupadd -g "$EXT_GID" appuser
|
|
|
|
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
|
2021-11-30 14:01:01 +00:00
|
|
|
useradd -r -u "$EXT_UID" -g appuser appuser
|
|
|
|
fi
|
2021-11-30 13:02:48 +00:00
|
|
|
|
2021-12-21 16:25:50 +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
|
2021-11-30 20:58:34 +00:00
|
|
|
|
2022-01-28 17:41:34 +00:00
|
|
|
# Patch mkdocs configuration
|
|
|
|
if [ -f mkdocs-patch.yml ]; then
|
|
|
|
yq \
|
|
|
|
eval-all
|
|
|
|
'. as $item ireduce ({}; . * $item)' \
|
|
|
|
mkdocs-source.yml \
|
|
|
|
mkdocs-patch.yml \
|
|
|
|
> mkdocs.yml
|
|
|
|
fi
|
|
|
|
|
2021-12-06 10:47:53 +00:00
|
|
|
if [ "$1" = "shell" ]; then
|
|
|
|
exec bash
|
|
|
|
else
|
|
|
|
exec gosu "$EXT_UID:$EXT_GID" make "$@"
|
|
|
|
fi
|