Commit 459e68c2 authored by Peter Parente's avatar Peter Parente Committed by GitHub

Merge pull request #688 from rkdarst/pre-start-hook

Add a posibliity for a pre-start hook
parents 8ccdfc1d 6fa9a4a1
......@@ -11,22 +11,33 @@ else
cmd=$*
fi
for f in /usr/local/bin/start-notebook.d/*; do
run-hooks () {
# Source scripts or run executable files in a directory
if [[ ! -d "$1" ]] ; then
return
fi
echo "$0: running hooks in $1"
for f in "$1"/*; do
case "$f" in
*.sh)
echo "$0: running $f"; . "$f"
echo "$0: running $f"
source "$f"
;;
*)
if [ -x $f ]; then
if [[ -x "$f" ]] ; then
echo "$0: running $f"
$f
"$f"
else
echo "$0: ignoring $f"
fi
;;
esac
echo
done
echo "$0: done running hooks in $1"
done
}
run-hooks /usr/local/bin/start-notebook.d
# Handle special flags if we're root
if [ $(id -u) == 0 ] ; then
......@@ -89,6 +100,7 @@ if [ $(id -u) == 0 ] ; then
# Exec the command as NB_USER with the PATH and the rest of
# the environment preserved
run-hooks /usr/local/bin/before-notebook.d
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
......@@ -132,6 +144,7 @@ else
fi
# Execute the command
run-hooks /usr/local/bin/before-notebook.d
echo "Executing the command: $cmd"
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