#!/bin/bash #variant to use conda insted of pip, not tested #Src: https://medium.com/swlh/how-to-install-jupyterhub-using-conda-without-runing-as-root-and-make-it-a-service-59b843fead12 # https://jupyterhub.readthedocs.io/en/1.2.1/installation-guide-hard.html set -e if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi CERTIFICATE_HOSTNAME=$1 if [ -z "$CERTIFICATE_HOSTNAME" ] then echo "Please specify hostname for the certificate generation" exit fi #apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0 \ # libnvinfer-dev=7.1.3-1+cuda11.0 \ # libnvinfer-plugin7=7.1.3-1+cuda11.0 #add public ssh keys #if [ ! -s "~/.ssh/authorized_keys" ]; then # cat id_*.pub >> ~/.ssh/authorized_keys #fi #echo "" #echo "Install supermicro system tools..." #apt-get update #apt-get install -y ipmitool && modprobe ipmi_devintf apt-get update apt-get install -y language-pack-de python3.10-venv echo "Install a recent notejs for jupyterhub from nodesource..." #src: https://github.com/nodesource/distributions/blob/master/README.md curl -fsSL https://deb.nodesource.com/setup_current.x | bash - apt-get install -y nodejs echo "create virtualenv and install JupyterHub..." python3 -m venv /opt/jupyterhub/ /opt/jupyterhub/bin/python3 -m pip install wheel /opt/jupyterhub/bin/python3 -m pip install jupyterhub jupyterlab /opt/jupyterhub/bin/python3 -m pip install ipywidgets npm install -g configurable-http-proxy echo "setup jupyterhub config..." mkdir -p /opt/jupyterhub/etc/jupyterhub/ cp jupyterhub_config_https.py /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py echo "setup systemd service..." mkdir -p /opt/jupyterhub/etc/systemd cp jupyterhub_conda.service /opt/jupyterhub/etc/systemd/jupyterhub.service ln -s /opt/jupyterhub/etc/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service systemctl daemon-reload systemctl enable jupyterhub.service echo "Generate self signed certificate..." mkdir -p /opt/jupyterhub/etc/jupyterhub/ssl-certs openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ -keyout /opt/jupyterhub/etc/jupyterhub/ssl-certs/jhubssl.key \ -out /opt/jupyterhub/etc/jupyterhub/ssl-certs/jhubssl.crt \ -subj "/C=DE/ST=NRW/L=na/O=na Systems/OU=Self_Signed/CN=$CERTIFICATE_HOSTNAME" \ -addext "subjectAltName=DNS:$CERTIFICATE_HOSTNAME" #echo "jupyterhub.service status: (opens vim)" #systemctl status jupyterhub.service echo "Install anaconda..." #wget -O /tmp/anaconda3.sh https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh #bash /tmp/anaconda3.sh curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg install -o root -g root -m 644 conda.gpg /etc/apt/trusted.gpg.d/ echo "deb [arch=amd64] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | sudo tee /etc/apt/sources.list.d/conda.list apt-get update apt-get install -y conda #symlinking the conda shell setup script to the profile ‘drop in’ folder so that it gets run on login: ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh mkdir /opt/conda/envs/ /opt/conda/bin/conda create --prefix /opt/conda/envs/python python=3.7 ipykernel #/opt/conda/envs/python/bin/python -m ipykernel install --prefix /usr/local/ --name 'python' --display-name "Python (default)" /opt/conda/envs/python/bin/python -m ipykernel install --prefix=/opt/jupyterhub/ --name 'python' --display-name "Python (default)" #users have to setup there kernel like this: #/opt/conda/envs/python/bin/python -m ipykernel install --name 'python-my-env' --display-name "Python My Env" #conda install --yes jupyterhub jupyterlab notebook configurable-http-proxy jupyterlab-git jupyter-server-proxy #jupyter labextension install jupyter-matplotlib #echo "Install Tensorflow..." #conda install --yes tensorflow-gpu #echo "Install cantera..." #conda install --yes --channel cantera cantera #echo "Install common Python libs..." #conda install --yes h5py tqdm pandas ipywidgets pillow matplotlib ipympl opencv-python #Other tools: #System monitoring #echo "Install netdata..." #wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh #echo "nvidia_smi: yes" >> /usr/lib/netdata/conf.d/python.d.conf #service netdata restart #on http://0.0.0.0:19999 #echo "Install gpuview..." #python3 -m pip install gpuview #gpuview service --host 127.0.0.1 --port 9988 #echo "Disable services that delays startup by wating for network connectivity..." #systemctl disable cloud-config #systemctl disable cloud-final.service #systemctl disable iscsid.service #systemctl disable open-iscsi.service echo "Start JupyterHub..." systemctl start jupyterhub.service echo "" echo "Setup successfully finished"