Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making references to home directory more dynamic #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions config/jupyter/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import json
import os
import sys
sys.path.append('/root/.jupyter/extensions/')

home = os.environ['HOME']
jupyterPrefs_dir = '{0}/.jupyter/'.format(home)
jP_static = jupyterPrefs_dir + 'static'
jP_extensions = jupyterPrefs_dir + 'extensions/'
jP_nbconfig_json = jupyterPrefs_dir + 'nbconfig/common.json'

sys.path.append(jupyterPrefs_dir)

c.JupyterApp.ip = '*'
c.JupyterApp.port = 80
c.JupyterApp.open_browser = False
c.JupyterApp.allow_credentials = True
c.JupyterApp.nbserver_extensions = ['jupyter_nbgallery.status', 'jupyter_nbgallery.post']
c.JupyterApp.reraise_server_extension_failures = True
c.JupyterApp.extra_static_paths = ['/root/.jupyter/static']
c.JupyterApp.extra_nbextensions_path = ['/root/.jupyter/extensions/']
c.JupyterApp.extra_static_paths = [jP_static]
c.JupyterApp.extra_nbextensions_path = [jP_extensions]
c.JupyterApp.tornado_settings = {'static_url_prefix': '/Jupyter/static/'}
c.JupyterApp.allow_origin = 'https://localhost:3000'

Expand All @@ -23,10 +30,10 @@
c.JupyterApp[var[len(config_prefix):].lower()] = os.environ[var]

def load_config():
return json.loads(open('/root/.jupyter/nbconfig/common.json').read())
return json.loads(open(jP_nbconfig_json).read())

def save_config(config):
with open('/root/.jupyter/nbconfig/common.json', 'w') as output:
with open(jP_nbconfig_json) as output:
output.write(json.dumps(config, indent=2))

# Override gallery location
Expand Down
34 changes: 18 additions & 16 deletions util/jupyter-notebook-secure
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#!/bin/bash
CERTS_PATH=/etc/pki/tls/certs

mkdir -p /etc/pki/tls/certs/
mkdir -p $CERTS_PATH

if [ ! -f $CERTS_PATH/server.pem ]; then
echo "Generating certificates ..."
openssl req \
-nodes \
-x509 \
-days 3650 \
-newkey rsa \
-keyout $CERTS_PATH/server.key \
-out $CERTS_PATH/server.pem \
-subj "/C=US/ST=CO/L=Denver/O=nbgallery/CN=nbgallery team/[email protected]"

if [ ! -f /etc/pki/tls/certs/server.pem ]; then
echo "Generating certificates ..."
openssl req \
-nodes \
-x509 \
-days 3650 \
-newkey rsa \
-keyout /etc/pki/tls/certs/server.key \
-out /etc/pki/tls/certs/server.pem \
-subj "/C=US/ST=CO/L=Denver/O=nbgallery/CN=nbgallery team/[email protected]"
fi

exec jupyter notebook \
--certfile=/etc/pki/tls/certs/server.pem \
--keyfile=/etc/pki/tls/certs/server.key \
--JupyterApp.port=443 \
--JupyterApp.ssl_options="{'ssl_version':5}" \
--allow-root
--certfile=$CERTS_PATH/server.pem \
--keyfile=$CERTS_PATH/server.key \
--JupyterApp.port=443 \
--JupyterApp.ssl_options="{'ssl_version':5}" \
--allow-root