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-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-06 10:10:43 +00:00
|
|
|
if [ -d "_build" ]; then
|
|
|
|
chown -R "$EXT_UID:$EXT_GID" _build
|
2021-12-06 11:22:19 +00:00
|
|
|
chown -R "$EXT_UID:$EXT_GID" .marp
|
2021-12-06 10:10:43 +00:00
|
|
|
fi
|
2021-11-30 20:58:34 +00:00
|
|
|
|
2021-12-06 10:47:53 +00:00
|
|
|
if [ "$1" = "shell" ]; then
|
|
|
|
exec bash
|
|
|
|
else
|
|
|
|
exec gosu "$EXT_UID:$EXT_GID" make "$@"
|
|
|
|
fi
|