2018-04-09 17:16:58 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
|
2018-05-03 05:06:03 +00:00
|
|
|
USERID=${USERID:=0}
|
2018-04-09 17:16:58 +00:00
|
|
|
|
|
|
|
## Configure user with a different USERID if requested.
|
2018-05-03 05:06:03 +00:00
|
|
|
if [ "$USERID" -ne 0 ]
|
2018-04-09 17:16:58 +00:00
|
|
|
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
|