-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-notebook.sh
executable file
·46 lines (37 loc) · 1.44 KB
/
start-notebook.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# Load bash libraries
SCRIPT_DIR=/opt/app-root/bin
source ${SCRIPT_DIR}/utils/process.sh
if [ -f "${SCRIPT_DIR}/utils/setup-elyra.sh" ]; then
source ${SCRIPT_DIR}/utils/setup-elyra.sh
fi
# Initialize notebooks arguments variable
NOTEBOOK_PROGRAM_ARGS=""
# Set default ServerApp.port value if NOTEBOOK_PORT variable is defined
if [ -n "${NOTEBOOK_PORT}" ]; then
NOTEBOOK_PROGRAM_ARGS+="--ServerApp.port=${NOTEBOOK_PORT} "
fi
# Set default ServerApp.base_url value if NOTEBOOK_BASE_URL variable is defined
if [ -n "${NOTEBOOK_BASE_URL}" ]; then
NOTEBOOK_PROGRAM_ARGS+="--ServerApp.base_url=${NOTEBOOK_BASE_URL} "
fi
# Set default ServerApp.root_dir value if NOTEBOOK_ROOT_DIR variable is defined
if [ -n "${NOTEBOOK_ROOT_DIR}" ]; then
NOTEBOOK_PROGRAM_ARGS+="--ServerApp.root_dir=${NOTEBOOK_ROOT_DIR} "
else
NOTEBOOK_PROGRAM_ARGS+="--ServerApp.root_dir=${HOME} "
fi
# Add additional arguments if NOTEBOOK_ARGS variable is defined
if [ -n "${NOTEBOOK_ARGS}" ]; then
NOTEBOOK_PROGRAM_ARGS+=${NOTEBOOK_ARGS}
fi
# Add .bashrc for custom promt if not present
if [ ! -f "/opt/app-root/src/.bashrc" ]; then
echo 'PS1="\[\033[34;1m\][\$(pwd)]\[\033[0m\]\n\[\033[1;0m\]$ \[\033[0m\]"' > /opt/app-root/src/.bashrc
fi
# Start the JupyterLab notebook
start_process jupyter lab ${NOTEBOOK_PROGRAM_ARGS} \
--ServerApp.ip=0.0.0.0 \
--ServerApp.allow_origin="*" \
--ServerApp.open_browser=False \
--ServerApp.allow_root=True