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
|
2022-04-26 09:24:59 +00:00
|
|
|
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
|
2022-04-26 09:24:59 +00:00
|
|
|
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
|
|
|
|
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
|
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
|
2022-01-30 16:14:57 +00:00
|
|
|
# set -x
|
2022-01-28 17:41:34 +00:00
|
|
|
if [ -f mkdocs-patch.yml ]; then
|
2022-04-26 09:24:59 +00:00
|
|
|
# patch reference mkdocs with user-provided options
|
2022-01-30 16:14:57 +00:00
|
|
|
yq eval-all '. as $item ireduce ({}; . * $item)' \
|
2022-04-26 09:24:59 +00:00
|
|
|
mkdocs-source.yml \
|
|
|
|
mkdocs-patch.yml \
|
|
|
|
> mkdocs.yml
|
2022-01-30 16:14:57 +00:00
|
|
|
else
|
2022-04-26 09:24:59 +00:00
|
|
|
# use reference mkdocs only (no options)
|
|
|
|
ln -s mkdocs-source.yml mkdocs.yml
|
2022-01-28 17:41:34 +00:00
|
|
|
fi
|
2022-01-30 16:14:57 +00:00
|
|
|
# set +x
|
2022-01-28 17:41:34 +00:00
|
|
|
|
2024-09-22 23:03:10 +00:00
|
|
|
if [ "$1" = "supershell" ]; then
|
2022-04-26 09:24:59 +00:00
|
|
|
exec bash
|
2021-12-06 10:47:53 +00:00
|
|
|
else
|
2022-04-26 09:24:59 +00:00
|
|
|
exec gosu "$EXT_UID:$EXT_GID" make "$@"
|
2021-12-06 10:47:53 +00:00
|
|
|
fi
|