forked from kleinee/jns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_jupyter.sh
executable file
·45 lines (38 loc) · 1.26 KB
/
configure_jupyter.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
#!/bin/bash
# script name: configure_jupyter.sh
# last modified: 2015/09/30
# sudo: no
if [ $(id -u) = 0 ]
then
echo "to be run as jns"
exit 1
fi
# generate config and create notebook directory
jupyter notebook --generate-config
cd $home
mkdir -p notebooks
target=~/.jupyter/jupyter_notebook_config.py
# get current ip address - we assume it is static
#ip=$(echo $(hostname -I))
ip='0.0.0.0'
# set up dictionary of changes for jupyter_config.py
declare -A arr
app='c.NotebookApp'
arr+=(["$app.open_browser"]="$app.open_browser = False")
arr+=(["$app.ip"]="$app.ip ='$ip'")
arr+=(["$app.port"]="$app.port = 9090")
arr+=(["$app.enable_mathjax"]="$app.enable_mathjax = True")
arr+=(["$app.notebook_dir"]="$app.notebook_dir = '/home/jns/notebooks'")
arr+=(["$app.password"]="$app.password = 'sha1:5815fb7ca805:f09ed218dfcc908acb3e29c3b697079fea37486a'")
arr+=(["$app.server_extensions.append"]="$app.server_extensions.append('ipyparallel.nbextension')")
# apply changes to jupyter_notebook_config.py
# change or append
for key in ${!arr[@]};do
if grep -qF $key ${target}; then
# key found -> replace line
sed -i "/${key}/c ${arr[${key}]}" $target
else
# key not found -> append line
echo "${arr[${key}]}" >> $target
fi
done