2018-04-09 19:16:58 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
|
2018-05-03 07:06:03 +02:00
|
|
|
USERID=${USERID:=0}
|
2018-04-09 19:16:58 +02:00
|
|
|
|
|
|
|
## Configure user with a different USERID if requested.
|
2018-05-03 07:06:03 +02:00
|
|
|
if [ "$USERID" -ne 0 ]
|
2018-04-09 19:16:58 +02:00
|
|
|
then
|
|
|
|
echo "creating new user 'openedx' with UID $USERID"
|
2018-04-25 21:48:15 +02:00
|
|
|
useradd --home-dir /openedx -u $USERID openedx
|
|
|
|
|
|
|
|
# Change file permissions
|
2018-04-25 21:31:57 +02:00
|
|
|
chown --no-dereference -R openedx /openedx
|
2018-04-09 19:16:58 +02:00
|
|
|
|
|
|
|
# Run CMD as different user
|
2018-04-25 21:48:15 +02:00
|
|
|
exec chroot --userspec="$USERID" --skip-chdir / env HOME=/openedx "$@"
|
2018-04-09 19:16:58 +02:00
|
|
|
else
|
|
|
|
# Run CMD as root (business as usual)
|
|
|
|
exec "$@"
|
|
|
|
fi
|