-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_jupyterhub.sh
More file actions
executable file
·64 lines (53 loc) · 2.02 KB
/
install_jupyterhub.sh
File metadata and controls
executable file
·64 lines (53 loc) · 2.02 KB
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
#!/bin/bash
. /etc/os-release
mkdir -p /etc/code-server-hub/util/jupyterhub_workdir
# Install necessary system packages
apt-get update
apt-get install -y python3-pip python3-venv
# For Ubuntu 18.04 and older, install Python 3.8 for modern JupyterHub
if dpkg --compare-versions "$VERSION_ID" "<=" "18.04"; then
# Add deadsnakes PPA for newer Python versions
apt-get install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update
apt-get install -y python3.8 python3.8-venv python3.8-dev
PYTHON_CMD="python3.8"
else
# Ubuntu 20.04+ already has Python 3.8+
PYTHON_CMD="python3"
fi
cd /etc/code-server-hub/util/jupyterhub_workdir
# Create virtual environment with appropriate Python
$PYTHON_CMD -m venv /etc/code-server-hub/util/jupyterhub_workdir/venv
# Install packages
VENV_PATH="/etc/code-server-hub/util/jupyterhub_workdir/venv"
$VENV_PATH/bin/pip install --upgrade pip
$VENV_PATH/bin/pip install jupyter jupyterhub jupyterlab nodeenv
# Setup node environment within venv
$VENV_PATH/bin/nodeenv -p --node=lts
$VENV_PATH/bin/npm install -g configurable-http-proxy
# Create systemd service
echo "[Unit]
Description=Jupyterhub
After=syslog.target network.target
[Service]
User=root
WorkingDirectory=/etc/code-server-hub/util/jupyterhub_workdir
Environment=\"PATH=$VENV_PATH/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"
ExecStart=$VENV_PATH/bin/jupyterhub -f jupyterhub_config.py
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/jupyterhub.service
# Create JupyterHub configuration
echo "import os
c.JupyterHub.port = 18517
c.JupyterHub.ssl_key = '/etc/code-server-hub/cert/ssl.key'
c.JupyterHub.ssl_cert = '/etc/code-server-hub/cert/ssl.pem'
c.Spawner.default_url = '/lab'
c.FileCheckpoints.checkpoint_dir = os.path.expanduser('~/.ipynb_checkpoints')
c.PAMAuthenticator.open_sessions = True
c.Authenticator.allow_all = True
" > jupyterhub_config.py
# Enable and start the service
systemctl daemon-reload
systemctl enable --now jupyterhub
systemctl start jupyterhub