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