Commit a73212ea authored by Richard Darst's avatar Richard Darst

Add a posibliity for a pre-start hook

- The start.sh script does different operations on users, and
  sometimes one may need to do operations *after* that is done (as
  opposed to /usr/local/bin/start-notebook.d/ which is run before).
  This provides that possibility.  (One use case is hooks which must
  be run after the users are set up.)
- To be technically perfect, one might want to use something similar
  to /usr/local/bin/pre-start-notebook.d/.  But let's start with the
  simplest thing possible for now - the expected use of this command
  is only if people use NB_USER, etc in a way that requires small
  follow up commands to be run.
- If notebook is running as root, this allows users to run arbitrary
  commands pre-sudo.  Consider security model.
parent 8ccdfc1d
......@@ -89,6 +89,7 @@ if [ $(id -u) == 0 ] ; then
# Exec the command as NB_USER with the PATH and the rest of
# the environment preserved
eval "$NB_PRE_START_HOOK"
echo "Executing the command: $cmd"
exec sudo -E -H -u $NB_USER PATH=$PATH XDG_CACHE_HOME=/home/$NB_USER/.cache PYTHONPATH=$PYTHONPATH $cmd
else
......@@ -133,5 +134,6 @@ else
# Execute the command
echo "Executing the command: $cmd"
eval "$NB_PRE_START_HOOK"
exec $cmd
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment