reduce continer size ans security attack surface

This commit is contained in:
Stefan Allius
2023-10-07 16:20:40 +02:00
parent d5561d393a
commit 8264cc6d00
3 changed files with 20 additions and 25 deletions

View File

@@ -10,17 +10,15 @@ echo "#"
if [ "$user" = '0' ]; then
mkdir -p /home/$SERVICE_NAME/log /home/$SERVICE_NAME/config
if id $SERVICE_NAME ; then
echo "user still exists"
else
if ! id $SERVICE_NAME &> /dev/null; then
addgroup --gid $GID $SERVICE_NAME 2> /dev/null
adduser --ingroup $SERVICE_NAME --shell /bin/false --disabled-password --no-create-home --comment "" --uid $UID $SERVICE_NAME
adduser -G $SERVICE_NAME -s /bin/false -D -H -g "" -u $UID $SERVICE_NAME
fi
chown -R $SERVICE_NAME:$SERVICE_NAME /home/$SERVICE_NAME || true
echo "######################################################"
echo "#"
exec gosu $SERVICE_NAME "$@"
exec su-exec $SERVICE_NAME "$@"
else
exec "$@"
fi