diff --git a/JupyterNotebook/files/entrypoint.sh b/JupyterNotebook/files/entrypoint.sh index 24e59f04b9b78dad7f27dae437ccddf3332c6935..535d24b1c6fc94c0c5c28047159980004bcb0422 100644 --- a/JupyterNotebook/files/entrypoint.sh +++ b/JupyterNotebook/files/entrypoint.sh @@ -1,22 +1,37 @@ #/bin/bash -# Set port -if [ "x$BASE_PORT" == "x" ]; then - BASE_PORT=8888 - echo "[INFO] using default Notebook server port (8888)" -else - echo "[INFO] Setting Notebook server port to $BASE_PORT" -fi +if [[ "x$@" == "x" ]] ; then -# Set password -if [ "x$AUTH_PASS" == "x" ]; then - echo "[INFO] Not using anyNotebook server password" + # Set port (defaults to 8888) + if [ "x$BASE_PORT" == "x" ]; then + BASE_PORT=8888 + echo "[INFO] using default Notebook server port (8888)" + else + echo "[INFO] Setting Notebook server port to $BASE_PORT" + fi + + # Set password (defaults to none) + if [ "x$AUTH_PASS" == "x" ]; then + echo "[INFO] Not using anyNotebook server password" + else + echo "[INFO] Setting Notebook server password to $AUTH_PASS" + fi + + # Set base dir (defaults to root). + if [ "x$BASE_DIR" == "x" ]; then + BASE_DIR='/' + else + BASE_DIR="'$BASE_DIR'" + fi + + # Run the Jupyter Notebook server. Use --allow-root if need to run as root. + exec jupyter notebook --ip=0.0.0.0 --port=$BASE_PORT --no-browser --NotebookApp.token=$AUTH_PASS --NotebookApp.notebook_dir=$BASE_DIR + else - echo "[INFO] Setting Notebook server password to $AUTH_PASS" -fi - -# Create Notebooks dir if not existent -mkdir -p /home/metauser/notebooks -# Run the Jupyter Notebook server. Use --allow-root if need to run as root. -exec jupyter notebook --ip=0.0.0.0 --port=$BASE_PORT --no-browser --NotebookApp.token=$AUTH_PASS --NotebookApp.notebook_dir='/home/metauser/notebooks' + ENTRYPOINT_COMMAND=$@ + echo -n "Executing Docker entrypoint command: " + echo $ENTRYPOINT_COMMAND + exec /bin/bash -c "$ENTRYPOINT_COMMAND" + +fi \ No newline at end of file