-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathstart-notebook.sh
executable file
·44 lines (34 loc) · 1.72 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
#!/bin/bash
log="/tmp/startnotebook.log"
echo "$(date +'%m-%d-%y %H:%M:%S') Starting Notebook" > $log
echo "$(date +'%m-%d-%y %H:%M:%S') Enabling ipywidgets: http://ipywidgets.readthedocs.io/en/latest/user_install.html" >> $log
jupyter nbextension enable --py widgetsnbextension --sys-prefix &>> $log
echo "$(date +'%m-%d-%y %H:%M:%S') Enabling RISE: https://github.com/damianavila/RISE" >> $log
jupyter nbextension install rise --py --sys-prefix
jupyter nbextension enable rise --py --sys-prefix
# Handle special flags if we're root
if [ $UID == 0 ] ; then
# Change UID of NB_USER to NB_UID if it does not match
if [ "$NB_UID" != $(id -u $NB_USER) ] ; then
usermod -u $NB_UID $NB_USER
chown -R $NB_UID $CONDA_DIR .
fi
# Enable sudo if requested
if [ ! -z "$GRANT_SUDO" ]; then
echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
fi
echo "$(date +'%m-%d-%y %H:%M:%S') exec su $NB_USER -c \"env PATH=$PATH /opt/conda/envs/python2/bin/jupyter notebook $*\"" >> $log
# Start the notebook server
exec su $NB_USER -c "env PATH=$PATH /opt/conda/envs/python2/bin/jupyter notebook $*" &>> $log
else
# Otherwise just exec the notebook
if [[ "${ENV_JUPYTER_PASSWORD}" == "" ]]; then
echo "$(date +'%m-%d-%y %H:%M:%S') exec /opt/conda/envs/python2/bin/jupyter notebook --NotebookApp.token='' $*" >> $log
exec /opt/conda/envs/python2/bin/jupyter notebook --NotebookApp.token='' $* &>> $log
else
echo "$(date +'%m-%d-%y %H:%M:%S') exec /opt/conda/envs/python2/bin/jupyter notebook $*" >> $log
exec /opt/conda/envs/python2/bin/jupyter notebook $* &>> $log
fi
fi
echo "$(date +'%m-%d-%y %H:%M:%S') Done Starting Notebook" >> $log
tail -f $log