diff --git a/base-notebook/start.sh b/base-notebook/start.sh index 3f3f7ed4..a3b79d76 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -30,7 +30,8 @@ if [ $(id -u) == 0 ] ; then fi # Enable sudo if requested - if [ ! -z "$GRANT_SUDO" ]; then + if [ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]; then + echo "Granting $NB_USER sudo access" echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook fi @@ -38,6 +39,15 @@ if [ $(id -u) == 0 ] ; then echo "Execute the command as $NB_USER" exec su $NB_USER -c "env PATH=$PATH $*" else + if [[ ! -z "$NB_UID" && "$NB_UID" != "$(id -u)" ]]; then + echo 'Container must be run as root to set $NB_UID' + fi + if [[ ! -z "$NB_GID" && "$NB_GID" != "$(id -g)" ]]; then + echo 'Container must be run as root to set $NB_GID' + fi + if [ "$GRANT_SUDO" == "1" || "$GRANT_SUDO" == 'yes' ]; then + echo 'Container must be run as root to grant sudo permissions' + fi # Exec the command echo "Execute the command" exec $*