-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvncserver-jupyternotebook-setup-ubuntu-16.04.sh
131 lines (87 loc) · 3.14 KB
/
vncserver-jupyternotebook-setup-ubuntu-16.04.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -e
#installing packages
SCRIPT_USER=$USER
SCRIPT_HOME=$HOME
printf "\nInstalling required packages\n"
sudo apt update && sudo apt -y install unzip xfce4 xfce4-goodies xfonts-base xfonts-75dpi xfonts-100dpi tightvncserver python2.7 python-pip
sudo python2.7 -m pip install jupyter pandas
#killing services / processes
if systemctl is-active [email protected]; then \
sudo systemctl stop [email protected] && printf "\[email protected] stopped\n"; \
elif pgrep vnc; then \
sudo pkill vnc;
fi
if systemctl is-active jupyter-notebook.service; then \
sudo systemctl stop jupyter-notebook.service && printf "\jupyter-notebook.service stopped\n"; \
elif pgrep jupyter; then \
sudo pkill jupyter;
fi
#setting up vnc server
touch $SCRIPT_HOME/.Xresources && touch $SCRIPT_HOME/.Xauthority
if [ ! -f $SCRIPT_HOME/.vnc/passwd ]; then
printf "\nEnter Password for VNC Dekstop\n"
fi
vncserver :1 && vncserver -kill :1
if [ ! -f $SCRIPT_HOME/.vnc/xstartup.bk ]; then
mv $SCRIPT_HOME/.vnc/xstartup $SCRIPT_HOME/.vnc/xstartup.bk
fi
cat > $SCRIPT_HOME/.vnc/xstartup << EOL
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
/etc/X11/Xsession
export XKL_XMODMAP_DISABLE=1
EOL
chmod a+x $SCRIPT_HOME/.vnc/xstartup
#setting up jupyter notebook
if [ ! -f $SCRIPT_HOME/.jupyter/jupyter_notebook_config.py ]; then
jupyter notebook --generate-config
fi
if [ ! -f $SCRIPT_HOME/.jupyter/jupyter_notebook_config.json ]; then
printf "\nEnter Password for Jupyter notebook\n" && jupyter notebook password
fi
printf "\nAdding services for VNC server and Jupyter Notebook\n"
sudo bash -c "cat > /etc/systemd/system/[email protected] << EOL
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=${SCRIPT_USER}
PAMName=login
PIDFile=${SCRIPT_HOME}/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i
ExecStop=/usr/bin/vncserver -kill :%i
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOL"
sudo bash -c "cat > /etc/systemd/system/jupyter-notebook.service << EOL
[Unit]
Description=Jupyter Notebook
After=syslog.target network.target
[Service]
Type=simple
User=${SCRIPT_USER}
PIDFile=${SCRIPT_HOME}/.jupyter/jupyter.pid
ExecStart=/usr/local/bin/jupyter notebook --config=${SCRIPT_HOME}/.jupyter/jupyter_notebook_config.py --no-browser --ip=0.0.0.0 --port=8888
WorkingDirectory=${SCRIPT_HOME}
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOL"
sudo systemctl daemon-reload \
&& sudo systemctl enable [email protected] && sudo systemctl enable jupyter-notebook.service \
&& sudo systemctl start vncserver@1 && sudo systemctl start jupyter-notebook.service
#setting up TWS and IBridgePy
#TWS
curl -s -O https://download2.interactivebrokers.com/installers/tws/stable/tws-stable-linux-x64.sh
chmod a+x tws-stable-linux-x64.sh
echo "n" | ./tws-stable-linux-x64.sh
#ibridgepy
mkdir -p i-bridge-py && curl -s http://www.ibridgepy.com/wp-content/uploads/2018/08/IBridgePy_Ubuntu_Python27_64.zip -o i-bridge-py/IBridgePy_Ubuntu_Python27_64.zip
unzip -o i-bridge-py/IBridgePy_Ubuntu_Python27_64.zip -d i-bridge-py/