-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash.sh
30 lines (26 loc) · 1.13 KB
/
bash.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
#!/bin/bash
CERTIFICATE_DIR="/home/ubuntu/certificate"
JUPYTER_CONFIG_DIR="/home/ubuntu/.jupyter"
if [ ! -d "$CERTIFICATE_DIR" ]; then
mkdir $CERTIFICATE_DIR
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "$CERTIFICATE_DIR/mykey.key" -out "$CERTIFICATE_DIR/mycert.pem" -batch
chown -R ubuntu $CERTIFICATE_DIR
fi
if [ ! -f "$JUPYTER_CONFIG_DIR/jupyter_notebook_config.py" ]; then
# generate default config file
#jupyter notebook --generate-config
mkdir $JUPYTER_CONFIG_DIR
# append notebook server settings
cat <<EOF >> "$JUPYTER_CONFIG_DIR/jupyter_notebook_config.py"
# Set options for certfile, ip, password, and toggle off browser auto-opening
c.NotebookApp.certfile = u'$CERTIFICATE_DIR/mycert.pem'
c.NotebookApp.keyfile = u'$CERTIFICATE_DIR/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:b7399b2a221d:a332c539a780d39c8d5094de047d0b64585b10a8'
c.NotebookApp.open_browser = False
# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8888
EOF
chown -R ubuntu $JUPYTER_CONFIG_DIR
fi